Ask HN: What's so awesome about static types

2 points by francoisdevlin ↗ HN
I like dynamic languages a lot. To me, I can get way more reuse from a library without having to use monads or some similar construct. Still, there are a bunch of smart people in the Scala/Haskell/ML camps that love static typing. What's the benefit?

2 comments

[ 3.0 ms ] story [ 12.5 ms ] thread
The strongest benefit of static types for me is: You can have different forms of polymorphism if you have static type information. For example, the visitor pattern from OO-languages is obsolete in languages with enough type information available, because they can just dispatch on all argument types. For example, python or ruby cannot do such a multiple dispatch without any extra effort.
The really big one is "deterministic" static analysis of code. What I mean by deterministic is that in non-dynamic languages it's possible to find all references to variables, functions and classes with 100% certainty just by looking at the code.

This leads to 2 killer features:

- 100% reliable refactoring

- Sophisticated code navigation (call graph, inheritance graphs, go to definition are 3 that I used dozens of times a day, for example)

Of course, even languages that are traditionally thought of as static, like Java, have some dynamic features, so the above "100%" isn't quite reached in practice.