Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"The computer benchmarks hosted on Alioth, for example, show that C++ (running on 32-bit Linux) runs the series of tests 27% slower than C. Other surveys show this difference as slightly larger or slightly smaller."

I don't know how they can make this conclusion. I'm not even sure what it means when they say that "C++ is 27% slower". In the C benchmarking code, they hand roll a lot of the data structures whereas in the C++ code, they include either the standard library or boost. So it's not really a comparison of C vs C++ is it. There is nothing about C++ that would make that big of a difference.



>> I'm not even sure what it means when they say that "C++ is 27% slower". <<

It means the author mis-read "how many times slower, ..., compared to the fastest programs."

Compared to the fastest programs, not compared to the C programs.

Compared to C programs, and Ada programs, and C++ programs, and JavaScript programs, and Fortran programs... that were faster.


I haven't looked at the benchmark, but I'd assume that the comparison is supposed to be "idiomatic C" vs "idiomatic C++".


Possibly, but as they present it, it makes it seems as if there was something inherent that would make it so much slower.


Well, for a long time the STL string class had poor performance. Idiomatic C++ would use the STL string class. Therefore idiomatic C++ would suffer a performance penalty.


27% slower = what one program does in 1 unit of time, another program requires 1.27 units to do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: