Live data from Hacker News

Python consumes 38x more energy than Java

stratoflow.com

71–80 of 142 posts

Re: Python consumes 38x more energy than Java

#71

Just write in Rust, it'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's a far superior ecosystem from a developer experience point of view and the fact it's going to get you as close to efficient as possible without you thinking too far into it is a welcome side effect. Using VScode with the Sqlx package I g…

Do you use an extension other than just `rust-analyzer` in order to get compile-time errors for SQL with sqlx?

I believe it's just the rust-analyzer - I only installed the rust extension via vscode so it may have included an extra bit.

Re: Python consumes 38x more energy than Java

#72
post #42

Just write in Rust, it'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's a far superior ecosystem from a developer experience point of view and the fact it's going to get you as close to efficient as possible without you thinking too far into it is a welcome side effect. Using VScode with the Sqlx package I g…

Are there any good interactive programming options in Rust? That's the main draw of a dynamic language like Python for ad hoc data science tasks, the semantics just lines up well with the highly iterative nature of the work.

I know I saw earlier in the year a Jupyter notebook for rust - but I haven't used it personally so I'm not sure how nicely it will play. I use jupyter+python to view and play with the data usually and then write my actual job in rust with Polars to use as the ETL or whatever i'm doing with it at that moment.

Re: Python consumes 38x more energy than Java

#73
post #63

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…

I think you bring up a good point. Our economic system isn't designed to reward low energy consumption. In fact, GDP and energy usage are very tightly linked. And because we are seeking growth in GDP at a system level, we are doomed to use more energy.

> GDP and energy usage are very tightly linked

Correlation or causation?

Re: Python consumes 38x more energy than Java

#74

Just write in Rust, it'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's a far superior ecosystem from a developer experience point of view and the fact it's going to get you as close to efficient as possible without you thinking too far into it is a welcome side effect. Using VScode with the Sqlx package I g…

Do you use an extension other than just `rust-analyzer` in order to get compile-time errors for SQL with sqlx?

To follow up - no, I reproduced an error - disabled my rust-analyzer extension in vscode and it went away.

Re: Python consumes 38x more energy than Java

#75

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…

I would add that proof of work algorithms (Bitcoin type) where the goal is to endlessly compute hashes with no real computational productivity gain are the real offenders, regardless of which language they're written in.

Re: Python consumes 38x more energy than Java

#76
post #63

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…

I think you bring up a good point. Our economic system isn't designed to reward low energy consumption. In fact, GDP and energy usage are very tightly linked. And because we are seeking growth in GDP at a system level, we are doomed to use more energy.

Considering energy costs money, our economic system is literally designed to reward lower energy consumption.

Re: Python consumes 38x more energy than Java

#78
post #53

Earlier quoted context omitted.

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

Startup time in Python depends on the program because Python compiles all modules to bytecode before executing them.

Re: Python consumes 38x more energy than Java

#79

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.

But isn't what makes numpy efficient written in C?

Well, the Java source uses threads. Guess how that's implemented.

FWIW if python provides an abstraction that keeps the code readable while keeping the efficiencies of C, I think that should count for python, not against it.

Re: Python consumes 38x more energy than Java

#80
post #78
post #53

Earlier quoted context omitted.

Startup times seem to be the same and also negligible: time python3 nothing.py 0.011s time php nothing.php 0.011s

Startup time in Python depends on the program because Python compiles all modules to bytecode before executing them.

When I up the loop size by a factor of 10, Python takes 10x longer. So I don't think the compile time plays a role here.

Similar for the PHP version.

    python3 loop.py
    3.450s

    time php loop.php
    0.469s
So PHP is 7x faster for the longer loop.
Post reply on HN