Follow

Which programming languages use the least amount of electricity, time and memory?

thenewstack.io/which-programmi

Some remarkable results. Look for instance at the difference in electricity use between and where the latter uses more than 5 times the energy.

is more than 50% more energy inefficient than

Given where stands, I am even happier for my choice of for development. Was planning on typescript before.

· · Web · 8 · 7 · 12

@niklas I think you also work(?) on stuff like that?! (or "care for that topic")

@humanetech

@El_joa
@niklas I would be interested for more of these resources posted to our community forum. The subject of energy efficiency in tech has not had the attention it deserves so far. I just posted the above article to the forum as well. Any additions welcome :)

@humanetech That's really weird, given that you don't actually run TypeScript - you run the compiled JavaScript. Perhaps they were running it using e.g. ts-node, compiling it before every run? If so, that would not be representative of real-world scenarios at all: TS code is run far more often than it is compiled.

@vinnl @humanetech while this probably wasn't what they were measuring, you can actually run Typescript without transpiling it to Javascript. Checkout the Deno runtime.

@robby @humanetech AFAIK they do still strip the type annotations before running it, although I suppose they probably do not type check your code, which should be the bulk of the computation. I think ts-node does still do that.

@humanetech I looked at the paper's classifications of languages by paradigm. I find it odd that both Perl and Ruby are considered functional languages. Ruby also doesn't appear in the OOP languages while OCaml does (OCaml has fine object system, but it's not used much and programs are primarily functional with some imperative bits).

@reynir @humanetech Also: I don't think it's *quite* right to classify JS as an interpreted language anymore...

That explains why it's so much faster than the others!

There's a lot more nuance between "interpreted" and "compiled" than seems to be discussed here, and that nuance to me at least better explains their results!

@humanetech
This data is currently old tho. Data from 2017 at the end of 2020 :).

@humanetech "All studies were conducted on a desktop with the following specifications: Linux Ubuntu Server 16.10 operating system, kernel version 4.8.0-22-generic, with 16GB of RAM,a Haswell Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz", is convenient to be aware that every single aspect of those specifications has an effect on measure (specially and energy measure), however i don't think anyone would challenge the overall results, they align perfectly with experience even in 2020 :)

@humanetech about go, does an algorithm like binary-trees has more relevance is string operations than something like fasta? if so TypeScript would actually be equal or better than Go for an server instance?

@humanetech As much as I believe the overall consensus of the article, I would like to see several independent verifications of the results found in it.

In particular, I'd like to see how the results vary when considering changing hardware architectures, OS configurations (e.g., what if the tests were running under Windows 10?), different DRAM technologies, the effects of NUMA vs. non-NUMA architectures, etc.

@vertigo @humanetech do you think go, c and javascript would change energy consumption patterns under those scenarios? (really asking), i would be inclined to think that compilers and interpreters wouldn't change much behavior (comparing for instance C and Go in Ryzen vs C and Go in Haswell) since the implementation of algorithms (and compilers) don't make use of the specific hardware) which is precisely why you have problems like Premiere running poorly in Ryzen (solved now)

@gassahara @humanetech To a limited extent, yes; Out-of-order CPU microarchitectures are dynamic, not static, and the algorithms used by specific CPU vendors can have measurable impacts on power consumption.

Do I think that Python will ever be better than C for a given task? Absolutely not. At least, not with CPython. Maybe with Pypy though? It could, if it's run on a suitable microarchitecture.

However, of particular note, NUMA vs. non-NUMA architectures, latencies with different DRAM technologies, etc. all affect the CPU regardless of microarchitecture, as they are all external to it. But, if Go can schedule goroutines so as to minimize some forms of external latency, that would be useful knowledge to have, I'd think.

@vertigo @humanetech that's interesting, exactly what i was asking for, i think the results would still, for instance put Go in the last position for binary-trees, since less latency in these architectures means more energy consumed.The organization of sections, of gcc however (since they said state-of-the-art compilers) are very friendly to the cache but doesn't affect memory loads, so it would come in the first places. The document *is* scarce in details about replication, but then, is CS! :)

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!