[ prog / sol / mona ]

prog


Lisp is one of the most energy-efficient language

1 2020-03-10 21:46

Save our planet, make Greta Happy, use Lisp.

+--------------+------+--------------+------+--------------+------+
|              |Energy|              |Time  |              |Mb    |
+--------------+------+--------------+------+--------------+------+
|(c) C         |1.00  |(c) C         |1.00  |(c) Pascal    |1.00  |
+--------------+------+--------------+------+--------------+------+
|(c) Rust      |1.03  |(c) Rust      |1.04  |(c) Go        |1.05  |
+--------------+------+--------------+------+--------------+------+
|(c) C++       |1.34  |(c) C++       |1.56  |(c) C         |1.17  |
+--------------+------+--------------+------+--------------+------+
|(c) Ada       |1.70  |(c) Ada       |1.85  |(c) Fortran   |1.24  |
+--------------+------+--------------+------+--------------+------+
|(v) Java      |1.98  |(v) Java      |1.89  |(c) C++       |1.34  |
+--------------+------+--------------+------+--------------+------+
|(c) Pascal    |2.14  |(c) Chapel    |2.14  |(c) Ada       |1.47  |
+--------------+------+--------------+------+--------------+------+
|(c) Chapel    |2.18  |(c) Go        |2.83  |(c) Rust      |1.54  |
+--------------+------+--------------+------+--------------+------+
|(v) Lisp      |2.27  |(c) Pascal    |3.02  |(v) Lisp      |1.92  |
+--------------+------+--------------+------+--------------+------+
|(c) Ocaml     |2.40  |(c) Ocaml     |3.09  |(c) Haskell   |2.45  |
+--------------+------+--------------+------+--------------+------+
|(c) Fortran   |2.52  |(v) C#        |3.14  |(i) PHP       |2.57  |
+--------------+------+--------------+------+--------------+------+
|(c) Swift     |2.79  |(v) Lisp      |3.40  |(c) Swift     |2.71  |
+--------------+------+--------------+------+--------------+------+
|(c) Haskell   |3.10  |(c) Haskell   |3.55  |(i) Python    |2.80  |
+--------------+------+--------------+------+--------------+------+
|(v) C#        |3.14  |(c) Swift     |4.20  |(c) Ocaml     |2.82  |
+--------------+------+--------------+------+--------------+------+
|(c) Go        |3.23  |(c) Fortran   |4.20  |(v) C#        |2.85  |
+--------------+------+--------------+------+--------------+------+
|(i) Dart      |3.83  |(v) F#        |6.30  |(i) Hack      |3.34  |
+--------------+------+--------------+------+--------------+------+
|(v) F#        |4.13  |(i) JavaScript|6.52  |(v) Racket    |3.52  |
+--------------+------+--------------+------+--------------+------+
|(i) JavaScript|4.45  |(i) Dart      |6.67  |(i) Ruby      |3.97  |
+--------------+------+--------------+------+--------------+------+
|(v) Racket    |7.91  |(v) Racket    |11.27 |(c) Chapel    |4.00  |
+--------------+------+--------------+------+--------------+------+
|(i) TypeScript|21.50 |(i) Hack      |26.99 |(v) F#        |4.25  |
+--------------+------+--------------+------+--------------+------+
|(i) Hack      |24.02 |(i) PHP       |27.64 |(i) JavaScript|4.59  |
+--------------+------+--------------+------+--------------+------+
|(i) PHP       |29.30 |(v) Erlang    |36.71 |(i) TypeScript|4.69  |
+--------------+------+--------------+------+--------------+------+
|(v) Erlang    |42.23 |(i) Jruby     |43.44 |(v) Java      |6.01  |
+--------------+------+--------------+------+--------------+------+
|(i) Lua       |45.98 |(i) TypeScript|46.20 |(i) Perl      |6.62  |
+--------------+------+--------------+------+--------------+------+
|(i) Jruby     |46.54 |(i) Ruby      |59.34 |(i) Lua       |6.72  |
+--------------+------+--------------+------+--------------+------+
|(i) Ruby      |69.91 |(i) Perl      |65.79 |(v) Erlang    |7.20  |
+--------------+------+--------------+------+--------------+------+
|(i) Python    |75.88 |(i) Python    |71.90 |(i) Dart      |8.64  |
+--------------+------+--------------+------+--------------+------+
|(i) Perl      |79.58 |(i) Lua       |82.91 |(i) Jruby     |19.84 |
+--------------+------+--------------+------+--------------+------+

