Live data from Hacker News

Which Programming Languages Use the Least Electricity? (2018)

thenewstack.io

81–90 of 267 posts

Re: Which Programming Languages Use the Least Electricity? (2018)

#81
post #4

Interesting results, but I think the farther you go down the list the more the fact that you're using the Computer Language Benchmark Game affects what you're seeing, as not all languages get the same attention. For example, Javascript and Typescript. Theoretically, I would assume those to be very close, since one compiles to the other. And for memory usage, they are very close. But for running time, Typescript is an…

> Theoretically, I would assume those to be very close, since one compiles to the other. I don't think that's a safe assumption. The Javascript results would be a lower bound (assuming the same algorithm, etc.), but there's no telling what "extra" Javascript (and thus overhead) might be inserted by the Typescript compiler. As far as individual results go, there's no point jumping to conclusions when the results and c…

Typescript is a superset of Javascript, you can literally submit the faster JS programmes as the TS ones.

Re: Which Programming Languages Use the Least Electricity? (2018)

#82
post #28

Earlier quoted context omitted.

You can write literally any JavaScript program with TypeScript (falling back to the `any` type if you really need to), so this doesn't really work in this case. Also, typical TypeScript programs are faster than typical JavaScript programs, because JavaScript JITs like predictable object shapes and monomorphic functions for the same reasons that other language implementations require them. Libraries like lodash and bl…

>typical TypeScript programs are faster than typical JavaScript programs Person who works on js engines here :) You would think this is the case, but in actuality, js and ts are about on par in performance (assuming similarly written code). This is in fact due to the fact engines optimize for idiomatic js patterns, not idiomatic typescript patterns. often these will align, but in some cases (usually revolving around…

Is that changing as ts is becoming more popular? I work at Google and I think typescript is picking up quite a lot of momentum inside of Google.

Re: Which Programming Languages Use the Least Electricity? (2018)

#83
post #38

Not sure what to make of this research. It's not like I can switch out JS in favor of these other languages (many of which are compiled binaries) in my web apps. The performance of for example web servers written in the different languages entirely would seem more interesting to compare. The JS/TS comparison was directly fishy. I found no mention in the paper of how they managed to "run" the tasks in Typescript, whic…

Maybe you can switch it out :) https://webassembly.org/

It wouldn't be switching out. You'd just be running WASM.

Re: Which Programming Languages Use the Least Electricity? (2018)

#84
post #65

Earlier quoted context omitted.

It took me about a minute looking at their published detailed data to notice the problem. They should have noticed a factor-of-15ish outlier and checked why on earth it was there.

That's not how the game works. The community "plays the game" by submitting better benchmarks when they come up with better solutions.

It's not really about how the game works, it's whether the study is using sane data. In this case, it very much isn't and it should have been obvious to them the data is bad.

Re: Which Programming Languages Use the Least Electricity? (2018)

#85

This study is a bit silly, I had to check whether it was an April Fool's joke. The chipset running the instructions is going to have a far higher impact on energy usage than the language compiling those instructions. For instance, switching to ASICs or even FPGAs that are optimized to handle certain types of computations. Just look at datacenters or mobile devices. Sure, optimizations are made to runtime environments…

To the naysayers: these languages are either compiled, or will be JIT'ed at runtime. What they will be compiled to will be chip specific binaries-- x86, ARM, whatever. The energy usage will be markedly different depending on which chip architecture is chosen, and will no doubt be inconsistent between different architectures and languages.

Or to put it another way. Why do you think mobile devices almost exclusively use ARM? Why do datacenter operators invest heavily in R&D for ASICs instead of engineering new languages or runtimes? Because languages play a secondary role in energy consumption.

This study is just like countless of other meaningless benchmarks seen in language war flame posts. Pointless and misses the big picture.

Re: Which Programming Languages Use the Least Electricity? (2018)

#86
post #4

Interesting results, but I think the farther you go down the list the more the fact that you're using the Computer Language Benchmark Game affects what you're seeing, as not all languages get the same attention. For example, Javascript and Typescript. Theoretically, I would assume those to be very close, since one compiles to the other. And for memory usage, they are very close. But for running time, Typescript is an…

> Theoretically, I would assume those to be very close, since one compiles to the other. I don't think that's a safe assumption. The Javascript results would be a lower bound (assuming the same algorithm, etc.), but there's no telling what "extra" Javascript (and thus overhead) might be inserted by the Typescript compiler. As far as individual results go, there's no point jumping to conclusions when the results and c…

