5 ms·
It is also not necessarily true that a C compiler will be better than a C++ compiler at optimizing the same code. Even more so considering that both gcc and cla
by qsort 5y ago
It is also not necessarily true that a C compiler will be better than a C++ compiler at optimizing the same code. Even more so considering that both gcc and clang are basically C++ compilers regardless.
In most cases, giving the compiler more information to work with makes the resulting code faster. C++ is generally slightly faster than equivalent C, even though the difference is usually very small.
I have to agree with the OP, C being 34% faster than C++ is simply an absurd result.
- truffdog 5y agoDon't clang, gcc, and msvc share a bunch of code between their C and C++ frontends (and uh, share the backend).
- jcranberry 5y agoC++ has more complexity not just more information. These comparisons are always flawed because they vary not just by language but by expertise of the one writing the benchmark in each language. And I think C++ has more potential for writing suboptimal code due to its complexity. It's also not obvious that all the different c++ constructs help the compiler speed up, IMO.
- igouy 5y ago> … vary not just by language but by expertise… When you wrote "always flawed" perhaps you meant inevitably flawed ? If not, then perhaps you could suggest a practical approach that would not exhibit that variation.
- igouy 5y agoSee https://news.ycombinator.com/item?id=30505343 https://news.ycombinator.com/item?id=30505343