4 ms·
> needs to get the performance gain that C has over C++ With RTTI and Exceptions disabled you should be able to get almost identical performance with C and C++
by Game_Ender 15y ago
> needs to get the performance gain that C has over C++
With RTTI and Exceptions disabled you should be able to get almost identical performance with C and C++. In some cases C++ compiler has additional information that can allow it to produce faster code as well.
- cube13 15y agoYou also need to not use: STL(most implementations are too slow) Boost or STLPort(namespace and compatability issues if you're not producing executables) Most OO features like inheritance and polymorphism(a lot of that is resolved at runtime, which eats cycles) Function overloading(debatable, since the compiler should resolve the function signatures at compile time) You're pretty much left with C with namespaces at that point.
- jmccaffrey 15y agoC++ actually has some performance advantages over C, especially relating to static polymorphism (qsort v. std::sort)
- sarvesh 15y agoWithout RTTI how would you make it portable? From the thread it is clear he was also concerned about portability.
- dedward 15y agoYup, and if you avoid using any of the new language constructs like objects and whatnot that C++ brings and basically stick to standard C, maybe using just a bit of C++ sugar here and htere, true.... but at that point you might as well be using C, and the argument is really moot.
- Game_Ender 15y agoYou are wrong. Those the only two features that incur any performance penalty for just existing, and even then it's implementation dependent and in some cases can be zero (ie. zero cost exceptions). Other things that are possibly slow, like virtual functions, can be avoided in specific cases when needed. This is similar to many how C projects use structures of functions pointers, for abstraction, but not everywhere (including the Linux kernel).
- deleted 15y ago[deleted]