Java is one of the most energy-efficient languages

Tuesday, 03 October 2017

Energy efficiency isn’t just a hardware problem. Your programming language choices can have serious effects on the efficiency of your energy consumption. We dive deep into what makes a programming language energy efficient.

For years, we’ve conflated performance with processing time. “How well does it do?” meant “how fast is it?” But these days, things have changed. Developers, engineers, and even consumers will do a lot to avoid a heavy drain on the CPU in order to preserve their batteries. Energy efficiency started on the hardware side, but now it’s trickled down into software development.

There are a lot of questions that arise when you try to measure the efficiency of a programming language. For one, what sort of metric are you using? Is a faster program language a more energy efficient one? Is a faster programming language a greener one?

However, comparing languages is difficult. The performance of a language can be easily improved just by the quality of its compiler or virtual machine. Improved source code is as crucial as optimized libraries.

A team of Portuguese researchers studied 27 of the most popular programming languages to see if there was any relationship between speed and efficiency.

What Pereira et. al. found wasn’t entirely surprising: speed does not always equate energy efficiency. Compiled languages like C, C++, Rust, and Ada ranked as some of the most energy efficient languages out there.Using the Computer Benchmarks Game, the team of researchers tested these languages by compiling/executing such programs using the state-of-the-art compilers, virtual machines, interpreters, and libraries. They then analyzed the performance of the different implementation considering three variables: execution time, memory consumption and energy consumption.

However, Java is one of the fastest and most energy-efficient object-oriented language. Interpreted languages like Perl, Python, and Ruby were among the least energy efficient. As the researchers discovered, the CPU-based energy consumption always represents the majority of the energy consumed.

On average, if sorted by their programming paradigm, the imperative languages needed the least amount of memory, followed by the object-oriented, the functional, and finally the scripting languages.

Go and Pascal do rather poorly in the straight efficiency test, but they do better if you’re considering languages based on time and memory or energy and memory.  For those interested in improved energy and memory, Rust and FORTRAN are also decent options.So, is it possible to choose a programming language based on energy, time, and memory usage? Well, yes. C is the clear winner across all the fields. But if you’re not interested in coding in C, there are some interesting options.

Test how efficient your code really is

The researchers have an awesome thing up over at GitHub where they’ll evaluate your code to see how energy efficient it is. It’s only three simple steps.

  1. Create a folder with the name of you benchmark, such as test-benchmark, inside the language you implemented it.
  2. Follow the instructions presented in the Operations section, and fill the Makefile.
  3. Use the compile_all.pyscript to compile, run, and/or measure what you want! Or run it yourself using the make command.

This article was originally posted on Jaxenter.

Latest jobs

Senior Java Developer

Hamburg, Germany | €50,000 - €80,000 pa

My client is a company based in Hamburg and they are currently seeking a Senior Java Developer.


Client Technical Support

Munich, Germany | €45,000 - €60,000 pa

My client is a company based in Munich and they are currently seeking a Client Technical Support

See all jobs Submit your CV

Register for an account

Create an account today to start applying for jobs and receive email alerts on your job criteria.

Register Today

J-People is a trademark of VMR Consultants | Registered Number: 4234001. VAT Number: 774 4848 82

Website design and built by: Revive.Digital