PHP vs. Java … and why I hate Java

Java is a widely-spread programming language. It’s used for many client-based software applications (for example most of the games you’re downloading for your mobile phone) as well as web applications. Everywhere you go you find people using Java. Hardcore developers love it because the structure of the language works pretty much like their brains. But getting a larger website live using Java takes ages. Whenever you change the code you must re-compile and deploy. I think there are much better ways to run websites than this.

PHP is a programming language used primarily for websites. It’s relatively easy to learn and you can get by using dirty code, at least in the beginning. The best thing about PHP is that it is a script language. You don’t need to compile the source code which can take a long time if you’re using Java. The PHP interpreter does that for you on the fly when a script is executed. You can change the website instantly and seamlessly so that deployment isn’t really a big issue.

The beauty of Java is that it’s fast because upon execution it’s code has been translated into machine language already. PHP tends to be slower here because it has to translate the code in real time. However, I don’t think using Java instead is a good trade-off. If traffic volume and execution time of PHP-based applications become an issue I just use more servers. Nowadays it’s a lot cheaper to spend money on infrastructure than on switching a platform to Java. You can also speed up PHP big time by using Memcache.

Some of the largest social media properties on the internet have been using PHP from the very beginning: Facebook, Wikipedia, Digg. So you see, it’s possible to scale PHP-based services. You just need to do it right. My point is, if for example Facebook had been written in Java, hardly any of these optional applications would exist and its viral growth wouldn’t have happened.

To validate my point, here’s a picture I took in my room at the Novotel London Excel where I stayed for a4uexpo. I hate the fact that even the entertainment systems of hotels run on Java and do not work:

television set showing error 404