3 ms·
It took me a while to understand why types are so important coming from stateful programming languages but it's surprisingly simple. In a stateful language type
by pandaman 7y ago
It took me a while to understand why types are so important coming from stateful programming languages but it's surprisingly simple. In a stateful language types are limited to expressions and statements are not typed. In a pure functional language, where there are no statements other than declarations, the whole program has an inherent type.
In a stateful language a complex type system will eliminate errors in some expressions e.g. "Oh, you tried to add a float number to a file handle!".
In a pure functional case a complex type system will eliminate composition errors in the whole program e.g. "Oh, you tried to throw an exception in the code which does not expect any exceptions!".
Naturally, type systems capable of typing a whole program tend to be more complex than ones only needed to type a single expression.