Live data from Hacker News

Python consumes 38x more energy than Java

stratoflow.com

111–120 of 142 posts

Re: Python consumes 38x more energy than Java

#111
post #110
post #108

Earlier quoted context omitted.

It's OpenOffice format; you should be able to open it with MS Excel too in case you prefer that.

Didn't open with ancient Excel. HTML? txt?

Must be really ancient.

Here is table 4 by geomean:

    (c) C 1.0
    (c) Rust  1.1
    (c) C++ 1.1
    (c) Swift  1.3
    (c) Fortran  1.7
    (v) Java  1.7
    (c) Ada 2.1
    (c) Chapel 2.3
    (c) Ocaml  2.4
    (v) C# 3.0
    (c) Go  3.4
    (c) Pascal  5.1
    (v) F# 5.2
    (c) Haskell 5.3
    (v) Lisp  6.1
    (i) Dart  7.8
    (i) JavaScript 8.2
    (v) Racket  8.5
    (i) Hack  11.0
    (v) Erlang 14.6
    (i) TypeScript  22.7
    (i) PHP  28.7
    (i) Jruby  31.6
    (i) Ruby  42.6
    (i) Python 51.9
    (i) Perl  60.5
    (i) Lua  78.9
And here the Rosetta algorithms (table 3) by geomean:

    (c) C 1.0
    (c) Rust 3.8
    (c) Fortran 4.1
    (v) Lisp 4.3
    (c) Pascal 4.7
    (c) Go 6.5
    (c) C++ 7.3
    (c) OCaml 7.9
    (v) Java 16.2
    (i) JavaScript 16.2
    (c) Ada 17.3
    (i) Dart 24.4
    (c) Haskell 26.3
    (c) Chapel 51.4
    (i) Ruby 56.8
    (v) Racket 59.7
    (i) Lua 89.7
    (i) PHP 91.5
    (v) Erlang 108.7
    (i) Python 115.9
    (i) Perl 166.6

Re: Python consumes 38x more energy than Java

#112
post #64

Earlier quoted context omitted.

You can write C in C++ but it won't be idiomatic C++. I've seen plenty of experienced "C++" developers that have no idea what is "shared_ptr".

True partly because shared_ptr is a relatively new language feature; I’ve been locked to a ~decade-old C++ compiler for most of my professional career, and so has everyone I know, just because support for a current compiler across platforms at any given time has been historically so spotty. It seems to be improving at the moment. > it won’t be idiomatic I just looked at the first example: C: https://benchmarksgame-te…

Oh it does too use STL, guess I’m blind. That could be part of the reason it’s slower.

Re: Python consumes 38x more energy than Java

#113

C++ uses 34% more energy than C? 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.

Last time I tried, only 3 of the 9 selected C programs seemed to compile as C++.

Re: Python consumes 38x more energy than Java

#114
post #64

Earlier quoted context omitted.

You can write C in C++ but it won't be idiomatic C++. I've seen plenty of experienced "C++" developers that have no idea what is "shared_ptr".

True partly because shared_ptr is a relatively new language feature; I’ve been locked to a ~decade-old C++ compiler for most of my professional career, and so has everyone I know, just because support for a current compiler across platforms at any given time has been historically so spotty. It seems to be improving at the moment. > it won’t be idiomatic I just looked at the first example: C: https://benchmarksgame-te…

You seem to be looking at the wrong source code.

The "Energy Efficiency across Programming Languages, SLE’17"authors provided this repo —

https://github.com/greensoftwarelab/Energy-Languages/blob/ma...

https://github.com/greensoftwarelab/Energy-Languages/tree/ma...

For a single outlier (regex-redux) there's a 12x difference between the measured times of the selected C and C++ programs.

Even so, that mostly messes up the results because the arithmetic mean is used rather than the median.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: Python consumes 38x more energy than Java

#115
post #111
post #110

Earlier quoted context omitted.

Didn't open with ancient Excel. HTML? txt?

Must be really ancient. Here is table 4 by geomean: (c) C 1.0 (c) Rust 1.1 (c) C++ 1.1 (c) Swift 1.3 (c) Fortran 1.7 (v) Java 1.7 (c) Ada 2.1 (c) Chapel 2.3 (c) Ocaml 2.4 (v) C# 3.0 (c) Go 3.4 (c) Pascal 5.1 (v) F# 5.2 (c) Haskell 5.3 (v) Lisp 6.1 (i) Dart 7.8 (i) JavaScript 8.2 (v) Racket 8.5 (i) Hack 11.0 (v) Erlang 14.6 (i) TypeScript 22.7 (i) PHP 28.7 (i) Jruby 31.6 (i) Ruby 42.6 (i) Python 51.9 (i) Perl 60.5 (i)…

To reduce the weight of outliers "average of ratios" and median:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: Python consumes 38x more energy than Java

#116

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…

The link is marketing for some consulting firm.

Re: Python consumes 38x more energy than Java

#117
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…

PHP JIT ?

Re: Python consumes 38x more energy than Java

#119
post #118

I can see C having 1.00 in table 4 in the article. But how does Python get 71.90 and JavaScript 4.45 ? Something seems off there.

71.90 arithmetic average more than the 10 selected C programs.

6.52 arithmetic average more than the 10 selected C programs.

Seems off because?

Re: Python consumes 38x more energy than Java

#120
post #115
post #111

Earlier quoted context omitted.

Must be really ancient. Here is table 4 by geomean: (c) C 1.0 (c) Rust 1.1 (c) C++ 1.1 (c) Swift 1.3 (c) Fortran 1.7 (v) Java 1.7 (c) Ada 2.1 (c) Chapel 2.3 (c) Ocaml 2.4 (v) C# 3.0 (c) Go 3.4 (c) Pascal 5.1 (v) F# 5.2 (c) Haskell 5.3 (v) Lisp 6.1 (i) Dart 7.8 (i) JavaScript 8.2 (v) Racket 8.5 (i) Hack 11.0 (v) Erlang 14.6 (i) TypeScript 22.7 (i) PHP 28.7 (i) Jruby 31.6 (i) Ruby 42.6 (i) Python 51.9 (i) Perl 60.5 (i)…

To reduce the weight of outliers "average of ratios" and median: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Geomean is the same; and it's less sensitive to outliers than arith. mean or median.
Post reply on HN