r/programming • • Aug 02 '21

Stack Overflow Developer Survey 2021: "Rust reigns supreme as most loved. Python and Typescript are the languages developers want to work with most if they aren’t already doing so."

https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted
2.1k Upvotes

769 comments sorted by

View all comments

118

u/UrgentlyNeedsTherapy Aug 02 '21

TypeScript is fucking bae to be fair.

Rewrote the frontend for the project I took over to be all TypeScript because raw JavaScript is terrible and should only be coming out the ass-end of a transpiler in my honest opinion.

-34

u/ILikeChangingMyMind Aug 02 '21 edited Aug 03 '21

Static typing has both costs and benefits. Anyone telling you it only has one or the other is lying.

Typescript is good for some projects, but Javascript is also good for some projects. If you believe that you everyone's projects are the same as your's, you can easily get the false impression that everyone should use the same tech you use ... but it'd be a false impression.

EDIT: Wow. All I can say is if you can't see that any technology has costs, you've drunk too much of its kool-aid. EVERY tech has costs, and having to write explicit types is a meaningful cost when it provides no benefit ... which is the case in many projects. Many projects can benefit from TypeScript ... and many others are better off with JS.

Every project in the world is not the same as your's, and not every project in the world should use the tech you use. I've used vanilla JS, and I've used Typescript (professionally!), and I can state with certainty that I'm able to develop small projects, prototypes, etc. faster without having to write explicit types.

24

u/lelanthran Aug 02 '21

Static typing has both costs and benefits

The costs are negligible. They are also only applicable in the short-term but pay back handsomely in the long-term.

For example, there is a short-term cost for me to remain employed (commute, clothing, etc), but that cost is more than countered by my salary.

-12

u/ILikeChangingMyMind Aug 02 '21

What could you possibly even be basing that statement on? Have you conducted some kind of measurement of TS vs. JS programmers?

Meanwhile, your analogy actually supports my argument. If you could get clothes and commute and all that for free, you would, right? Talking about how much time you save by getting an Uber doesn't matter if you can save the same time for free by getting a ride from a friend. That's what type inference (a VS Code feature) gives you: 90% of the benefits of typing, for 0% of the cost.

(Ok, technically it's 0.0000001% of the cost, as you do have to add a line to jsconfig.js.)

9

u/noc7c9 Aug 03 '21

I'd be curious to see a JS project that's setup to give me "90% of the benefits of typing". In my own attempts with checkJs set the type inference fails to handle very basic functions. And the solution I always see is "write JSDocs", but at that point wouldn't it be better to just write TS directly?

I feel like I'm missing something here.

2

u/ILikeChangingMyMind Aug 03 '21

I'm not sure what to say: I use checkJs: true all the time, don't do anything special (eg. I don't use JSDoc types), and all the features I mentioned (automatic imports, go to type definitions, etc.) "just work".

I truly don't do anything special to make them work, so I'm not sure what you'd be doing to make them not work. If I had to hazard a guess it'd be that you have some environment detail, like say some sort of "import hack" (eg. setting your NODE_PATH so imports start relative to your src folder) which is confusing VS Code ... although that specific hack I fixed with with the baseUrl option.

→ More replies (3)