12 ms·
If I'm going to "upgrade" from JavaScript, why would I specifically choose TypeScript? Yes, it gives some compile-time-only type safety in certain places, but
by Slackwise 8y ago
If I'm going to "upgrade" from JavaScript, why would I specifically choose TypeScript?
Yes, it gives some compile-time-only type safety in certain places, but it doesn't provide state safety like ClojureScript. I'm more worried about state/reference-based bugs creeping into my code versus type related issues, which I'll be checking via unit tests anyway. On top of that, it doesn't protect you from the usual JavaScript pitfalls since it's backwards compatible, including the bad parts.
Or am I missing something here? Is it popular because it lets you directly upgrade existing JavaScript files? I can see that being a big draw. Small and gradual improvement, yeah?
- samirm 8y agoIt's popular because OOP is the only thing most people know and understand better than any other paradigm and has been a staple of "reliable software" in big business.
- joshuacc 8y agoTypeScript supports both FP and OOP styles of programming. And it doesn't add any new OOP features on top of JavaScript.
- andyfleming 8y agoOne might argue that interfaces are an OOP feature that TypeScript adds. That said, you aren't forced to use them.
- steve_adams_86 8y agoInterfaces are excellent for defining structures in both FP and OOP paradigms in my opinion. They simply describe the shape of data. This is useful in most situations I can think of at compile time.
- brlewis 8y agoThere are various options for trading away backward compatibility to gain protection from the usual JS pitfalls. Search for "strict" on https://www.typescriptlang.org/docs/handbook/compiler-options.html https://www.typescriptlang.org/docs/handbook/compiler-option...
- always_good 8y agoWhat do you mean by "state safety" in ClojureScript? For example, it couldn't mean atoms/CAS because it's already single-threaded. Also, you'd consider upgrading to Typescript because static-typing was on your wishlist. ClojureScript isn't really a competitor. In fact, I ultimately found that "I still want a dynamically-typed language but with some technical improvements" is the weakest reasoning for switching away from Javascript which is why I ended up dropping ClojureScript. Meanwhile I've found something like Elm goes far enough to make the switch more worthwhile (static typing, built-in front-end architecture, etc).
- iLemming 8y agoYou left it too soon. Clojure.spec brings much more than most of the other type systems could deliver.