Live data from Hacker News

Which Programming Languages Use the Least Electricity? (2018)

thenewstack.io

131–140 of 267 posts

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

#131

Hope that the cloud providers don't bill according to energy consumption. I like Python a lot...

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.

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

#132
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.

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

#133
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?

Not really no. The closest thing to production I've used it was as a one-liner web-server to serve some images.

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

#135
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.)

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

#136
post #28

Earlier quoted context omitted.

>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…

Any articles/resources on writing high-performance JS that you would recommend? I don't use JS for work, but just for random fun stuff. So just curious to learn more about it.

Just write idiomatic code, it's what all the major engines try to optimize for.

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

#137

Earlier quoted context omitted.

Not sure why you picked on Java though. As per this study, Java is doing better than both of them. So at least if the goal is to improve on those, you need to look at Rust/C++/C/Ada.

I'm not trying to pick on it. But those languages are significantly harder to develop for. Go/Swift are trying to be general improvements that maintain and improve upon developer productivity while achieving great performance and efficient memory utilization (which if you look at the paper is one area Java is not necessarily great at).

Makes sense. It didn't come across that way since you mentioned the energy savings and then immediately mentioned those alternatives. Interestingly though, while Java used a lot of memory, the energy expenditure for DRAM is still one of the lowest for Java. And they found little correlation between memory usage and DRAM energy in general. I wonder why that is.

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

#139
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…

as not all languages get the same attention.

...which also seems to be reflective of how much programmers using language X care about (execution) efficiency, so I'd say these results are not far off from reality.

C and C++ are another interesting pair --- proponents of the latter always love to claim "zero cost abstractions" that allow you to write very abstract code which they say the compiler can then optimise (or clean up the mess, depending on your viewpoint...) to the same output as if you did it manually in C, but the results show a very different picture.

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

#140
post #121
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…

How do you get the 11 years figure? What is your idea of a drastic reduction? How will you measure it? And should all countries observe it equally?

You can play around with different setting here http://trillionthtonne.org/ The model they're based on is a few years out of date though. The trajectory our politicians put us on right now seems to suggest that they subscribe to extremely optimistic settings or are okay with absurd warming.
Post reply on HN