DEV Community

Discussion on: C++ is awesome, here's why...

 
codenameone profile image
Shai Almog

C++ was faster when Google search was developed. It's not as simple today. Performance is a more nuanced debate at this level and benchmarks can mislead both ways. C++ is not faster and neither is Java. There are benchmarks that can go either way.

A JIT inlines virtual methods at runtime, that's something a C++ compiler can't physically do. This is one of those super optimizations that can make a frequently used code path scream since it serves as a basis for further, even deeper optimizations. A well tuned GC can place the peek where you have idle time. C++ will pay a higher price usually on the same thread where things physically happen. To be fair a GC typically needs more RAM to play around with, especially with a JIT. It can tradeoff of more RAM vs. higher performance vs. fewer pauses but would still take more RAM overall.

Using shared pointers for everything is 2x slower at least, which is exactly my point. The C++ new operator is already slower than Javas new. So you pay a performance penalty for careful coding and lose the advantage C++ is supposed to give you.