exceptions vs. error codes
May 13th, 2005 at 10:43 amJoel has recently written another article supporting error codes and bashing exceptions. Joel is smart, he knows his programming and his articles are insightful, but IMHO he didn’t program much serious C++.
C++ is a difficult language, no question about that. But that’s what you pay for having a relatively high-level language with a close to perfect performance (by “perfect” I refer to C – the high-level assembly). When you write complex C++ code with classes that have dynamic resources (memory is most common) exceptions are *vital* to write normal & safe code. Every serious C++ programmer knows this.
Related posts:

April 27th, 2009 at 12:49
Couple of problems here:
* C/C++ performance is not “perfect.” Indeed, in the modern era, it is quite lacking. Most performance issues now are related to cache coherency and parallelism. C/C++ gives you tools to handle neither. malloc/new allocate memory where ever it happens to be free, and once allocated, it cannot be moved. A good GC language will cream C/C++ for performance, simply because it can move memory around, and align it based on how it is used. C/C++ also lack higher-level constructs that a runtime can parallelize efficiently. If I use higher-level constructs like map, the runtime can spread those across multiple processors when available (see Fortress for an extreme example of this). When I write cross-platform assembly, I either need to make my code inefficient, or to take tremendous amounts of time to customize it to a specific platform (single-core vs. quad core vs. multiple CPUs vs. OpenCL), and even then, it won’t scale to future processors. JIT is also faster than statically compiled now. There are a lot of run-time optimizations impossible at compile-time.
* Joel is a gas bag. He hasn’t coded seriously in years, and his articles show that. All that his articles are good for are to see one (often flawed) management philosophy.
Otherwise, you’re right. Exceptions are useful.