I would argue that because C is so hard to program in, even the claim to machine efficiency is arguable. Yes, if you have infinite time for implementation, then C is among the most efficient, but then the same applies to C++, Rust and Zig too, because with infinite time any artificial hurdle can be cleared by the programmer.
In practice however, programmers have limited time. That means they need to use the tools of the language to save themselves time. Languages with higher levels of abstraction make it easier, not harder, to reach high performance, assuming the abstractions don’t provide too much overhead. C++, Rust and Zig all apply in this domain.
An example is the situation where you need a hash map or B-Tree map to implement efficient lookups. The languages with higher abstraction give you reusable, high performance options. The C programmer will need to either roll his own, which may not be an option if time
Is limited, or choose a lower-performance alternative.
Microbenchmarks which are heavily gamed. Though in fairness the overall results are fairly reasonable.
Still I don't think this "energy efficiency" result is worth talking about. Faster languages are more energy efficient. Who new?
Edit: this also has some hilarious visualisation WTFs - using dendograms for performance figures (figures 4-6)! Why on earth do figures 7-12 include line graphs?
Real-world (macro) benchmarks are at least harder to game, e.g. how long does it take to launch chrome and open Gmail? That's actually a useful task so if you speed it up, great!
Also these benchmarks are particularly easy to game because it's the actual benchmark itself that gets gamed (i.e. the code for each language); not the thing you are trying to measure with the benchmark (the compilers). Usually the benchmark is fixed and it's the targets that contort themselves to it, which is at least a little harder.
For example some of the benchmarks for language X literally just call into C libraries to do the work.
It does make sense, if you skim through the research paper (page 11). They aren't using performance.now() or whatever the state-of-the-art in JS currently is. Their measurements include invocation of the interpreter. And parsing TS involves bigger overhead than parsing JS.
I assume (didn't read the whole paper, honestly DGAF) they don't do that with compiled languages, because there's no way the gap between compiling C and Rust or C++ is that small.
Their measurements include invocation of the interpreter. And parsing TS involves bigger overhead than parsing JS.
But TS is compiled to JS so it's the same interpreter in both cases. If they're including the time for tsc in their benchmark then that's an even bigger WTF.
Looking at the Energy/Time ratios (lower is better) on page 15 is also interesting, it gives an idea of how "power hungry per CPU cycle" each language might be. Python's very high
I would be interested in how things like MATLAB and octave compare to R and python. But I guess it doesn't matter as much because the relative time of those being run in a data analysis or research context is probably relatively low compared to production code.
Does the paper take into account the energy required to compile the code, the complexity of debugging and thus the required re-compilations after making small changes? Because IMHO that should all be part of the equation.
It's a good question, but I think the amount of time spent compiling a language is going to be pretty tiny compared to the amount of time the application is running.
Still - "energy efficiency" may be the worst metric to use when choosing a language.
They compile each benchmark solution as needed, following the CLBG guidelines, but they do not measure or report the energy consumed during the compilation step.
Time to write our own paper with regex and compiler flags.
I just learned about Zig, an effort to make a better C compatible language. It's been really good so far, I definitely recommend checking it out! It's early stages for the community, but the core language is pretty developed and is a breath of fresh air compared to C.
For raw computation, yes. Most programs aren't raw computation. They run in and out of memory a lot, or are tapping their feet while waiting 2ms for the SSD to get back to them. When we do have raw computation, it tends to be passed off to a C library, anyway, or else something that runs on a GPU.
We're not going to significantly reduce datacenter energy use just by rewriting everything in C.