Live data from Hacker News

Python consumes 38x more energy than Java

stratoflow.com

81–90 of 142 posts

Re: Python consumes 38x more energy than Java

#81

Earlier quoted context omitted.

Thanks for this link. They also seemed to have avoided libraries like numpy. In my mind, python made it possible to hardware optimize with libraries like numpy quite easily. Avoiding it is a mistake. I'll try to see if I have time to play the game myself and throw my attempt in there.

If your web service runs with numpy, excellent.

A web service is not typically compute-bound, so it's doubtful a Python web app is going to use 38x more energy than a Java web app.

Re: Python consumes 38x more energy than Java

#82

Earlier quoted context omitted.

Most reasonable people in the industry understand that Java can be fast, especially in benchmark-oriented code. The problem is that the OOP-first ideology of the language and the coding culture surrounding it is not performance-oriented, especially with modern machines that don't like pointer-chasing. One not very well known fact is that just-in-time compilers have more optimisation-specific info than pure ahead-of-t…

What I noticed is that you have a lot of tools available to tune Java applications, but it was more necessary to rely on them to get to a good spot. In the Rust version, I got a 2x speed improvement by using a rayon thread pool instead of tokio, but the improvements in the Java version were 100x by the end of it.

Java tooling in general is great, that's true.

But nothing beats Vtune for squeezing the lemon of a tight loop of C code beyond any reason :-) Java just doesn't lean itself well to that kind low-level code wrangling. One misstep - and the performance house of cards falls apart.

Re: Python consumes 38x more energy than Java

#83

Earlier quoted context omitted.

The banking system.

I thought banks used COBOL?

I bet you're right and that I'm misremembering. I learned about it in the context of fronting mainframes with graphql so I wasn't thinking too much about the backend language.

Re: Python consumes 38x more energy than Java

#84
post #3

The actual benchmark: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... EDIT: fwiw, classic Fortran is twice as fast as java :P As is Rust, but that's less funny to me

Interesting, what is "Chapel"? Will need to look that up. EDIT: seems to be https://chapel-lang.org/

It is very fast and very memory efficient apparently

Re: Python consumes 38x more energy than Java

#85

One should always be skeptical of these sorts of benchmarks, especially against Java, and I say this as primarily a Java developer. 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's not particularly fast; and well optimized python will run circles around it.

As opposed to the lean Python Django webservices? What a bad take..

Re: Python consumes 38x more energy than Java

#86
post #85

One should always be skeptical of these sorts of benchmarks, especially against Java, and I say this as primarily a Java developer. 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's not particularly fast; and well optimized python will run circles around it.

As opposed to the lean Python Django webservices? What a bad take..

As opposed to well written code that doesn't use bloated frameworks.

Re: Python consumes 38x more energy than Java

#87

Earlier quoted context omitted.

I did an excercise some time ago and managed to get two file transfer apps, one in Rust and one in Java, where the performance was effectively the same (in some cases with a slight Java edge!), but the memory consumption was orders of magnitude in favor of Rust. The JVM is a wonder of engineering, and Java is indeed quite fast.

Most reasonable people in the industry understand that Java can be fast, especially in benchmark-oriented code. The problem is that the OOP-first ideology of the language and the coding culture surrounding it is not performance-oriented, especially with modern machines that don't like pointer-chasing. One not very well known fact is that just-in-time compilers have more optimisation-specific info than pure ahead-of-t…

I don’t think there is much point to these discussions without at least fixing some parameters/problem domain across languages. Of course pointer chasing is worse than a well-thought out encoding that fits many objects into a cache-line and is sequentially accessed. The question is — can the problem at hand use such a structure in the first place? Because not every problem can be solved with ECSs and the like - hell, I would even go as far to claim that most programs have a small hot loop, and otherwise spend their time slowly crawling through vast amounts of code and data in a non-orderly fashion. What part is prone to nice, sequential access is traditionally handled by the DB, which does its work very well. For the resulting 10 lines that has to be iterated through, it doesn’t really matter if it’s pointer chasing, especially when it has to wait for IO at every step in a typical server application.

So if we actually compare similar problems at hand, for a certain kind the difference is negligible, and is well offset by safety, productivity, maintainability. Hell, due to having safer primitives, one might be able to take advantage of better parallelism, that easily makes up for the slower single-core performance.

Re: Python consumes 38x more energy than Java

#88

Earlier quoted context omitted.

You seem to be conflating speed and memory usage. A spring boot app will generally be very performant. It will indeed use more memory though.

You should get your hands on say, go and go-fiber, and compare that with spring boot regarding speed and memory. And I say that with our main backend being kotlin/java and spring boot. It's a nightmare and absolute and utter garbage.

Why would it be “absolute and utter garbage”!

Re: Python consumes 38x more energy than Java

#89

Amazing. I have seen this list popping up in my LinkedIn feed for more than a year already and it keeps coming back. 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: "Python is bad for the environment", "we should switch to language xxx to combat global warming" etc. First of all, especially for the slower languages…

> "we should switch to language xxx to combat global warming" etc.

These takes fail to take into account the huge discrepancy between the market value produces by computer systems per unit of energy. It is such a huge value that it barely matters compared to most other industries, plus the net amounts are not particularly high either. Nonetheless, it can matter in certain cases, and Java is a great choice for server setups due to its GC being very efficient in doing only the necessary amount of work.

Also, I’m not convinced that a full on complex assembly app would be leaner than the same program written in a lower level language. That’s an area where compilers are very good, and humans only have so much working memory/hair on their head to hand-optimize whole programs.

Re: Python consumes 38x more energy than Java

#90
post #65
post #37

Earlier quoted context omitted.

use in what ? I severely doubt anything I do touches fortran millions times a day unless it's google search that runs on it.

Are you sure you've looked inside all those .dlls and .sos you use every day? At the end of the day Fortran is compiled and it can just create dynamic libraries which program you use depend on, and you'd never know. Heck, I wouldn't bet against using me using at least 1 Cobol library once per month, you never know what kind of craziness is going on behind the scenes.

Yes. No fortran there
Post reply on HN