The list places JavaScript at a score of 4.45 and TypeScript worse at 21.5. For reference, C, the most energy efficient it 1.0
The list places JavaScript at a score of 4.45 and TypeScript worse at 21.5. For reference, C, the most energy efficient it 1.0
The point is that TypeScript is JavaScript with typing syntax added on top. There is a transpile step into JS. That's how TypeScript works. The runtimes are exactly the same. Unless we're also measuring the build step? Which seems silly.
The difference should be near zero. And it's not. They clearly do not understand exactly what they are measuring.
I think the takeaway, however is the theme of a spectrum of energy efficiency, with compiled languages being more efficient than those that are not.
But I still maintain that the overall efficiency of a system is more a function of other factors.
But the argument that TypeScript generates a JavaScript, so it must have similar speed doesn't hold in general.
If the compiler in question is a whole-program compiler, it can make optimizations that a normal person couldn't do.
As an anecdote in [1] a raytracing program were implemented in both Scheme and C. The Stalin compiler (a whole-program Scheme compiler) produced an executable 45% faster than the one produced by g++. The Stalin compiler produced the excecuable by compiling Scheme to C, and then used a C compiler to produce the final executable.
The price of a whole-program compiler? Well, the compile time are huge.
[1] Scroll to Siskind's comment. https://groups.google.com/g/comp.lang.scheme/c/NJxRsdMNKz4
For those curious about the actual programs and results: https://web.archive.org/web/20071011073406/http://www.ffcons...
Programs that didn't type check were excluded.
https://github.com/greensoftwarelab/Energy-Languages/issues/...
Using the Geometric Mean or the Median with the time measurements from that table would have highlighted the middle value, like this:
JS 7.25
TS 7.80
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...