3 ms·
There is a cost to not using types - Dealing with bugs at runtime that would of easily been caught by a compiler. Difficulty in understanding your own code ba
by trixie_ 8y ago
There is a cost to not using types -
Dealing with bugs at runtime that would of easily been caught by a compiler.
Difficulty in understanding your own code base - functions available, parameters on those functions, the properties on the objects passed into those functions.
Refactoring - some of the most refactoring you'll do is when quickly iterating on a small application. Refactoring is super error prone, and typing minimizes those errors.
As always the typing is optional. So if it is slowing you down or some library doesn't have types, or you just don't need it in a particular case - then just use 'any'.
I've experienced typings increase my productivity in even the smallest projects. The compiler is your friend, the typings you need are often minimal and mostly inferred.
- franciscop 8y agoAgreed, I never said the opposite. But you'll agree that the costs of using types are mainly upfront, while the costs of not using them are mainly in the form of debt.
- skohan 8y agoExcept the costs of using types are usually in the form of a learning curve: i.e. when you are learning the type system it's relatively expensive, but once you've mastered it it's just part of your coding practice. When you do run into the rare issue, it's usually east to solve it. By contrast, dynamic typing problems never go away. They're usually because of a faulty assumption, or due to a typo, or they're the cumulative hours you spend trying to figure out what exactly has to be passed into a function since it's not explicitly part of the signature, and the maintainer of the library you're using didn't document it well. In the long term, static typing is much less expensive, and it's not accident that people tend to prefer more types over the course of their career rather than less types.