[...]
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.
Well, what to do if you are zombified with this "power" trip since
the craddle. "Power" is the only thing that counts to most biorobots,
most of whom are complex inferiority driven and zombified with violence
since the craddle. Long story.
Actually, I'm sure you didn't think that statement out. Performance
is only one of many issues
Yep, important one, but not the MOST important one in the scheme of things.
---I'd guess that correctness would be the most
important one (but even there---correctness is only important for the
features you use).
Well, correctness is a vague concept overall.
Correctness of what?
Correctness of your powerful and flexible logging and program state
monitoring system that dynamically displays the intermediate states your
program takes while doing some timely and important operations?
Correctness of your user interface design that turns out to be one of
the most important characteristics of any program because it allows you
to do the maximum number of things with the most of ease and conceptually
clear user interface design?
Correctness in terms of being able to recover from any kind of error
and continue on some time expensive operations?
Or simply dumb correctness of the low level algorithms, that are
even being correct, still make your program suck big time overall
as it is totally unintuitive, cumbersome and you name it?
"Correctness" of your documentation and making it available on all
user interface panels, dialog boxes, etc. as a context sensitive
help buttons, clearly describing you the functionality of any GUI
element or well tagged and interlink documentation, describing
your program with a fine enough degree of detail, while, at the
same time not overloading you with tons of crap, just like almost
all the Microsoft documentation does?
Or just describing you things that take at least a couple of good
paragraphs to describe in a single sentence? Again, just like
Microsoft does? Those things can not be describe in a single
sentence, and yet, that is all you get.
Is THAT correctness?
Or, the program being compatible for generations and runs
on any version of o/s, no matter what they invent more or less?
Does THAT count as "correctness"?
Does ANY kind of error handling and reporting count as "correctness"?
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.
Well, I thought the early versions of exceptions were the fastest
possible, even in principle, because they utilized the setjmp,
longjmp design and would simply abandon the stack below certain
depth by simply long jumping several levels up the stack to
setjmp label.
Interesting aspect on exception performance I saw on these thread
is the issue of exceptions "being expensive" in terms of processing
overhead. Well, it does count in exceptions of the string to number
conversion and things like that, not even clear it matters that
much because the very conversion itself is very expensive.
But my opinion is that the exception processing overhead is a non
issue since your program runs without exceptions in 99.999% of cases.
But once you do hit some exception, what does it matter how much
of a performance of exeption processing do you get, if your program
is basically screwed at that point, and about the most critical
and most important issue would be an informational aspect of it,
to give the user as much and as clear information about it, as
possible, presenting this error in a listbox of running status,
that could be scolled back to see what happened to your program
even hours ago.
Plus automatic error logging into rotating log files, that are
automatically updated and time stamped ad infinitum.
I think using exceptions in a way that they become a normal flow
of your code is a misuse of exceptions. You should not rely on
exceptions to do program logic. Otherwise the very notion of
ecxeption becomes totally distorted.
Once you hit ANY exception, take as much time as you want
to do anything you want, even going out to disk, error informing,
or anything like that. The more thoughrough job you do processing
exceptions, the better. If you can manage deallocate the heap
memory, great, it matters in C++. Luckily, in Java, it does not
matter. Because the heap deallocation is automatic and really
fine grained and optimized for local scope. So its performance
is non issue.
It is surprising to see that to this day, there is no gc in C++.
In any kind of more or less complex program the chance of memory
leaks is so high, that I doubt there are that many programs that
do not leak memory.
The same thing with threading, gui and other things, C++ is so
missing even after generations.
It's a pitty, Sun decided to take upon Microsoft with their JVM
legal case. That simply killed Java because Microsoft just dropped
it totally from their product line and stopped ANY development
with anything that even sounds Java-ish.
That is probably the biggest tragedy in the software industry,
because the non-dynamically scoped lanugages that are the bread
and butter of software industry, are not being developed.
C++ is a dead end as it stands right now in my opinion.
Today, with all dynamically scoped languages there is no issue
of portability. Take Python, PHP, Ruby, SQL that are running
the world more or less. There is no issue with "does it run
on Linux and Windows"?
And look at this pathetic C++ with all these bizarre syntax
complications. How many people in their clear mind, writing
those Egyptian hieroglyphs with templates think that anyone
else, looking at their code would be willing to spend half
an hour trying to understand that most unintuitive meaning
of those 3 mile long template definitions and all the side
effects of it?
People have milliseconds to look at some code.
I was using Java for several years and, because Microsoft
does not support anything beyond JDK 1.3, which is at leat
10 years old, you can not use generics (templates equivalent
of C++ more or less), or you can not use even swing
functionality (GUI stuff).
But, the best development environment I know of is MS
Visual Studion, and I mean BY FAR. As a result, I was forced
not to ever use generics and to this day, I have not seen
ANY problems with not using them. Yes, casting is not nice,
but in the scheme of things, at least from the stand point
of code clarity, it is MUCH better to use casting than
templates or generics. First of all, I can understand the
code in milliseconds. Try to understand someone elses code,
written by "smart" egghead, who is basically a pervert,
trying to make the simpliest looking thing, look like
a grand unifying theory.
Just look at 3 things that make Java what it is:
1) Built in threads - TOP notch idea. Helps portability
like nothing else.
2) Built-in GC. - TOP notch idea. Memory leaks will prevent
any program from running more than a couple of days in one
go.
3) Built-in GUI. Outstanding idea.
4) Binary compatibility. - The MOST important criteria for me,
BY FAR.
I don't want to write several versions of my programs to be
able to run it on ANY O/S. First of all, all that stuff is
out of the window nowadays becasue dynamically scoped languages
are already taking up the majority of sw business.
WHO in his clear mind would like to EVEN BOTHER about maintaining
all this non portable crap?
And what I am seeing is these C++ purists are sitting here and
running their mealy mouths about "purity of language" to the
point of obscene, chasing away even guys who would like to
discuss the threading, GUI or all other issues on this group.
What are you guys doing here? Trying to dig yourself down
into the ground as fast as you can manage? Digging your own
grave with a back hoe?
Do you want me to talk on 5 different groups about C++
based programming issues? And what does THAT buy you?
Fragmentation of discussions and issues?
Schitsophrenic view on system design?
Totally non-portable code?
Never being able to write a single GUI code for any O/S?
Never being able to run a binary compatible code,
while ALL dynamically scoped languages do it all day long,
ALL over the place?
Wasting weeks on cleaning up the memory leaks?
I have wasted MONTHS on trying to catch all the subtle memory
leaks in a sophisticated async based program because of some
network availability issues make you maintain all sorts of
queues, depending on user interaction, causing such headaches,
that you can not even begin to imagine from the standpoint
of memory leaks.
And still, to this day, I do have a few memory leaks.
Nothing major really, and no one will even notice it even
restarting program several times. But still, there should be
no memory leaks PERIOD.
How do you do it with C++?
Either you wake up, or smell the flowers on the graveyard.
That is the verdict for you, C++ "gurus", writing the most
convoluted crap and presenting it as a particle science
and a grand unifying theory.
It makes me puke seeing most of your code.
Every time I have to deal with someone elses code,
it makes me shiver. Because I know your cunningness and your
complex of inferiority. You'd waste hours writing some most
confusing spagetti, just to make sure it is going to take them
days to understand your code and will make you one of the
"irreplaceable". Job security trip.
Instead of writing the simpliest code that does exactly the same
thing and can be understood within milliseconds by anyone who
knows what he is doing.
Is THAT a progress?
Just look at all these "inventions" and "improvements" in C++?
Where do you think it is going to take you?
And the bottom line, with all that "great" improvement,
your programs still suck balls in vast majority of cases.
What a pitty.
--
Programmer's Goldmine collections:
http://preciseinfo.org
Tens of thousands of code examples and expert discussions on
C++, MFC, VC, ATL, STL, templates, Java, Python, Javascript,
organized by major topics of language, tools, methods, techniques.