by okeuro49 · 3y ago · 0 comments
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.
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...
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.
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.
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.
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.
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.