sajad torkamani

All subjective / opinionated stuff here…

Let the compiler catch errors for you

The compiler catches invalid property usages or method calls. Assuming an object is defined and accessing a property / method on it is a common runtime error (e.g., where foo is null or undefined).

Let the compiler catch these errors for you so you avoid runtime errors in production.

Easier to read = less cognitive load

Types make your code easier to understand. You can look at a function and know (not guess) what type of arguments it expects and what type of values it returns. Less guessing = less cognitive load = more brain resource left to focus on domain problems instead of juggling types in your head.

Programming is hard as it is. Let’s make our lives easier.

Easier to refactor

Knowing that the compiler will catch type errors for you gives you the confidence to rename your variables, functions, classes, etc or to move files around. Without types, you’d need a good test suite to give you the confidence to do these refactorings on a whim.

Easier to upgrade third-party dependencies

The compiler will catch type errors if new upgrades introduce breaking changes. Saves you the trouble of having to dig through changelogs (assuming they exist).

Tagged: Misc