October 13, 2003
@ 11:23 PM

Joel Spolsky writes

The reasoning is that I consider exceptions to be no better than "goto's", considered harmful since the 1960s, in that they create an abrupt jump from one point of code to another. In fact they are significantly worse than goto's:

  1. They are invisible in the source code. Looking at a block of code, including functions which may or may not throw exceptions...
  2. They create too many possible exit points for a function. To write correct code, you really have to think about every possible code path through your function...

A better alternative is to have your functions return error values when things go wrong, and to deal with these explicitly

Whoa, this is probably the second post from Joel that I've completely disagreed with. Exceptions may suck (unchecked exceptions especially) but using return values with error codes sucks a lot more.