5 ms·
Interesting to see Rust beat out C++ very slightly.
by cphajduk 6y ago
Interesting to see Rust beat out C++ very slightly.
- petermcneeley 6y agoGiven that C++ is (mostly) as superset of C its not simply interesting its odd. Did they not simply give the C program to C++? Are they claiming that the C++ compiler compiles C programs to slower lower perf binary.
- rsanders 6y agoThat's a good point. But then you're not benchmarking C++ as a distinct language. So what would sufficiently distinguish a C++ program from a C program? Let's assume it's not just minor incompatibilities introduced to prevent compilation by a C compiler. There must have used some definition that is not explicit in the paper, but you can see in this code sample that the author used various C++ standard data types (std::string, std::array), iterators, classes, concurrency (std::thread). I'm no judge of C++ style, but perhaps it's "C++ as a C++ developer circa 1997 would have written it". https://github.com/greensoftwarelab/Energy-Languages/blob/master/C%2B%2B/fasta/fasta.gpp-5.c%2B%2B https://github.com/greensoftwarelab/Energy-Languages/blob/ma...
- iTokio 6y agoIt’s probable that they are mostly measuring implementations efficiency or GCC vs LLVM for these languages.
- dochtman 6y agoGiven that it's from 2017, I'm guessing today's results might be quite different.
- moonchild 6y agoIf you look at some of the individual benchmarks, they show that c, c++, rust, ada, and fortran are all over each other. I expect the difference in this case is either due to differences between llvm and gcc; differences in the standard library implementation; or because rust requires strict aliasing by default.
- kevincox 6y agoYup. In theory Rust and Fortran perform better than the others mostly due to the strict aliasing rules. However many benchmarks won't benefit from this difference and in practice it depends mostly on the standard library implementation and the "idiomatic" solution in each language. Of course compilers matter as well and even if they can all use LLVM the maturity of the frontends does matter.