Re: Exception Misconceptions
On Dec 18, 8:31 pm, Brian <c...@mailvault.com> wrote:
On Dec 18, 2:29 am, James Kanze <james.ka...@gmail.com> wrote:
On Dec 17, 8:11 pm, Brian <c...@mailvault.com> wrote:
On Dec 17, 12:27 pm, James Kanze <james.ka...@gmail.com> wrote:
[...]
The machinery isn't that complicated. After all, you
need to be able to walk back the stack in other cases as
well (e.g. in a debugger---and what compiler doesn't
come with a debugger). The alternatives are relatively
expensive, and some people do choose their compiler
based on benchmark results (and those benchmarks rarely
test the performance when an exception is thrown). For
better or worse, performance is an issue for compiler
vendors---lower performance means less sales.
When buying a car I care about how fast it goes from 0 to
60. There's flexibility about the range for that with me,
but if a car is two to three times slower than others in
that regard, it's a big red flag
So you won't consider cars like the VW Golf, since a Ferrari
does accelerate two or three times fasters.
Actually, I'm sure you didn't think that statement out.
Performance is only one of many issues---I'd guess that
correctness would be the most important one (but even
there---correctness is only important for the features you
use). Or even availability: early implementations of
exceptions used the slower mechanism because they could get
the implementation out the door quicker that way. And so
on.
I'm not arguing with that, just saying that with the software
in question, both are free. If price/cost isn't a factor, I'd
definitely take a Ferrari.
You don't have three children:-). I wouldn't mind having a
Ferrari, either, but for day to day use, there are more
practical cars. Regardless of price. With three children and
two dogs, a van beats a Ferrari hands down. If you really live
out in the wilderness, with only dirt roads, you'll probably
prefer a Jeep. And if you have to drive and park a lot in
Paris or London, you'll want something small. As with software,
there's no silver bullet.
With regards to exception handling and C++ (to get back on
subject), if some of the early implementations of exceptions
used slower mechanisms than is considered necessary today, it's
generally because it was a question of supporting exceptions now
with the slower mechanism, or supporting them in two years time
with an optimal mechanism.
Similarly, with regards to optimizing application code: you've
only got so much time to write it in, so it's often a question
of making it take 5 milliseconds less time (over an hour), or
adding a feature. I think all really competent computer
scientists are purists, and would like for every line to be
"optimal" (foremostly in elegance and readability, but also in
terms of performance). I also think that all really competent
software engineers know how and when to make engineering trade
offs.
--
James Kanze