3 ms·
Type systems aren't just about adding static type annotations to your otherwise dynamically typed code to catch a few bugs. If you embrace the type system and
by sfvisser 9y ago
Type systems aren't just about adding static type annotations to your otherwise dynamically typed code to catch a few bugs.
If you embrace the type system and start modeling your domain types with the natural invariants in mind you start seeing the real benefit. Once you enforce the invariants of your data in the types you'll notice entire categories of bugs will impossible to introduce. Abstraction barriers between different parts of your codebase will become more clear and impossible to break. Otherwise complicated architectures will become easy to express.
Types change everything.
- kybernetikos 9y ago> If you embrace the type system and start modeling your domain types with the natural invariants in mind you start seeing the real benefit. Except that few type systems have the capability to do this in a reasonable way that doesn't lead to horribly contorted code full of type-induced damage. Just look at the difficulties that people have trying to express code at a higher level of abstraction like partial application, currying, generic composition, etc (as in fantasy land or ramda) in typescript. If you're acclimatised to working in a specific type system, you'll probably never notice the areas where it stops you legitimately abstracting. > entire categories of bugs will impossible to introduce. This is true. > Otherwise complicated architectures will become easy to express. This, I think, is false. In fact many complicated architectures (depending on your type system) will become impossible to express, and to some extent this is a feature rather than a bug.
- skybrian 9y ago"Impossible to express" seems a bit much, but you might have to write your own Any type.
- deleted 9y ago[deleted]
- aczerepinski 9y agoThere's a great talk on this subject by Richard Feldman from Elm Conf. I haven't used typescript so I'm not sure if the techniques translate well. https://www.youtube.com/watch?v=IcgmSRJHu_8 https://www.youtube.com/watch?v=IcgmSRJHu_8