4 ms·
That just described how I feel about Typescript - created by Java programmers so that they can feel comfortable and not have to learn how to program in Javascri
by suzzer99 3y ago
That just described how I feel about Typescript - created by Java programmers so that they can feel comfortable and not have to learn how to program in Javascript. I was a Java dev for a decade. It's so much more tedious and less fun than programming in Javascript. I get Java recruiting emails and I shudder.
I accept that in gigantic apps worked on by multiple teams, and libraries shared with 3rd parties, Typescript makes sense. But 90% of the time I see it used it's with a smallish node app or SPA worked on by a few people, and all Typescript does is slow things down.
I feel like I can count on one hand the number of times I've gotten burnt by a run-time JS bug that a compiler would have caught. I just don't see that as a strong use case for the overhead and development drag of TS. I only see sharing lib-ish code across teams as a net benefit of TS.
99% of the time when the TS IDE complains over something that a JS linter wouldn't have caught, it's just because something wasn't defined properly in TS, not because it's an actual error in the code.
- toastercat 3y ago> That just described how I feel about Typescript - created by Java programmers Close! C# programmers. :)
- deleted 3y ago[deleted]
- okeuro49 3y ago> created by Java programmers so that they can feel comfortable and not have to learn how to program in Javascript. Well... C# .Net developers, as Microsoft found, correctly, that you can't build complex products easily with a lack of types. I also don't think many program in vanilla Javascript; it seems everyone is using JSX.
- capableweb 3y agoAre you really trying to say people couldn't build complex apps before TypeScript? I know of hundreds of examples that were made before TS... Complex apps still had lots of tests, which basically solve the same problem as TS is trying to address, without having to write a different language than what gets run by the browsers.
- sdeframond 3y agoHow would you compare the overhead of writing tests un JS to the overhead of doing proper TS? Obviously tests are still useful in TS, but not as many I think. Also, the feedback loop of a static type system is, IME, much faster than with tests only.
- jdlshore 3y agoSpeaking as someone who’s done both, you write the same tests either way. The main benefit of the type system is for IDEs, which have better code completion and automated refactorings when they can statically analyze types. Types also make type-related errors easier to debug: your tests will probably trigger the bug, but you’ll have to do some digging to figure out why. On the flip side, the TS type checker is painfully slow, the code is noisy, and you’ll waste a lot of time satisfying the type checker. For me, the sweet spot has been dynamic (runtime) type assertions in JS. Fast feedback loop, no transpilation hassles, good error messages when type-related errors occur. Downside is that now the editor can’t statically analyze types. Lately, I’ve been experimenting with using swc to transpile TypeScript without typechecking it. Now there’s a fast feedback loop and I use the IDE to discover type errors. (And the integration build checks types too.) I’ve just recently started this experiment, so jury’s out on whether it’s better than runtime type checking.
- capableweb 3y agoI end up having the same amount of tests in JS as in TS. I'm not really testing that the types are correct, but that functions work correct. So just because you're writing JS, doesn't mean that everything you would assigned types to in TS, you now write a unit test for itself. And my editor does the autocomplete thing seemingly just as well as the autocomplete I get from TS, even when I just write JS code normally.
- okeuro49 3y ago> Are you really trying to say people couldn't build complex apps before TypeScript? I said easily. Types remove whole categories of errors. I think the industry has generally found dynamic typing to be a mistake. Most dynamic languages are now trying to retrofit types.
- rikroots 3y ago> I also don't think many program in vanilla Javascript I enjoy coding in vanilla JS - my canvas library is 100% vJS, with a hand-written .d.ts file in the root directory in case anyone wants to import it into their TS project. That said, I also enjoy jogging along cliff edges and sheltering under trees during storms so I'm not the sort of person who should be offering programming advice...
- schwartzworld 3y agoJsx is really a templating language, not a replacement for JS. React still involves writing a lot of JavaScript code, and typescript helps quite a bit both with the js and the jsx.
- overgard 3y agoTypescript's type system is vastly different from Javas, and if you're using it that way you're missing most of the good parts. The great thing is it's powerful enough that you don't lose JS's dynamic features, but your code becomes much more self documenting and clearer, and your IDE has a much better idea how to support you. I would never go back to vanilla JS, typescript saves me way too much time and from too many headaches.