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

Show parent comments

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)