Live data from Hacker News

Python consumes 38x more energy than Java

stratoflow.com

51–60 of 142 posts

Re: Python consumes 38x more energy than Java

#51
post #47

Is Python's "values don't change, they get replaced by new ones stored elsewhere" approach what makes it slow? I would like to see some micro-benchmarks which pin down the bottlenecks. For example, this minimal benchmark with one variable and a few control structures: x=0 for i in range(int(10e6)): if i Runs 5 times slower here than the same in PHP: $x=0; for ($i=0; $i Tested with: time python3 loop.py Which gives me…

You can’t use time command in this sort of benchmark. You are including start up t times here.

Re: Python consumes 38x more energy than Java

#52

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.

No man spring boot is hideously slow as well compared to vanilla java. It's pretty fast compared to many other things, but that's just because vanilla java is extremely fast. You often see like 15-30 second start times for springboot apps, which is hilarious and 13-28 seconds longer than it has any business taking.

startup time?

Any java performance test is generally done against a warmed up VM - which would be representative of the 99.99% of the time the app is running. With or without spring boot.

Re: Python consumes 38x more energy than Java

#53
post #47

Is Python's "values don't change, they get replaced by new ones stored elsewhere" approach what makes it slow? I would like to see some micro-benchmarks which pin down the bottlenecks. For example, this minimal benchmark with one variable and a few control structures: x=0 for i in range(int(10e6)): if i Runs 5 times slower here than the same in PHP: $x=0; for ($i=0; $i Tested with: time python3 loop.py Which gives me…

You can’t use time command in this sort of benchmark. You are including start up t times here.

Startup times seem to be the same and also negligible:

    time python3 nothing.py
    0.011s

    time php nothing.php
    0.011s

Re: Python consumes 38x more energy than Java

#54
post #29

Earlier quoted context omitted.

Fortran is a beast. People crap on it all the time yet use it often millions of times a day without realizing it.

I don't think Fortran gets beaten up that much, it's just sort of ... ignored

There are only two kinds of languages...

Re: Python consumes 38x more energy than Java

#55

While Java'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 an…

> see a noun and jump to making a class

Even when what you Utils.see Utils.is a verb, you Utils.must still Utils.jump to Utils.make a class.

Java 5's static imports at least allow cleaning up the call site, although the documentation advises (in bold) using this feature "very sparingly".

Re: Python consumes 38x more energy than Java

#56

Earlier quoted context omitted.

No man spring boot is hideously slow as well compared to vanilla java. It's pretty fast compared to many other things, but that's just because vanilla java is extremely fast. You often see like 15-30 second start times for springboot apps, which is hilarious and 13-28 seconds longer than it has any business taking.

startup time? Any java performance test is generally done against a warmed up VM - which would be representative of the 99.99% of the time the app is running. With or without spring boot.

Startup time matters too. There's no reason you should have 2003 start times in a 2023 application.

A java application should be able to start in seconds. An inability to do so is the surefire litmus test for pulling in too many dependencies.

Re: Python consumes 38x more energy than Java

#57

Earlier quoted context omitted.

No man spring boot is hideously slow as well compared to vanilla java. It's pretty fast compared to many other things, but that's just because vanilla java is extremely fast. You often see like 15-30 second start times for springboot apps, which is hilarious and 13-28 seconds longer than it has any business taking.

Have you tried Spring native?

I've tried and worked with most of what the Spring ecosystem has on offer, and I'm not particularly impressed. It seems to codify all the practices that makes for mediocre software.

Re: Python consumes 38x more energy than Java

#58

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.

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.

As a data point I ported a spring boot application to rust and max memory lowered from 200 mb to 9 mb.

Re: Python consumes 38x more energy than Java

#59

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.

Aren't file transfers done by the kernel via sys-calls? All languages would be equally fast, given they don't do something stupid like reading and writing individual bytes.

They both boiled down to a sendfile call, effectively. The differences came to runtime weight, and parallelism strategy/implementation. It turns out that not having to pay for object headers/stack allocation by default, helps a lot more than I anticipated. I did this to actually measure what the difference was.
Post reply on HN