top
What's Wrong with C++, Anyhow?
To paraphrase Bjarne Stroustrup, C++ is the best C++ there is. I still make my living with it, and it's as good an extended mostly-C-compatible language as I can imagine. However, I lost faith in it after the ANSI committee added exception handling. At that point it became clear that the ANSI committee was off its rocker.
Why C++ Exception Handling is Evil
- You can't win, and you can't break even: It is incredibly difficult to avoid resource leaks when using C++ exception handling. Many special techniques must be followed, particularly in constructors and destructors. These techniques are not at all simple--have you seen the long magazine articles outlining how to keep exception handling from causing resource leaks? Any article with fewer than 8 pages is merely skimming the surface.
- You can't get out of the game: Do you think you can just not use C++ exceptions and thereby avoid its overhead and complexity? Forget it. If you call a single library function in some third party code which tosses an exception, your program is now exposed to all of the complexity and overhead of exception handling. All it takes is one exception thrown by one function in one library, and you're in the game whether you want to be or not. All the ANSI committee has to do is sucker one library vender into using C++ exceptions, and pretty soon we'll all have to deal with it.
C++ exceptions violate one of Bjarne's prime rules for language features: You should never have to pay for a feature you don't use. You can end up paying (dearly!) for exceptions even if your code doesn't use any.
I'd rather write correct code than spiffy code. C++ exceptions sure are spiffy, but the code that uses them is awful hard to get right.
Copyright (c) 1997 by Wayne E. Conrad, All Rights Reserved
Last Updated May 6, 1998
This page has been accidentally visited times since May 1st, 1998.
This page hosted by Get your own Free Home Page