If exceptions are used where they are supposed to be used
(exceptional
Exceptions have a run-time overhead whether they're used or not.
That depends on the implementation. Even if exceptions have a run-time
overhead when they are not thrown, in the context of a real-time system
the real question is: is the overhead deterministic? On some
implementations exceptions have zero runtime overhead when they are not
thrown. On those implementations it might actually be faster to use
exceptions that to check the error status after every function call and
to propagate the error code back to the caller.
However when an exception is thrown we have different story. In a
real-time system you don't want exceptions to be thrown during normal
operation.
Furthermore, they often seem to be used to avoid having to check results of
operations which makes things very non-deterministic.
I fail to see the logic here. Errors reported by return values or some
error variable can be easily ignored, ignoring exceptions requires extra
effort from the programmer. Considering this, I come to the opposite
conclusion.
Personally, I would
rather use design-by-contract design-time testing to avoid situations that
could cause exceptions
Unfortunately not all exceptions can be replaced by DbC.
and actually deal with results from operations that
could fail; it's just a matter of discipline.
Either way you will need discipline (as always with C++). If you don't
use exceptions the error status must be checked after every function
call and propagated which is tedious and easy to forget. With exceptions
the RAII idiom must be applied when actions have to be undone in case of
an error.
If you're not careful, C++
exception soon become lazy-mans error checking; jusdging by the number of
times applications under XP dies and generate error reports,
That has little to do with exceptions and a lot with poor programming. I
bet a lot of those error reports have little or nothing to do with
exceptions.
C++ exceptions
don't improve robustness (the assumption here is that most desktop
applications these days make widespread use of exceptions/STL).
That assumption may be wrong. But even if it were right; what do you
think what would happen without exceptions? The best you can hope for is
that it fails silently with without malicious side effects.
Not handling exceptions falls into the same category as ignoring error
return values. The difference is that if you fail to handle a exception
the application will terminate, if fails to act on a return code the
application will hop along untill it crashes somewhere else. In both
cases the problem is the programmer, not the error reporting/handling
strategy.
I don't think exceptions are the root of all evil; they are often just
the messenger with bad news. OTOH I don't want to advocate using
exceptions as a better alternative to return codes. Sometimes return
codes are a more appropriate/better choice. It depends on the situation,
understanding the pros and cons is the key here.