Exceptions Are Bad

June 15, 2014

Exceptions are the primary error-handling mechanism employed by many widely-used languages. They are also a side-effect that makes a liar of the type system, and makes local reasoning about code far more difficult. They represent an undeclared method result smuggled through a back-channel separate from its declared return type. Furthermore, they transitively become an undeclared result of anything that calls that method, and anything that calls that, and so on. Trying to reason about the correct behaviour of code becomes very difficult, since the return type can no longer give you enough information. Exceptions kill modularity and inhibit composition.

Source: The abject failure of weak typing

Go uses multiple return values to propogate errors. In Scala you have Option, Either, or Validation to provide more type safe error handling.

Discussion, links, and tweets

I am learning to be programmer and math.

comments powered by Disqus