source: https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf

2 2020-03-11 02:55 *

ok

3 2020-03-11 13:23 *

>>2
Python is an ecological disaster. It's a strong argument against it. If people are truly concerned then they should switch. But to be fair, I just wanted to insert a M-x table-capture generated table here

4 2020-03-11 17:26 *

>>3 fair excuse, lol

5 2020-03-11 18:32

because nobody uses it?

6 2020-03-11 18:59 *

>>5
You've just been using it.
But keep wasting CPU cycles and RAM with your unethical Python code. Do not complain about global warming afterwards.

nobody

the Happy Few*

7 2020-03-11 21:17

>>3

Python is an ecological disaster. It's a strong argument against it. If people are truly concerned then they should switch.

Evidently, you will be able to link a study that, instead of merely CPU and RAM at runtime, accounts for the energy consumption of the human developers during the vastly different amounts of development time required to produce code of equivalent or nearly equivalent functionality in those various languages. Otherwise, you would be selecting a narrow slice of the energy cost to suit your conclusion, and using this to claim anything about the environmental impact would be both unscientific and ridiculous to such a degree that Greta's happiness would be much better served by simply handing her Hermione Granger as a girlfriend.

8 2020-03-11 21:34 *

I believe this to be an important and interesting topic, but this paper is so sloppily done it could have been written by sociologists.

The paper starts by asking the question: ``Can we compare the energy efficiency of software languages?'' Of course anyone who understands the difference between a language and an implementation will quickly tell you that no, you cannot, yet the authors claim that they did so. The actual language implementations are listed on the companion website, where you can learn that Python means CPython 3.5.2, Lisp means SBCL 1.3.3.debian, and for OCaml they are using the optimizing (native) compiler (version 4.05.0). They were running all this on an Intel i5-4660, and measured the energy consumption using some Intel tool. Yet they claim that their results are ``externally valid'' and general, despite not measuring alternative implementations or running on other architectures, or even just two different microarchitectures.

For the measurements, they are using a subset of the Computer Language Benchmark Game. These programs are very computation intense, and are characterized by a single, long burst of near uniform performance. The paper does not concern itself with questions whether these are representative of usual load, or in what cases it might be representative, or why it might not make sense to measure something else.

Having measured the energy consumption and execution times, they ask whether there is linear proportionality between the two. Unsurprisingly they find that while the fastest program consumes the least energy, there are also cases where a faster program consumes more energy than a slower one. They do not investigate what could have caused this. Furthermore, they do not concern themselves with trying to explain what "energy efficiency" actually means, and seem to rely on using total energy consumption instead.

Next, they want to investigate whether memory usage correlates with energy consumption. Sadly they are only measuring peak memory usage (using the time utility!), which turns out to be completely useless.

Finally, they take their results and try to recommend languages based on it, concluding that if you want to save both time and energy, you should write everything in C, but if you want to also save memory, you can try Pascal too.

In general this seems to be a filler paper. They took existing tools and programs, started the benchmarks, leaned back, drank some coffee, presented the results, all without even once questions if any of it made sense.

