[PD] [offtopic] Re: That C++ is slower thing again
Larry Troxler
lt at westnet.com
Mon Nov 24 04:49:57 CET 2003
On Sunday 23 November 2003 17:12, mark wrote:
> This is an argument that is utterly ridiculous in this day and age.
>
> I used to have it with the box coders (the guys that wrote
> emebeded and onboard code) when I worked for a racing car
> firm many years ago. Then, they had a point.
Strange. "Many years ago" I coded for EPROM as well, and weirdly, it was the
corss-compiler vendors that were slow to offer C++, while I was constantly
bugging them about it. This is kind of interesting, since you apparently knew
embedded systems programmers that didn't want C++. Perhaps they were really
hardware engineers who soft of evolved into doing software, and even the
concept of using C and not assembler was very experimental in their minds.
Even though stuff like dynamic allocation was irrelevant at the time, I sure
could have used the syntactical, organizational help that C++ offers, when
doing those 128KB - 512KB ROMs. I think that paradoxically, it was because I
was so size and speed conscious, that I was in tune with what the compilers
were generating, that I realized that using C++ would have been a great
design-time convenience, whithout imposing run-time cost.
> On a modern PC
> loaded with a busy operating system (linux suffers less here
> perhaps than windows but there is still a lot going on) I defy
> ANYONE to detect a difference between what is essentially
> a few extra pointer de-references.
>
I think the misconception these days arises simply because the larger, and
hence slower, the project, the more likely it is that it uses C++ and not
just C. IOW there's some causality confusion taking effect.
Certainly (I hope!) nobody is still arguing that the virtual member function
mechanism is slowing things down!
> yes - C++ is marginally slower than C but unless you are working
> in a tiny amount of memory on low power processor I doubt it will
> effect you at all. Even the box coders would win their arguments
> based on memory usage against speed more often than not
>
No, I disagree with you here. C++ is not "marginally slower than C;". But that
statement is of course quite vague - to be more precise, you would really
have to define the environment surrounding that statement, for your assertion
to have any meaning. Without defining parameters, it's equally valid to say
that C++ is slower than C, the same as C, or in fact, is faster than C.
But for most practical purposes, C++ is the same as C as far as run-time
performance is concerned. At least, from a theoretical point of view, this
_must_ be true - both C and C++ are compiled, statically typed, languages.
Maybe some computer science graduate could verify or refute this conjecture.
Larry
More information about the Pd-list
mailing list