Comparative performance of C(gcc) and C++(g++)

John Love-Jensen eljay@adobe.com
Thu Jan 30 13:25:00 GMT 2003


Hi Ivan,

>Can i really gain in run time speed and memory using C instead C++ ?

No, you cannot gain in run time speed and memory using C instead of C++.

Well written C and well written C++ are comparable in run time speed and
memory.

Poorly written C or C++... then all bets are off.

However (BIG HOWEVER) C++ provides many Big Hammers that have known
overhead.  It is possible for someone unaware of the costs (performance
and/or code bloat) of those powerful tools, and my use them inappropriately.
For example, using a list<int> instead of a vector<int>, and wondering why
the performance is poor FOR A GIVEN PROBLEM DOMAIN.

C does not provide those kind of Big Hammers, so inexperienced or naïve
programmers cannot "accidently" use them.  Note:  many third party libraries
exist that DO provide those same kind of Big Hammers for C.  I was just
referring to the Standard C Library, and the Standard C++ Library.

>Where i can find resources in comparative benchmarking over these languages ?

I don't know.  I wrote my own, just to satisfy my own curiosity.
  
>How is the gain ( if there is ) of C over C++?

There's not.

Sincerely,
--Eljay



More information about the Gcc-help mailing list