3 ms·
I'd argue it's the exact opposite - the best of both worlds. But it is what you make of it. The poster child of gradual typing has to be TypeScript, and it's
by acoard 4y ago
I'd argue it's the exact opposite - the best of both worlds. But it is what you make of it.
The poster child of gradual typing has to be TypeScript, and it's been a wild success. TypeScript allows gradual implementation to any JavaScript project and there's almost a million small different gradients you can use. From simply using a js file, to noImplicitAny, to simple types, to using complicated built-in types (eg Partials).
With TypeScript, you never lose the speed of dynamic typing. The whole point of gradual typing is you can jump between more and less types, so at no point are you restricted from reverting to full dynamic typing. And it is true, you can't rely on all types being checked, but the point is you add it to the important/stable bits. And having your largely stable important bits being typed while your more experimental unstable code can be dynamic (while still getting the benefit of consuming the stable types) is a nice place to be.
As I said, it is what you make of it. If you spend all your time typing the unstable bits and leave the stable core bits untyped, well, you've just wasted your time and would get the worst of both worlds.
- eweise 4y agoMy only experience with gradual typing is in Dart and I was surprised that I got runtime errors around types that should have been correct. I don't follow Typescript but guessing its a wild success because it checks your types and gradual typing is a way to incrementally adopt the language. Regarding wasting time, type inference takes a lot of boilerplate out of the strictly typed code.
- haolez 4y agoThat's the theory. In practice, TypeScript projects look a lot like C#/Java ones, with lots of annotations and generics usage everywhere.