Change of mind

Static typing in dynamic languages

For a long time, I was the proponent of dynamic languages. They were more expressive and gave you more freedom to structure the program. Plus they were more concise. Typing all those type annotations was a waste of time.

Until I worked with Haskell for a while. It’s a strongly typed language, there’s no way around it.

Haskell is still expressive. It uses the smart type inferring system. No more wasted time telling the compiler every single variable type. It can infer most of that information automatically.

That changed my mind on static typing. It shows how robust well-typed code can be. The feeling of certainty of the fact that your program will run and will not crush because of some random error. No more fear of hitting this JavaScript error:

Uncaught TypeError: Cannot read property 'split' of undefined

or the common Ruby on Rails view problem:

NoMethodError: undefined method `split' for nil:NilClass

Compiler can actually ensure that this will not happen.

It’s liberating.

That eliminates certain types of unit tests. The tests checking that the code will handle malformed inputs.

Thanks to Facebook’s project flow this kind of static safety comes to JavaScript ecosystem.

I can’t wait to investigate it and to incorporate it into my daily workflow.