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.

Python consumes 38x more energy than Java

52 pointsby misiaxalmost 2 years ago

17 comments

boesboesalmost 2 years ago
The actual benchmark: <a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;performance&#x2F;spectralnorm.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a><p>EDIT: fwiw, classic Fortran is twice as fast as java :P As is Rust, but that&#x27;s less funny to me
评论 #36707333 未加载
评论 #36707205 未加载
评论 #36707220 未加载
评论 #36712257 未加载
marginalia_nualmost 2 years ago
One should always be skeptical of these sorts of benchmarks, especially against Java, and I say this as primarily a Java developer.<p>Well optimized Java is very lean and can be incredibly performant, but the median modern Java app is an obese cronenberg made out of gigabytes of SpringBoot dependencies. That&#x27;s not particularly fast; and well optimized python will run circles around it.
评论 #36707219 未加载
评论 #36707265 未加载
评论 #36709499 未加载
misja111almost 2 years ago
Amazing. I have seen this list popping up in my LinkedIn feed for more than a year already and it keeps coming back.<p>While any benchmark is of course interesting when considered on its own, the conclusions that people draw from this list tend to be complete nonsense: &quot;Python is bad for the environment&quot;, &quot;we should switch to language xxx to combat global warming&quot; etc.<p>First of all, especially for the slower languages in this list, it is extremely rare that application code written in that language is the bottleneck of a performance critical application. Typically the bottlenecks of every day applications tend to be databases and network. If you need heavy number crunching, there tend to be excellent libraries available written in lower level languages, such as e.g. for Python NumPy and Pandas. If you are really concerned about the energy footprint of your application, you&#x27;re probably better off with optimizing these components. Or optimizing the higher level architecture of your own application, which tends to be a lot easier in a higher level langguage.<p>Second, coding in a faster language is often not economically possible. Programming the same application in C will normally take much longer than coding it in Python. Developing time costs money and can also mean loss of opportunity.<p>And finally, the &#x27;greenest&#x27; language of them all was not even included in this list: assembly. I guess the author must have realized in the back of his head that such a difficult language wasn&#x27;t a realistic option for switching to a more energy efficient solution. He&#x2F;she just failed to realize that this argument applies to many other languages as well.
评论 #36709714 未加载
评论 #36708066 未加载
评论 #36707628 未加载
评论 #36712896 未加载
Uninenalmost 2 years ago
Even more clickbaity title would have been &quot;Python consumes 70x more energy than Rust&quot;
评论 #36707237 未加载
评论 #36707224 未加载
评论 #36712429 未加载
评论 #36707207 未加载
_hanalmost 2 years ago
I would like to point out that the data in the table is from 2017, and CPython recently focused a lot on performance.
boredumbalmost 2 years ago
Just write in Rust, it&#x27;s easier to build good software than either of these languages (yea, yea, do you data analyst stuff in python until you start using POLARS). At this point it&#x27;s a far superior ecosystem from a developer experience point of view and the fact it&#x27;s going to get you as close to efficient as possible without you thinking too far into it is a welcome side effect.<p>Using VScode with the Sqlx package I get compile time errors on my SQL - as a result I haven&#x27;t ran a binary with a typo from my SQL in the last 12 months.
评论 #36710447 未加载
评论 #36707487 未加载
评论 #36707421 未加载
awelxtralmost 2 years ago
Does this table take into account energy used while developing&#x2F;maintaining?
评论 #36707276 未加载
评论 #36707392 未加载
radicalbytealmost 2 years ago
This is why I&#x27;m learning Rust: C# gives fast development speeds than Python with decent performance. Python and Go for when their native libraries smoke C# and now Rust for performance or low level.
评论 #36709741 未加载
pellaalmost 2 years ago
The research: &quot;Energy Efficiency across Programming Languages&quot; SLE’17, October 23–24, 2017<p>PDF: <a href="https:&#x2F;&#x2F;repositorio.inesctec.pt&#x2F;bitstream&#x2F;123456789&#x2F;5492&#x2F;1&#x2F;P-00N-4CX.pdf" rel="nofollow noreferrer">https:&#x2F;&#x2F;repositorio.inesctec.pt&#x2F;bitstream&#x2F;123456789&#x2F;5492&#x2F;1&#x2F;P...</a><p>The human mental energy required for programming, unfortunately, has not been measured. ;-)
bigfryoalmost 2 years ago
So python programmers are destroying the planet.. I just knew it all along
zelphirkaltalmost 2 years ago
While Java&#x27;s compiler or JIT is probably one of the most optimized softwares in existence, how do we measure, what overhead the language nudges the programmers to build? I am thinking of AbstractProviderFactoryProxy and similar. Or that for a very long time it forced you (or still does to a degree) to put everything into classes, breeding 1 or 2 generations of programmers, who see a noun and jump to making a class and then subsequently initializing the class to be able to call a method, which actually would only need to be a standalone function.<p>It probably does not balance the 38x, and probably the JIT optimizes parts of it away, but surely the cost is far from zero.<p>Also what about the computational resources it takes to just run a JVM, compared to running a Python program?
评论 #36707490 未加载
评论 #36709808 未加载
评论 #36707547 未加载
mgalmost 2 years ago
Is Python&#x27;s &quot;values don&#x27;t change, they get replaced by new ones stored elsewhere&quot; approach what makes it slow?<p>I would like to see some micro-benchmarks which pin down the bottlenecks.<p>For example, this minimal benchmark with one variable and a few control structures:<p><pre><code> x=0 for i in range(int(10e6)): if i&lt;50: x=x+1 print (x) </code></pre> Runs 5 times slower here than the same in PHP:<p><pre><code> $x=0; for ($i=0; $i&lt;10e6; $i++) if ($i&lt;50) $x++; echo &quot;$x\n&quot;; </code></pre> Tested with:<p><pre><code> time python3 loop.py </code></pre> Which gives me 0.31s<p>And:<p><pre><code> time php loop.php </code></pre> Which gives me 0.06s<p>A factor of five seems to be roughly the average when comparing Python to PHP for a bunch of different code constructs I tried.
评论 #36707518 未加载
评论 #36713081 未加载
Rochusalmost 2 years ago
There is a more recent paper by Pereira et al. from 2021 (see <a href="https:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;abs&#x2F;pii&#x2F;S0167642321000022" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;abs&#x2F;pii&#x2F;S01676...</a> ); if geomean is used (which is the correct method) instead of what they apparently do in the paper, there is yet a different order (see <a href="http:&#x2F;&#x2F;software.rochus-keller.ch&#x2F;Ranking_programming_languages_by_energy_efficiency_evaluation.ods" rel="nofollow noreferrer">http:&#x2F;&#x2F;software.rochus-keller.ch&#x2F;Ranking_programming_languag...</a>).
评论 #36712083 未加载
fancyfredbotalmost 2 years ago
C++ uses 34% more energy than C?<p>I thought C code was generally also valid C++ code and so you really should be able to get the same performance and energy consumption. Very odd.
评论 #36707497 未加载
评论 #36712563 未加载
tmalyalmost 2 years ago
I can see C having 1.00 in table 4 in the article.<p>But how does Python get 71.90 and JavaScript 4.45 ?<p>Something seems off there.
评论 #36715050 未加载
评论 #36714026 未加载
number6almost 2 years ago
So Python is 38x more powerful?!
jjakenalmost 2 years ago
Now compare mental energy