Re: We do not use C++ exceptions
on Tue Feb 03 2009, Jeff Schwab <jeff-AT-schwabcenter.com> wrote:
David Abrahams wrote:
If you give a person a lifejacket, he may be able to stay afloat long
enough to improvise a response to an unanticipated emergency situation,
in which case full recovery is a possibility. Since software can only
handle the situations the programmer can anticipate, the same reasoning
doesn't apply.
Hardware (including lifejackets) and software (including exceptions) are
no different in this sense. The presence of a life jacket proves that
someone foresaw the potential need for it. The same is true of a
throw-expression.
We don't give people life jackets in the hope that the bearers will
somehow innovate their way out of watery deaths. We hope that they
might be rescued.
Umm, no. *I* hope that it will buy them enough time to avoid death, by
innovation or rescue or providence or whatever. Rescue isn't something
one can count on either.
Sometimes this works, and sometimes it doesn't. Similarly, even
crippled software can still be useful, if only to support interactive
debugging.
Jah, if you want effective debugging, begin it at the first moment the
error is detected, not after some amount of unwinding and who knows
what-all else.
Just as a sick patient has a far greater chance of
recovery than a dead one, an ailing application beats the heck out of
a core dump. Debugging a core dump is the software equivalent of an
autopsy.
Think of it as cryogenics. If you think unwinding can *really*
resusscitate the program, you can always restart the core dumped state
under a debugger and allow it to continue. You can't seriously be
arguing that it'll be easier to cure the patient after the disease has
had a chance to make further progress?
Once a program dies, the most you can hope for is to learn
enough from the death to avoid similar problems in the future.
When the Remote Agent software on Deep Space 1 detected an internal
inconsistency, the engineers on the ground were able to debug the cause
(a race condition), and salvage the mission. Had the original
programmers chosen to terminate the application, rather than entering an
interactive debugger, the $100M mission might have been a complete loss.
Exactly, that's my point. They didn't throw an exception, they went
straight to the debugger the moment the problem was detected.
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]