[deleted]

Re: Which Programming Languages Use the Least Electricity? (2018)

#87
post #29

Earlier quoted context omitted.

You can write literally any JavaScript program with TypeScript (falling back to the `any` type if you really need to), so this doesn't really work in this case. Also, typical TypeScript programs are faster than typical JavaScript programs, because JavaScript JITs like predictable object shapes and monomorphic functions for the same reasons that other language implementations require them. Libraries like lodash and bl…

So why is the TypeScript bench slower?

My best guess: probably written by someone that doeant know how to write performance TS. I say this with no skin in the game. I write neither JS nor TS. What I have observed in language benchmarks over the years, is that the benchmarks are rarely written by an expert, but usually by someone with cursory knowledge of the language. E.g. just enough to be dangerous.

Often times, these sorts of benchmarks are done with prejudice (not necessarily malice). The benchmarks are written by someone with something to prove: my chosen tech stack performs better, and let me show you why. A favorite of mine is Perl vs Python comparisons, where you see an idiomatic Perl implementation vs a non idiomatic Python implementation (or other way around). Typically in a head-to-head comparison, the benchmarks are developed by the same individual whom likely has above average knowledge in their favorite and below average in the target they're trying to show as inferior.

You'll see this time and time again in internet benchmarks comparing performance. Unless you can see the code from all benchmarks involved, my suggestion is to avoid them. I mean, for all I know, the author of the benchmark was unaware of the built in sort and instead bubble sorted.

Re: Which Programming Languages Use the Least Electricity? (2018)

#88
post #4

Interesting results, but I think the farther you go down the list the more the fact that you're using the Computer Language Benchmark Game affects what you're seeing, as not all languages get the same attention. For example, Javascript and Typescript. Theoretically, I would assume those to be very close, since one compiles to the other. And for memory usage, they are very close. But for running time, Typescript is an…

> Theoretically, I would assume those to be very close, since one compiles to the other. I don't think that's a safe assumption. The Javascript results would be a lower bound (assuming the same algorithm, etc.), but there's no telling what "extra" Javascript (and thus overhead) might be inserted by the Typescript compiler. As far as individual results go, there's no point jumping to conclusions when the results and c…

> but there's no telling what "extra" Javascript (and thus overhead) might be inserted by the Typescript compiler.

That's true, but the fact we're talking about an order of magnitude running time difference is what lead me to think it's not as easily explained as that.

> there's no point jumping to conclusions

Respectfully, I don't think I did. I put out a theory, with my reasoning, fully acknowledging where it might be wrong. As someone that doesn't use TypeScript (and I wouldn't consider myself in expert in JavaScript either), I don't feel qualified to assess the respective algorithms for those languages in the benchmarks game, so I brought the issue to a larger audience so someone else might take a look if so inclined.

> Typescript is still 2-3x slower than Node in several of the benchmarks, and the results could have been different in May 2018 when the article was written.

That doesn't really invalidate my theory, as it's possible those are also instances where it's lagging in a good submission. Given that there are several tests where it actually beats the fastest JavaScript algorthim submitted, that seems at least plausible.

Re: Which Programming Languages Use the Least Electricity? (2018)

#89

Earlier quoted context omitted.

> Theoretically, I would assume those to be very close, since one compiles to the other. I don't think that's a safe assumption. The Javascript results would be a lower bound (assuming the same algorithm, etc.), but there's no telling what "extra" Javascript (and thus overhead) might be inserted by the Typescript compiler. As far as individual results go, there's no point jumping to conclusions when the results and c…

Typescript is a superset of Javascript, you can literally submit the faster JS programmes as the TS ones.

This may be a dumb question as I know nothing about Typescript, but is it idiomatic to do that, though? You can, for the most part, use C in C++. But if C was beating the pants off of C++ in benchmarks it wouldn't tell me anything useful if someone submitted a C program as the C++ benchmark. If I wanted to use idiomatic C, I'd use C. I expect a C++ vs. C comparison to compare the encouraged features of C++ with what's available in C.

Re: Which Programming Languages Use the Least Electricity? (2018)

#90
post #23

> A faster language is not always the most energy efficient My rule of thumb now is that memory access, not compute, is the primary consumer of energy. That would tend to confirm the above statement while also supporting the data that scripting languages aren’t super energy efficient, since they tend to do a lot more dynamic allocation than compiled languages, when generally broadly speaking about common programming…

[deleted]
Post reply on HN