DEV Community

Discussion on: What Do You Think About Types?

Collapse
 
drbearhands profile image
DrBearhands

In impure languages, such as java and c, types primarily seem to be a performance feature. You can get a property of a complex type by adding an offset to the memory location of the parent type.

In pure languages, types have a wider reach as they span over effects and errors as well as data. So in this sense, impure languages tend to have a partial type system at most. This is why many people don't get the point of types.

Going further, you can be a whole lot more specific in your type system. A number isn't just a number.

That said though, I've had plenty of errors in JS and python that would have been prevented with even a basic compile-time type system. "Undefined is not a function", simply using the wrong variable, or forgetting to take a property of a value rather than the value itself. It's easy to forget such details if the algorithm you're working on is taking the majority of your attention.