Live data from Hacker News

Which Programming Languages Use the Least Electricity? (2018)

thenewstack.io

161–170 of 267 posts

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

#162
post #55

Earlier quoted context omitted.

I'd be very interested in seeing a few energy benchmarks not here, for example: energy to route 1B hits to a web endpoint, energy to parse a Json, energy to grab an auth token from a web request and forward to an auth server. Energy to forward 1M 1k files from the filesystem to the network, etc.

Well, I think the reason they don't do that, and focused on the benchmark game (which I think is a good solution to their problem of needing representative sample, it just comes with its own caveats), is because much of that is often handled by libraries (possible written in C), code in the Interpreter or VM (also possibly written in C), or handled by the OS (in the case of connection handling and file access). Those…

Sure but even a language neutral ballpark could be useful to compare relative sizes. Is network or disk energy used insignificant wrt CPU or ram ? Is it roughly equivalent ?

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

#163
post #25

No mention of assembly language, which should be even lower on electricity and RAM usage than C and Pascal.

Yes, I was looking for "carefully optimised Asm" on that list too. Even if it's not faster it will pretty much always be smaller. (Compilers are surprisingly easy to beat at size optimisation.)

Well -Os can be a bit better. However I doubt program size is very significant compared to data size in Compiled languages by example.

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

#164

Earlier quoted context omitted.

They already do, in the sense that you'll need beefier/more machines to do the same job. Of course, using Python means you have a lot of low-hanging fruit to pick. We have a Python service where we moved ONE ~60 line recursive function to Go and overall CPU consumption dropped to 15-20% of what it used to be.

That sounds pretty damn nice - would you happen to have a good link in mind for reading more on the subject?

What's interesting is also how go and python interaction is since you seem to be able to call go from python and the reverse very efficiently.

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

#165
“On average, compiled languages consumed 120J [joules] to execute the solutions, while for a virtual machine and interpreted languages this value was 576J and 2365J, respectively.”

IMHO it's not quite right to evaluate energy efficiency just by looking at the runtime performance. Compiled (incl. JIT) programs have to be compiled. So for compiled programs, you have upfront costs (e.g. rust, haskell much more than c), you would have to include in the calculation. Then you have programs/script that run once (a day maybe). I wouldn't be surprised if taking this into account would change the calculation.

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

#166
post #123

Earlier quoted context omitted.

BEAM has a 'busy wait' feature. Schedulers with no jobs to do will remain active so they can respond to new jobs faster. You can turn this down so that the schedulers go to sleep quicker, reducing CPU usage. From http://erlang.org/doc/man/erl.html : +sbwt none|very_short|short|medium|long|very_long Sets scheduler busy wait threshold. Defaults to medium. The threshold determines how long schedulers are to busy wait wh…

Interesting. Have you ever used Erlang in production? How did you find it?

It's pretty obvious if you're running RabbitMQ which ranks highly in the output of `top` even if no messages are being processed.

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

#167
post #91

Couple points (I've worked on app servers): 1- This is exactly how we should all be thinking about server engineering moving forward, as we aim to drastically reduce carbon footprint within 11 years. Efficiencies at the language level are one of biggest bangs for buck here. Just by redeploying, you can reduce energy consumption by perhaps double digits. Imagine how hard that is to do at the hardware or energy farm le…

Go's GC is not really pushing the envelope. They have merely improved from a STW, non-compacting, non-generational collector with a 25% CPU overhead to a concurrent, non-compacting collector with reasonable overhead. JVMs and CLR had those a decade ago. The state of the art are concurrent, compacting, region-based pauseless or millisecond-pause collectors.

Comparing Go's GC to one of the many specialized fine-tunned Java GCs is pointless, I find.

I'm sure you're also aware that recent Go's GC pauses are sub millisecond for most use cases:

"We now have an objective of 500 microseconds stop the world pause per GC cycle." - 2018 Go team

https://blog.golang.org/ismmkeynote

My personal experience with microservices is to expect STW pauses in the 350 microsecond range. The best part is that it requires zero tunning or developer's attention while still being light on memory usage. Can't say the same for Java's default GC.

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

#168

Now, seriously: C and the boogieman of managing your own memory is a myth. Anything you want from another language can be built up from C, and be in your direct source code control working in C. Far too much propaganda is written telling programmers perfectly capable of the gains from working in C that they should be afraid of working with their own memory allocations. As if being organized is impossible.

Language runtime analysis for server-like programs seems obsessed with putting everything into a single process and address space. With C/Unix, traditionally or at least since inetd, the way to go is start a fresh process per request, which mostly just solves the problem of manual memory management (eg. because the O/S clears up the mess you left behind), at the price of latency. I'd like to see a benchmark comparing these approaches, since gc is far from being free of overhead either.

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

#170
I did not expect Lua to be that far down the list. I thought Lua was a go to choice for scripting embedded software. Also, I'm not surprised that JavaScript outperforms most of the other scripting languages (according to this potentially erroneous benchmark).
Post reply on HN