Why some people go exception-less

Yan Babitski
The Startup
Published in
7 min readDec 4, 2019

--

Exceptions are nice. It’s an elegant concept supported natively by many, if not all, mainstream programming languages that help to signal that something went not as planned, and the program can not proceed with execution as usual. However, some people claim it’s an anti-pattern that should be avoided. Let’s take a look at what it’s all about.

The idea of not using exceptions sounds ridiculous. Exceptions make perfect sense; they are easy to learn and easy to use. Why would you abandon such a convenient tool? What would go next: don’t use arrays? Avoid objects? Stay away from polymorphism? But actually, if we would look at places where this idea is proposed we could find that it comes from people who understand a lot about programming: Joel Sapolsky has an article about the topic from 2003, according to C++ style guide exceptions are not used in Google C++ code, and Go (also from Google) doesn’t even have exceptions as a language feature (though technically it does it’s just called differently). So there must be a rational idea behind it.

Let’s create a use case and see what problems we might have while using exceptions.

Alice

Alice is working on an enterprise project and adds a new feature. When writing tests, Alice sees that application crashed with the following stacktrace:

--

--