TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Energy Efficiency across Programming Languages [pdf]

192 pointsby Malfunction92over 4 years ago

29 comments

drmeisterover 4 years ago
Lisp (Common Lisp) beats all the other dynamic languages by a considerable margin. This is why I am developing Clasp - a Common Lisp implementation based on LLVM that interoperates with C++&#x2F;C (<a href="https:&#x2F;&#x2F;github.com&#x2F;clasp-developers&#x2F;clasp.git" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;clasp-developers&#x2F;clasp.git</a>) for scientific programming.<p>With Clasp, we get the best of multiple worlds. We get a dynamic language (Common Lisp) with automatic memory management and enormous expressive power that can directly use powerful C and C++ libraries. All three of these languages are &quot;long-lived&quot; languages in that code that was written 10 and 20 years ago still works.<p>Performance is really important to me and I have written a lot of code over the past four decades. I won&#x27;t develop meaningful code in any language that falls below Racket in table 4 because these language implementations are too inefficient. I furthermore want to keep using my code over the years and decades and so I won&#x27;t develop meaningful code in any language where someone else can break my code by changing the standard. My program &quot;leap&quot; was written 27 years ago in C and it is still being used daily by thousands of computational chemists. But it&#x27;s really hard to improve leap because the code is brittle largely because of malloc&#x2F;free-style memory management (brrr). For a compiled, high-performance, standard language with proven lasting power and performance - Common Lisp is the best choice.
评论 #24645240 未加载
评论 #24643220 未加载
评论 #24643162 未加载
评论 #24643133 未加载
评论 #24644679 未加载
评论 #24643086 未加载
评论 #24644072 未加载
评论 #24648137 未加载
zachruss92over 4 years ago
Something I&#x27;ve been thinking a lot about lately is environmental friendliness in software, given that data centers contribute 3% of global greenhouse emissions (same amount as the entire airline indistry).<p>I&#x27;m thinking along the lines of using interpreted languages less server side because of efficiency, but also relying on JS less client side and using WASM where it makes sense.<p>This has stemmed from me leaning Go last year and being moved by actually how much faster it is than Node for my use cases (API development and data processing).<p>Where I am curious to see the total impact is how we can take advantage of economies of scale to save money and increase efficiency. I&#x27;m thinking along the lines of scale to zero, event driven architectures.<p>Google Cloud, for example, claims they operate their data centers with industry leading efficiency while also being powered by renewable energy. At scale, do services like Cloud Run or Cloud Functions actually make a difference?
评论 #24644335 未加载
评论 #24643694 未加载
评论 #24646515 未加载
tinesover 4 years ago
I did some research on this topic in university, and our consistent result for CPU-based programs was: if it finishes faster, it uses less energy, and vice versa.<p>So it&#x27;s no surprise to see that VM-based programs use more energy; they&#x27;re slower.
评论 #24643029 未加载
评论 #24644520 未加载
StillBoredover 4 years ago
So, the Steve Jobs rumor about only allowing compiled programs on the original iphone was right? There is about a 4x energy increase going to a VM&#x27;ed language and about a 19x going to a fully interpreted one over using a natively compiled language.<p>So, the energy efficiency is actually worse than the perf loss in general.
评论 #24643050 未加载
评论 #24648719 未加载
egsmiover 4 years ago
I was really interested in how they measured power because there is a ton of nuance there.<p>They used the metric reported by a tool that limits average power via a programmable power limiter in hardware which an interesting way to do it. Totally valid but I really wish they provided more detail here. For example, did all workloads run at limit all the time? Presumably they did. Limit based throttling is a form of hysteretic control so the penalty part will be critical. How often and when the limit is hit will be critical too.
dhabover 4 years ago
&gt; In order to properly compare the languages, we needed to collect the energy consumed by a single execution of a specific solution.<p>With this, Java ranking on top 5 is quite impressive. Considering that JIT optimisations wouldn&#x27;t have really kicked in. My hypothesis is that if the Java program was allowed to run a few more times, and then compared, it would rank higher.<p>And, along the lines, couldn&#x27;t the other compiled languages and vm-based (common lisp, racket) be JIT optimised?
lebuffonover 4 years ago
Funny (old) energy efficiency story that used to be published on- line but I can&#x27;t find it.<p>It&#x27;s about the first handheld scanner for a large shipping company. The hardware was engineered and nailed down and a team was contracted to write the software. They got about 1&#x2F;2 way completed and said the box didn&#x27;t have enough ROM to handle all the features in the spec. The company contracted Forth Inc. to try and salvage the project and that was possible because they used their proprietary Forth VM and factored the heck out the code so they could reuse as much as possible and got it all to fit. (Common Forth trick)<p>10 Years later, a new device was commissioned and management was smarter! They made sure their was a lot more memory on board and a new contracted team finished the job. In the field however the batteries would not last an entire shift...<p>Forth Inc was called again. They made use of their cooperative tasking system to put the machine to sleep at every reasonable opportunity and wake it from user input.<p>Maybe it ain&#x27;t the language that matters as much as the skill and imagination of the designers and coders. Just sayin&#x27;
stephc_int13over 4 years ago
Marginal differences should be ignored in this kind of benchmark.<p>It is usually well accepted that faster execution leads to lower power usage, as long as the CPU is operating in a reasonable thermal envelope.<p>Nothing new here, except that we can have a better grasp of the different orders of magnitude.
dleslieover 4 years ago
I wonder what the carbon impact the use of those inefficient dynamic languages has had, in both desktop and backend environments?<p>I imagine it&#x27;s substantial and worth considering.
评论 #24644869 未加载
评论 #24643713 未加载
评论 #24643379 未加载
评论 #24643400 未加载
dnauticsover 4 years ago
These are computationally-heavy workloads. Do most HN programmers really do work in those domains? Is most computational work done today even in those domains (possibly, due to the amount of streaming videos, but also most of us are not coding video streamers)? Maybe a more interesting to test workload would be parsing medium-large random JSONs issued by concurrently-connecting entities. And also comparing the same setup under a low-workload scenario with a high workload scenario, possibly also comparing orchestration engines (e.g. kubernetes autoscaling).<p>I&#x27;d also be curious to probe &quot;worst case&quot; scenarios. Can you cause kubernetes to thrash spinning up and killing containers really badly, and how much of an effect does that have on energy consumption?
leothekimover 4 years ago
This appears to have been published in 2017?
drmeisterover 4 years ago
Huh - I somehow submitted the same message twice. Hacker News doesn&#x27;t let me delete it. So I&#x27;ll edit it down - see the version above about Common Lisp and our implementation of it called Clasp.
评论 #24643001 未加载
评论 #24643061 未加载
cryptoquickover 4 years ago
It&#x27;s worth noting that since this was published several years ago, and Rust has come a long way since then, it might very well top most of these benchmarks nowadays.
评论 #24647664 未加载
ncmncmover 4 years ago
Anything that seems to demonstrate C++ as slower than C is implicitly busted. You could compile the C code with the C++ compiler and get the same speed.<p>I&#x27;m looking at their table 4, with C:1.0, C++:1.56.<p>This throws the whole paper into doubt. Comparing crappy code in one language with good code in another reveals little of substance.
评论 #24648196 未加载
评论 #24657640 未加载
评论 #24648490 未加载
zelphirkaltover 4 years ago
It would be interesting to have a similar research done for distributed systems as well. Then one would have to choose programming language and library or framework for distributed systems development, if the language or the runtime einvironment does not offer support for it out of the box.
tastyminerals2over 4 years ago
I wonder how these rankings would have changed for C++ and Rust if they included compile times :)
评论 #24643209 未加载
lliamanderover 4 years ago
This is cool.<p>Now, can we get a comparison of these results vs. LOC?<p>I feel like almost any assessment of programming languages should have a table weighting the results based on how many lines of code it took to get that result.
lliamanderover 4 years ago
That Erlang is relatively power inefficient doesn&#x27;t surprise me. I wonder how much of that is due to the &quot;busy wait&quot; it uses to reduce the latency in message processing.
评论 #24647137 未加载
评论 #24643163 未加载
atroxoneover 4 years ago
Why do you consider typescript and javascript different languages?
评论 #24643230 未加载
评论 #24643194 未加载
gokover 4 years ago
previously <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15249289" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15249289</a>
beached_whaleover 4 years ago
I would love to see the one where they do CRUD&#x27;y things or do data transformations which seem to occupy a large part of compute power.
评论 #24644823 未加载
afrojack123over 4 years ago
Which real life use case would Go be better than Java? Go uses less memory but is slower than Java. Which uses cases use a lot of memory?
评论 #24648537 未加载
cphajdukover 4 years ago
Interesting to see Rust beat out C++ very slightly.
评论 #24643607 未加载
评论 #24642887 未加载
评论 #24642968 未加载
评论 #24642709 未加载
cellularmitosisover 4 years ago
Such a shame they didn&#x27;t include LuaJIT.
aibover 4 years ago
As if there weren&#x27;t enough reasons to learn Rust already, there&#x27;s a new one: We owe it to the planet.
transfireover 4 years ago
No Forth :(
tastyminerals2over 4 years ago
Lua memory consumption is surprisingly very high.
m0zgover 4 years ago
I&#x27;m surprised that Rust is ahead of C++ in their ranking, and by quite a bit. I tend to use C++ as &quot;C with STL and smart pointers&quot; basically (a-la Google), I don&#x27;t see why it&#x27;d be any slower or less energy efficient than C.
评论 #24647510 未加载
gojomoover 4 years ago
Oh heavens, busybodies are gonna ban Python and Ruby under the guise of fighting climate change.
评论 #24646671 未加载
评论 #24643062 未加载