Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Complied Languages rather than Interpreted Languages #132

Open
aoifefitton opened this issue Oct 24, 2022 · 4 comments · Fixed by #152
Open

Using Complied Languages rather than Interpreted Languages #132

aoifefitton opened this issue Oct 24, 2022 · 4 comments · Fixed by #152
Assignees
Labels
proposed pattern An idea for a new pattern to submit

Comments

@aoifefitton
Copy link

Describe the pattern you'd like to propose
Compiled languages “tend to be” the most energy-efficient - see paper linked in reference section.

Actions:
- Use a language as close to the machine as possible, example: c, cpp rather than python.
- Revise scripts/programs to replace e.g. python with e.g. cpp.

Describe specific emission impact from this pattern
Regarding SCI = ((E *I) * M) per R, E will decline with use of the likes of C/Cpp rather than Python.

More stats:
https://devblogs.microsoft.com/sustainable-software/language-impact-on-ui-apps/

References to this pattern
Compiled languages “tend to be” the most energy-efficient:
See table 3: https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf?utm_source=thenewstack&utm_medium=website&utm_campaign=platform

https://thenewstack.io/which-programming-languages-use-the-least-electricity/

Additional context
C is low level in the sense that it enables direct manipulation of the computer hardware (at least as direct as the OS will allow). The most common implementations of Python, Java, etc. are at least one step further removed from the hardware because they run in a VM. If you want to manipulate the hardware from Python you'll have write an extension to the Python VM, usually in C or C++. There's no virtual machine interpreting C executable code. It's compiled into machine instructions, specific to a particular CPU, that are linked together and run on your hardware

@aoifefitton aoifefitton added the proposed pattern An idea for a new pattern to submit label Oct 24, 2022
@markus-gsf-seidl
Copy link
Contributor

I'll convert this, but I'm torn. This topic is very complex and I think we should touch it very carefully. Maybe the best option is to have a project that does actively benchmark this. The greenlab link seems to provide a GSF compatible source, but the last work done is from many years ago.

@dubrie Is there a category for this? I would throw it into cloud, but maybe there could be a more general category

@dubrie
Copy link
Contributor

dubrie commented Oct 30, 2022

@markus-ntt-seidl I think cloud is OK as a category for now (can re-sort as more patterns get filed) but we do have a tag for programming-language already so let's make sure that tag is in there.

@s-geiger-si
Copy link

We would love shift the focus of the pattern towards what is the most energy efficient solution for a given problem.

Most developers would not write a REST API in a low-level language like C (although maybe it could be done). On the other hand, if we look at Python, Javascript (Node) and Java, then all three languages are perfectly suitable for a RESTful microservices. but according to the links below they have a hugely different energy consumption, so the choice then should lean to Java over python (as an example).

We suggest to extend the considerations section with the following items:

@markus-gsf-seidl
Copy link
Contributor

Maybe we step this down a notch or two and suggest that the implementers should consider performance optimising hot-spots of their code in different directions, instead of advising them to choose this or that.

Try to use:

  • More efficient algorithms (self-implementation or via libraries); keep up with current papers or other implemenations
  • Reduction of use-cases (do not calculate something that has a minor business impact and a high compute impact; can't remember if there is already a pattern for this)
  • Consider also programming language impact when implementing algorithms (which you the team has to choose yourself based on your knowledge/time/other constraints) without us giving a "list of greenest programming languages".

Personally I still think this whole pattern will be a can-of-worms: Comparisons are very academic, good algorithms are faster even in slower languages and programming paradigms are very important (to a limit given by each domain). There are so many real world things to consider to master performance and green software (are these even synonyms?)
I remember Twitter moving to Async IO Java, since it was more efficient than doing this DIY in C. RESTful APIs can be written in C, but it may not be realistic to do so.

russelltrow added a commit that referenced this issue Jul 30, 2024
…d-languages

Using Complied Languages rather than Interpreted Languages #132
@LiyaMath LiyaMath self-assigned this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposed pattern An idea for a new pattern to submit
Projects
Status: No status
6 participants