I assume he was proving a point where main() of his full program using error code checking was not in fact checking the return value of foo()<p>Even in simple example code like this you can forget a check. In this case that result would be undefined if any call to devide failed.<p>I'd much rather have my program blow up with a readable stack trace pointing to where it happened than it working with a basically random value and then maybe blowing up somewhere totally unrelated or worse, destroying user data.
I prefer Raymond Chen's take on exceptions: <a href="http://blogs.msdn.com/b/oldnewthing/archive/2005/01/14/352949.aspx" rel="nofollow">http://blogs.msdn.com/b/oldnewthing/archive/2005/01/14/35294...</a>
Nice article but as far as I'm concerned you don't need to _prove_ this as it is a logical fallacy to start with.<p>If an exception is being thrown then something is wrong, if something isn't wrong then you implemented your exceptions incorrectly as exceptions shouldn't exist in normal program flow.<p>So to recap, you're writing a crap ton of more code just so you can return your error code _slightly_ faster than it would take an exception. You're optimising your failure cases, which (in the _vast_ majority of cases) is UTTERLY ABSURD.
Perhaps the worst problem with checking-vs-exceptions is, either solution dominates your code structure, obscuring the algorithm logic.<p>The holy grail would be some method of ensuring the code cannot fail e.g. weirdly constrained argument semantics. Thus separating algorithm from constraints instead of shuffling them together on the page like a deck of cards.
Today with terabyte harddrives, gigabytes of RAM and broadband connections, when is the binary size a more important factor than both execution speed and ease of development? Especially when the binary size difference is probably not huge?<p>Shouldn't the advice of this article just be "use exceptions"?
A few issues. Does he actually benchmark? Things don't always work in practice the way you would think.<p>If you are going for ultra-high performance, do you even have error-checking? Do you write it in assembler?