3 ms·
I bounce back and forth between TypeScript and Clojure. I've been keeping a close eye on Clojure's upcoming spec as it seems to be a nice opt-in, run-time type-
by vga805 8y ago
I bounce back and forth between TypeScript and Clojure. I've been keeping a close eye on Clojure's upcoming spec as it seems to be a nice opt-in, run-time type-checking solution. I like the flexibility and quickness with which dynamic languages let me iterate, but I want the safety. I want at least some of the benefits of both.
So yes, they (dynamically typed languages) have some advantages. Sometimes when I'm iterating quickly, especially on new projects, I don't want to fight with the compiler. BUT, I vastly prefer TypeScript to JavaScript because JS has a lot of foot-guns. I think when we get the existential operator, it will have less foot-guns, but I will probably never again write a new project for work in JS from scratch.
I really love the ideas Rich Hickey put forth in his most recent Clojure conj talk: https://www.youtube.com/watch?v=YR5WdGrpoug https://www.youtube.com/watch?v=YR5WdGrpoug
The ability to spec out the shape of an object, and then in the different contexts in which you need some of that data, specify what you need, is an awesome solution to optionality (Watch the talk!). I absolutely love how much thought RH has put into the design of Clojure, and I think the final release of spec will be a close to perfect balance of dynamism and opt-in safety.
Of course, TS is a superset of JS, so adopting it little by little sorta gets me that balance I want.
- wvenable 8y ago> I don't want to fight with the compiler. The only time you're ever fighting the compiler in a modern statically typed languages with type inference is when you've made a mistake.
- SmooL 8y agoOr you're trying to do something fancy that the compiler/type system doesn't support
- wvenable 8y agoIf you're doing something so "fancy" that the compiler/type system doesn't support it, you should probably re-think it.
- nicoburns 8y agoPerhaps, but if that means doing it in a more cumbersome way, or with mire boilerplate, then that would be an area where dynamic languages have an advantage. IMO, one of the geeat things about TS is that you can opt out of the type system for specific functions if you really want to.
- zukzuk 8y agoNah, there are still some patterns, especially around metaprogramming, that TypeScript doesn't support. One example is the inability to refer to the current class inside a static method. This makes it really awkward to write things like factory methods, which in turn forces you to either resort to copy & paste coding, or fighting with the compiler. See https://github.com/Microsoft/TypeScript/issues/5863 https://github.com/Microsoft/TypeScript/issues/5863 for example.
- Nimelrian 8y agoHigher kinded types are currently not supported by the TS compiler and would be a highly appreciated feature.
- farresito 8y agoIs it really the compiler/type system's fault, though? Sounds more like a language's design or specification flaw.
- sime2009 8y ago> The ability to spec out the shape of an object, and then in the different contexts in which you need some of that data, specify what you need, is an awesome solution to optionality You realise you can do the same thing in TS with its structural type system?