3 ms·
Without meaning any disrespect, this is a sort of naive perspective that comes about when you consider a language in isolation. When you try to use exceptions,
by millstone 12y ago
Without meaning any disrespect, this is a sort of naive perspective that comes about when you consider a language in isolation.
When you try to use exceptions, you'll quickly encounter the following:
1. Your C++ code may be called by C code that knows nothing of exceptions.
2. Exceptions have big implications for API design. See for example GOTW #8 http://www.gotw.ca/gotw/008.htm http://www.gotw.ca/gotw/008.htm , which acknowledges that "some interfaces can't be implemented in an exception-safe manner."
3. try/catch/throw have performance impact. Compilers optimize for the no-exceptions-thrown case, and the practical cost of throwing an exception can be prohibitively high. Google "Zero-cost Exception" for more.
The net result is that proper exception handling is difficult to incorporate gracefully, and "exceptions are all fatal errors" is a very reasonable position. Last I checked, Firefox is compiled with -fno-exceptions, and this is how Cocoa frameworks work as well.