C++ is blazing fast. In the worst case you will get Performance of the C. In the best case you will slightly outperform C code. Of course a bit of work and knowledge is required.
Best case, C++ can definite match C in performance ~ avoid the STL, use your own optimized code.
No. Best case, high-level C++ outperforms high-level C. The classical example being std::sort, which can be optimised further than std::qsort due to the lack of function pointer indirection. Of course link-time optimisation evens the playing field again but there are similar situations (which I’ve encountered in real-world code) where link-time optimisations cannot be performed. Consequently, templated C++ code was inlined more aggressively than equivalent C code, and performed substantially faster.
Of course you could drop down to a lower-level API and match up performance again but this simply isn’t realistic for a high-quality library. That’s why it’s entirely accurate to say that, in the best case, C++ systematically outperforms C.
4
u/top_logger Jan 18 '19
C++ is blazing fast. In the worst case you will get Performance of the C. In the best case you will slightly outperform C code. Of course a bit of work and knowledge is required.