By far the most interesting result is the fact(?) that the change from SBCL 1.3.3 to 1.4.3 made Lisp somewhat slower everywhere, except for `fasta', which is up to four times as efficient in all three measures with the new compiler.
https://sites.google.com/view/energy-efficiency-languages/updated-functional-results-2020
https://sites.google.com/view/energy-efficiency-languages/results

9 2020-03-12 07:52

https://theses.liacs.nl/pdf/2017-2018-BeinemaEmiel.pdf

Some BSc student tried replicating the results and improving the measurements. Unfortunately, they only measured C++, Go and Python.

10 2020-03-24 05:48 *

>>8
Write your own paper. Noone can do a perfect study. This is kind of the point of research. At least they made a contribution in providing a starting point for others to continue.

11 2020-03-27 20:55

>>10
Critiquing what they did is a perfectly valid way to continue.

12 2020-03-28 18:38 *

>>11
Too bad it read less like a critique of the paper and more like an ad hominem of the authors.

13 2020-03-31 16:39 *

>>12
I am sorry that you feel this way. The main issue with the paper is that it presents very specific results but then proclaims them as general. For every language they take a single implementation and run it on a single microarchitecture. They do admit that with time the results might change due to compilers improving, but they do not address the question of possible differences due to hardware at all.

14 2021-10-10 14:53 *

>>1

Save our planet, make Greta Happy, use Lisp.

Why do you say "use Lisp" when it is abundantly clear that Lisp is a loser? Based on the data in the table, you should have said "use C" instead!

15 2021-10-10 16:29

So would using, say, Chicken or Nanopass-ed Chez, count as using C or not?

16 2021-10-10 17:14

>>15
Doesn't Haskell compile to C also?

17 2021-10-10 19:27

Language efficiency is irrelevant in most domains; otherwise the dominant constraint on efficiency tends to be improper thinking. Languages can improve this by encouraging reuse, but in reality this seems not too significant. To my eyes improper thinking's dominance comes from within established abstractions which may or may not be language dependent.

Now clearly there are domains where language efficiency is relevant. Typically this happens when you're running at scale, or when many potential users are precluded access due to performance even after all major errors in thought have been removed. ( note real-time systems are excluded from this list as the issue there is not performance but consistency ) With this in mind I posit that one should care exactly when you think you might end up in this scenario, and not otherwise. Even in this case it's likely that only parts of the application need to be written in an efficient language.

This is my opinion anyway.

18 2021-10-10 21:55

>>16

Oh, I think there are lots of languages that can compile to C, I'm just curious if HLL -> C has a similar (runtime) efficiency to C, energy-wise.

19 2021-10-11 00:38

I agree with >>17, language efficiency is irrelevant in most domains. It is typically applications with "large scale operations" that demand tight resource constraints; there's plenty of applications that don't have such constraints.

For the work that I normally do, programmer time is significantly more expensive than computer time. The programmer time cost of iterating and proving logic is normally more important to me.

20 2021-10-11 20:54 *

>>17,19
This thread is about energy-efficiency, not "language efficiency", whatever that may be.

21 2021-10-11 22:03 *

>>20
That's right, the thread is about energy efficiency. I'm making the argument that energy efficiency is not important for the vast majority of programmers. Energy efficient software is normally a significant investment of the programmer's time. That's the cost of being energy efficient.

22 2021-10-12 07:28

>>21
That's not the argument being made in >>17,19. Read the posts again. They do not mention energy-efficiency at all, they don't even imply it. They talk about "language efficiency", without mentioning what it is supposed to be.

The question is not about the programmers' time. Your careless Python programs are destroying the planet and we are all going to die because of you. Your time is not worth more than the time of the whole of humanity and all other living beings. Energy efficiency is important for everyone other than programmers.

23 2021-10-12 09:11 *

Your careless Python programs are destroying the planet and we are all going to die because of you. Your time is not worth more than the time of the whole of humanity and all other living beings. Energy efficiency is important for everyone other than programmers.

No you are a liar. If you were truly serious about this, you would leave your house. You would never touch a computer ever again. You would never have anything to do with mass produced electricity. This is the only way you'd be consistent with what you say here. You would never do this because you are actually a liar.

24 2021-10-12 16:33

OK, but seriously, if you have some garbage-collected, untyped language that compiles to C and you write a benchmark (say fasta or k-nucleotide) or make a benchmark specific to your domain- do the compiled versions tend to run more like the high-level language or more like C (I'm not talking energy in particular, just in general).

25 2021-10-12 17:51

>>20
They probably differ by a linear factor running very similarly to one another because you wrote the same algorithm twice. The linear factor whether from peep-hole optimizations or smaller run-time will be relevant when it is, and not otherwise. Chances are your application is not using optimal algorithms, or contains superfluous representation conversions, or solves a more expensive problem than necessary, etc. it'd be advantageous to focus on these first. After you resolve these high-level issues if linear factors are still relevant for your use case you can rewrite relevant portions in a low-level language like NASM (perhaps this can even be done inline as in GOOL of Crash Bandicoot fame).

26 2021-10-12 21:26

>>24
Most importantly it would need runtime checks for the types. Why not measure it yourself?

27 2021-10-12 22:41

>>26
Mostly, because I haven't learned C yet.

28 2021-10-12 22:50

>>26
Wait, so if you had a program that read in a bunch of numbers from a file and then did some calculations with them and you had 2 programs:

1. written in C
2. written in Scheme and then compiled to C

There would be be a bunch of type checks in the executable for program 2 that weren't in program 1?

29 2021-10-13 01:46

>>28
Scheme is dynamically and strictly typed, no? So there must be type checks whenever you do an operation on a variable to make sure the operation is legal for the variable's current value. I'm not a very experienced programmer (or the guy you're asking), but this is my understanding of it.

30 2021-10-13 11:54

>>29

That's what I wasn't sure about (I also wrote >>27 )- on the way from Chicken Scheme or Chez to C it seems like a lot of the variables could end up having type declarations added. Specifically, anything in a let that never was set! -or even if it was set!, if you were re-writing it in C in SSA form.

31 2021-10-18 22:38

Notice how Scheme is not on the list. Are the results too embarrassing to publish? Is this a blatant attempt to mislead the public about the performance of Scheme implementations by piggybacking on the good performance of Common Lisp's SBCL?

32 2021-10-18 23:57

If you want to make Greta happy just ditch the PC and go learn smoke signals. Well wait... No, better learn nothing at all and life in a cave.

33 2021-10-19 10:51

>>32
Smoke signals cause air pollution. Greta would not be happy about that.

34 2021-10-19 15:35

>>33
Yes, that's why i said it's better to learn nothing at all.

35 2021-10-20 07:04 *

Is making these ridiculous claims (the next one will be "omg Greta would hate you for exhaling CO₂!!!") a coping mechanism? The choice is not between excessive waste of our limited resources and complete abandonment of civilization. You can use the resources available in a responsible manner. Instead of building strawmen, plant a tree or something.

36 2021-10-20 08:20 *

>>35
OP is just trolling us. The rest of us enjoy interacting with a troll.

37 2021-10-22 13:30 *

>>35
Javashitters should be made to plant a tree to account for the excessive energy consumption of webshit.

38 2021-10-22 14:43

>>37
Please look at the table. Java is more energy efficient than Lisp. Lispers should also be made to plant trees.

39 2021-10-22 14:57

Trees are good. It's nice to have something to keep your 100% non-isolated home warm in winter when to 1950 windows are leaky as fuck.

40 2021-10-22 17:43

>>37
They also force people to throw away their old hardware if you want to keep using "modern" websites.

41 2021-10-22 18:15

Fair point. It's kinda ambiguous though. Often times newer hardware is more energy efficient. Not sure what's better option here: Africans sitting on a dump burning the plastic to get at the metal or a bit higher energy consumption. Probably the higher consumption. New hardware costs money and i don't like that.

42 2021-10-22 21:59

>>38
Please look at my face. Javashit is Javascript, not Java. Javashit is less energy efficient than Lisp by a factor or 2, therefore Javashitters should plant double the trees.

43 2021-11-18 19:05

They have a new paper out: https://haslab.github.io/SAFER/scp21.pdf (this is a preprint)

44 2021-11-18 21:33

What sort of sucker would care about global environmental issues beyond global agreements? If only domestic environmental concerns would be more prominent. The group think is just so overwhelming that scarcely anyone I know can think for themselves.

45 2021-11-18 23:37 *

What sort of sucker wastes their energy thinking about this shit?

46 2021-11-19 00:37

>>45
double snore.

47 2021-11-20 07:17 *

>>44
I believe that we are living in a communist conspiracy to utterly destroy society such that society will desire to live as subsistence communists. I get this from reading from the communist Herbert Marcuse and what he believes about society and communism. Marcuse says that he wants normal people to stop desiring to work as pieces of cogs in the perpetual economy machine, a machine that produces significant prosperity for everybody. Marcuse hates that the life energy devoted to working for the perpetual economy machine means that people do not desire a subsistence communist life. His grand idea is to change the very biology of humans so that humans can't help but desire a subsistence communist life.

One of the ways to change the nature of society is through managing the economy such that the economic machine becomes a "circular economy". What this means is that there is some kind of economy commissar who controls all economic activity such that everybody gets the perfect amount of what they need to subsist. No amount of excess or advancement is allowed for the economy. The ideal of the circular economy is expressed today is in multiple ways: anthropogenic climate change leading towards a "sustainable economy and society", there is also the Environmental-Social-Governance score (ESG score) that leads towards an "equitable economy" that enjoins together private businesses and government control over businesses.

If I am correct in this analysis, we are heading towards Herbert Marcuse's outcome to utterly destroy our current society for the sake of his perfect utopia of communism: a communism where we all live simple lives, we will own very little, and they will proclaim that we are happy and free within this utopia. I will tell you this: some communists will be more equal than other communists, they will live the life of luxury eating meat, driving cars, enjoying air conditioning, enjoying heated baths while the rest of us as happy subsistence communists eating vegetables and bug protein.

48 2021-11-20 16:35

>>47
Actually existing communists states didn't care much for the environment. The focus was always on rapid industrialization and "catching up with the west" (the only exception that comes to mind is Cambodia, if you count it at all and I'm sure you do, haha). Also the Herbert Marcuse was rather blatantly part of USG funded project to transform the Marxist tradition into something which could be integrated into the existing order (recouperation), e.g. various forms of liberalism (both literally and in the US vernacular sense). Your post reaks of agitprop, as usual.

49 2021-11-20 18:25

>>47
Actually rereading you're not too far off. The goal isn't equity, but compensation for the tendency of the rate of profit to fall. The "Great Reset" where you'll "own nothing and like it." is not a conspiracy of the disciples of Marcuse, but of the richest and most powerful people on the planet. The idea is not to centralize control, but to commodify (excellent for rich gamblers with a fix in the system) through artificial scarcity as much as possible. The state would merely exist as an enforcement mechanism for the market, being stripped of most its relevant regulatory capacity. Reducing what is considered subsistence (e.g. I can no longer eat meat, have to always be on call for work, am expected to close and open the store, am denied a collective bargaining etc.) is a means to increase surplus value extraction from workers, while reconciling the artificial scarcity. Then again I suppose it wouldn't be good agitprop if their weren't a grain of truth in it. This peculiar sort of mirroring of legitimate concern in clearly false statements has been a common play since jet trials were claimed to be aliens. You'd think the rule book would have changed since, but I guess not.

50 2021-11-20 21:40 *

>>48,49
I believe in classical liberalism where freedom is inalienable and supercedes the state. This is opposed to communism where they believe that rights come from the state and are granted as privileges. What I'm doing is connecting what Marcuse teaches together with what's happening today. All the activity that's working to promote sustainability are happening to the detriment of economic progress. Notice that the enviromentalists never support nuclear power because plentiful power supports strong economic progress. The ideal is to slow down the economy into a circular economy. The consequence is to make everything more expensive which leads to more people becoming more dissatisfied with the idea of capitalism. The richest and most powerful people of the planet are conforming into Marcuse's world whether they know it or not. The language I hear from them matches the sentiment that Marcuse teaches about society, they might know and support Marcuse or they might not know this but this is what's happening.

I hate all of this. I want a life of freedom where people can choose to live as cogs in the economic machine. Within today's freedom, people can also choose to live as subsistence farmers and gatherers all they want, there's no need to force a free society to live minimal subsistence lives. The communists don't like that there are inequalities that happen when there is freedom. What they want is conformity for all, except for the communist leaders who happen to have the superior intellect and therefore they should have control of society and the resources.

51 2021-11-20 22:45

>>50
Historically communist states had a "right to employment", and did not care about the environment. Communism isn't a welfare state with environmental protection, it's a working man's state. Their focus was on industrialization, and preventing surplus value extraction by an elite (although failing to a degree). Surplus value extraction beyond necessary to sustain the means of production is an inefficiency, it means taking capital that could be spent on improving industry and spending it on the "leisure class". Your communism and Marxism in practice (or in theory for that matter) are so remarkably different that it's hard for me to imagine that Marcuse inc. would have been able to convince anyone of this.

Marxist theory states that capitalism will drive wages to sustenance levels, and that this will cause revolution. This is done because of the tendency of profits to fall, an inherent property of the capitalist mode of production... Perhaps your intention is not only agitprop but a targeted attack to reduce faith in the common man, and to distract in the short term. Probably the best algo is to ignore you as I was doing before.

52


VIP:

do not edit these