2 ms·
Why would you prefer Typescript over, say, Clojurescript if functional is your priority? It's the immutability that matters in functional. Typescript is just a
by cutler 6y ago
Why would you prefer Typescript over, say, Clojurescript if functional is your priority? It's the immutability that matters in functional. Typescript is just a better way to manage mutable code.
- eyelidlessness 6y ago> Why would you prefer Typescript over, say, Clojurescript if functional is your priority? Because the benefits of a powerful static type system (type checking, documentation, refactoring) are also a priority. I’ve used ClojureScript extensively, and shipped cljs projects in production. But one of the problems I encountered frequently was completely inexplicable behavior when I mistakenly passed incompatible values to core functions. Absolutely bonkers errors or silent failures I had to track deep into the inner recesses of cljs.core etc, generally having to reverse engineer the advanced compilation to understand what had happened. When I filed bugs on cases like this, eg asking for a meaningful runtime error, they were without exception closed as WONTFIX with snooty notes like “just don’t pass incompatible values to core functions”. While I’m quite a fan of TDD, even my extensive coverage would sometimes fail to catch issues like that. But TypeScript routinely catches them for me. > It's the immutability that matters in functional. I believe the ML family of languages would strongly disagree... > Typescript is just a better way to manage mutable code. TypeScript is a better way to catch type errors in JavaScript, mutable and immutable alike. But it does help enforce immutability if you use `readonly`/`as const` extensively, which I do. Sure, I’d vastly prefer immutability was the default. But it’s a small price to pay for such huge productivity and safety improvements.