loading...

re: What Do You Think About Types? VIEW POST

FULL DISCUSSION
 

I prefer statically typed languages. I guess the main reason is that types provide valuable documentation for interfaces. They help explaining how to use interfaces correctly and make it harder to use them incorrectly.

Of course it can be cumbersome to declare variables of complex types but that's why modern statically typed languages have type inference.

Actually I never really understood where the supposed productivity boost offered by dynamically typed languages should come from. Maybe it works well for quick prototypes or applications with very short lifecycles. Most software I am working on needs to be maintained for some years.

 

I think interface description can be achieved with decent naming only. In this regard type info is just an additional word in the name. It is not essential for a nice description but it catches misuse early.

This is something nice, I must admit. I used to have a lot of if blocks to catch runtime type errors of the arguments in my OSS code because not everyone reads the docs. Since TypeScript got so popular I just add a type def file to my projects. If someone wants type safety they can use TypeScript and vanilla JS guys can still refer to the docs.

Thanks for the (repeated) comment and sorry for the mess with Sunday's post. 😄

Code of Conduct Report abuse