Live data from Hacker News

Python consumes 38x more energy than Java

stratoflow.com

91–100 of 142 posts

Re: Python consumes 38x more energy than Java

#92

This is why I'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.

Go is not generally faster than C#/Java. There are scenarios where each can come up on top.

Re: Python consumes 38x more energy than Java

#94

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…

How is a class that holds a static method/function any different to simply namespacing? Never understood people’s problem with that. For example, what’s the problem with Java’s Math “class”? It only has stateless math functions like any other language, nothing is forced on you.

Re: Python consumes 38x more energy than Java

#95

Earlier quoted context omitted.

Please explain how "AbstractProviderFactoryProxy" is related to the language. I have taken over as lead for a Python project and what I see all the Java problems people used to make fun of (none have worked in Java before) and worse. On top, everything has an interface starting with "I", C# style. Methods in entities, service classes are instantiated with state etc. And side-effects are all over the place. If you are…

> Please explain how "AbstractProviderFactoryProxy" is related to the language. The language Java did, until some time ago, not allow you to pass functions as arguments. You had to make an anonymous inner class for example, satisfying some interface. Many design patterns are very much oriented towards a language like Java, which does/did not allow for higher order functions. Take the visitor pattern for example. It w…

You are misunderstanding the Visitor design pattern. It is not replaced by higher order functions — the point of it is to emulate multiple dispatch (over the usual single dispatch most languages have), that is, to change method implementation based not only on the receiver, but the argument as well.

(It is replaced/has an exact analog with pattern matching though. Thankfully, Java has that available nowadays as well).

Re: Python consumes 38x more energy than Java

#96

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.

LLM has entered the chat...

Most of the implementations for LLMs runtimes I know of are Python using PyTorch. I believe most of the heavy lifting is written in C++ (llama.cpp), though.

Re: Python consumes 38x more energy than Java

#97
post #63

Earlier quoted context omitted.

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?

Side effect.

Energy consumption is a result of labor applied to tools and technology for production. It is not mere correlation, but it is also not the cause, it is one measurable downstream effect.

China, in fact, used energy consumption as the measure for GDP reporting. For this reason, local leadership in cities and provinces would game the system by running the coal plants at peak and turning on all lights in a city day and night to juice the numbers so they'd show higher GDP (Beijing used to do this before they hosted the Olympics, for example).

Re: Python consumes 38x more energy than Java

#98

Earlier quoted context omitted.

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.

I mean.. threads are implemented by the OS, I don’t really see the equivalency here.

Re: Python consumes 38x more energy than Java

#99
post #90
post #65

Earlier quoted context omitted.

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

Afaik some math libraries are written in fortran that may be used by your system.

Re: Python consumes 38x more energy than Java

#100

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…

Easy? No. Rust is a far more difficult language to work in than Python.

It will require you to write more correct code, so the end product is more likely to come out better. But it is not easy, even for building "good" software. (Assumption: "good" := correct, maintainable, efficient, and robust -- Rust nails the efficient part.)

Post reply on HN