Comparative performance of C(gcc) and C++(g++)
Thu Jan 30 17:11:00 GMT 2003
-----BEGIN PGP SIGNED MESSAGE-----
As most people here on the list already told you:
It depends on the problem domain and it depends on the concepts of C++
you want to use (templates, virtual functions, object inheritance, ...).
Some problems are addicted to C++ because the problem domain can use
many of the advantages of C++. Other problems can't really exploit the
advanteges of C++ and may be happier if you implement them in C because
incautios usage of C++ may be a big risk.
There is no general answer to your question, at least because you can
nearly program C using a C++ Compiler.
If you use GNU compilers the differences are mostly dependend on the
different features of the language, because AFAIK every GNU compiler
frontend translates to an intermediate code. This intermediate code than
is optimized by the compiler backend (completely independent of the
previously used language).
If you need every bit of performance use assembler. Mostly handcrafted
code is faster than produced code. (not much, but it may be around the
3-5% you were talking about.)
And a last tip: Start coding, profile your code, look where the time
gets lost, optimize only this part AND try to build a C and C++ program
for a small subdomain of your problem and look which is better for your
Ivan Vieira Velho wrote:
| My problem is decide witch language use in an project that analysis
| demonstred complex , huge and need a better use of all resources in
| the machine (highly optimized).
| The choose for Assembly was abandoned because C/C++ compilers support
| assembler and have highly optimized functions and tools. For an
| specific implementation major C/C++ compilers support inline assembler.
| Well, the last choose is the project implementation language (C or
| For me 3-5% more eficiency (speed and memory) for C is remarkable, 1-2%
| more, I will choose C++ .
| This is my problem.
| Busca Yahoo!
| O serviÃ§o de busca mais completo da Internet. O que vocÃª pensar o
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Gcc-help