Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP vs. Java are there energy consumption differences?

Tags:

java

php

energy

I heard a rumor, that Java consumes less energy than PHP and was wondering if and how this would be true. I'm currently working in a company where we base most of our apps on PHP. Power consumption has never been the problem for us, but we are working on bigger projects where it might matter. We love PHP for web developing and are wondering how such a rumor can spread and if it is true at all.

The example I heard was that Facebook is switching for exactly that reason to Java (I can't seem to find any of this stuff on google though).

Since a customer of mine is asking me this question I would love proof if it is true.

like image 567
Thomaschaaf Avatar asked Aug 23 '09 15:08

Thomaschaaf


People also ask

Which is the most energy efficient language?

Compiled languages like C, C++, Rust, and Ada ranked as some of the most energy efficient languages out there. 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.


1 Answers

Computers don't particularly care if they're executing Java or PHP. Power consumption is pretty much the same. The question then becomes a question of performance - if you can serve more requests with one server you'll need less servers and consume less power. Or alternatively, if you're not doing web scale applications, serve your requests quicker and spend more time idling, which consumes less power.

Given pure Java and pure PHP, Java as a statically typed JIT'ed language is of course faster. The question is rather which one can you make faster given the team members and development effort available to you.

My take is that the best way is to mix languages, use existing Java based infrastructural tools, such as Terracotta to build the performance critical parts and something more nimble to build complex but not that heavy business and presentation logic.

like image 96
Ants Aasma Avatar answered Oct 06 '22 02:10

Ants Aasma