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:

Your article is more on interpreted vs compiled languages. In fact, java is not compiled to machine code but into bytecode to be interpreted by the jvm. And I don’t think it takes a long time to compile java code, but I admit that it is longer than not having to compile at all. However, you don’t have to compile your Jsp pages. Pages and classes can also be hot redeployed individually on the fly, hence you “can change the website instantly and seamlessly so that deployment isn’t really a big issue.”
I think one of the main advantage of php over java is how easy it is to get an operational lamp stack so you can start working.
And finally I don’t think that showing as 404 status error page proves anything about php beign better than java. This is a developer issue, all sites can have broken links.
If you need an enterprise-level, high-performance web application, then choose Java. The fact that PHP is “easy to learn” is not relevant. The concept of implementing “dirty code” with PHP or any language is flat-out scary. For large projects, you’d better have expert developers no matter what the programming language. Also, the previous comments from SVachon are 100% accurate.
$recommendation => $java;
I agree with the two comments above. When looking at enterprize applications, there are other issues which crop up. Like what happens when a low level programmer gets hold of your code. Or when the business needs to develop a complex feature. What about adding the ability to expose functionality as web services in a robust manner, without affecting application availability. Or having accurate debugging and performance statictics.
Having “dirty code” code in your any application is like having cooking oil in your Ferrari engine. And sticking one’s head in the sand with regards to enterprize issues is just shoddy.
Anybody who has worked at the enterprize level should know this. There is nothing wrong with PHP or JAVA. They were built for different reasons.
Apples and Pears my friend.
I have read most of these comments and still not sure to start learning more java or get to know php coding at an expert level. Am actually a masters student. We have been taught JAVA and is very boring when it comes to write codes. After Masters, my intentions to pursue a carrier in programming. Right now, I have to start my final project of web application for a shop and have only 3 months to complete it. Should I continue doing JAVA as I have learned it some how in the past 6 months, or work on PHP for it if it’s more demanding at a professional level.
cheers
I like that java is strongly typed, that way debugging is easier, and always you know what is really happening, without too much hassle.
@Shah,
use PHP. Java is for very big projects with its advantages of good refactoring. Given the time, you must go ahead with php and use Kohana framework (MVC architecture) for good understanding and practices. This gives you a good understanding of OOP and atleast one Design pattern.
At a later stage, learn Design patterns in java (particularly adapter pattern), JSF, JPA and you are to market.
Looking even further, start learning a function/OO hybrid language like Scala which will replace java eventually. (2 years time)
Cheers,
kappa
good article on java based php framework http://www.ibm.com/developerworks/opensource/library/wa-quercus/index.html
“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.”
Too right.
I have heard too many times people give the “php is not scalable to enterprise levels”, “java does enterprise well”. I dont think that I can speak to this first hand.
What I can say is, that I touched both languages and ultimately chose php for its quicker ramp up, ease of use, ease of reading, no headaches for overhead. Java functions, in the past, were hard for me to lookup, understand. Say I wanted a simple existing function that searches a string for a sub-string. It took me ages to find with java, and the code was ugly to read once implemented. Php I found the function in under a minute of searching its docs, and the code was very understandable.
I was coding very small programs for myself and my work basically, NOT enterprise or professional level. So, I always trusted what others said: PHP doesnt scale. Well, now that I have seen a .php stuck into one of the pictures at facebook…. facebook is the ULTIMATE of scaling. I mean, really you cannot scale to more users than that. There really is nothing currently higher in users that I can think of.
I think that PHP can be easy to use/learn, and dangerous to scale. But, if done right apparently, it can shoot you to the moon.
I am going to learn Python I think. It is a mix between java and php qualities. Python is more heavily object oriented and strict and enherently scalable, yet it too is script-based… it compiles as you run it. No need for go-live or compilation headaches.
My Comment is different, i am waiting for a time where database manages this better then language. once the database performance gets increased most of the programming language can do better jobs.
Its on database we have to give more concentration. Languages are only mediators.
Java and PHP. two are not good.
Why should we want to stick will an intermediate language like this better we can go for C++ or c compiled language .
Will can give high performance.
So my conclusion is,
1. Database is the main part need a good optimisation in performance.
2. Me frameworks have to be developed in c++ or c so that other can do web projects in these language. perfectly.
3. Both Database and language should have a good garbage Collection Methodology.
4. Good IDE for developement. with lots of auto generate facilities.
etc..
I am waiting for such a high performance.
Hi,
I am M.C.A fresher student. I had started to teach java but i don’t know market position.Someone says php is better than java for job purpose. Please tell me ..
Most of the java programmer use to say that “enterprise-level, enterprise-level”. Actually they don’t understand what is enterprise-level.
Hi,
Well, it is difficult to give a general answer to the question: “java, or php?”.
I am a java programmer. I know also asp.net very well, various versions, worked with .net 1.1, 2.0 and 3.*
For personal stuff, Java hosting is expensive, .net hosting is either too expensive or too unreliable. Also if you have 20 websites and 19 are with wordpress (php), developing the site number 20 in Java will make the deployment environment very difficult to configure and maintain.
So for personal purpose I work with php
I see the following pros:
- Cheap infrastructure
- Reliable solution (at a Java solution peeking daily at the logs to see potential errors is a must,while at php this is not the case).
- Documentation available everywhere
- Free
However you cannot overlook the cons:
- Weak typing – much more difficult to write the php code than the Java one. Modern editors – like Eclipse PDT I am currently using only partially provide intellisense.
- Arguable namespace implementation – personally I don’t use namespaces because of that
- C based plugins – you never know what is in store for you, maybe the next version of that fancy php plugin you use will not work, or maybe the windows version will work fine and the unix one will not. On the contrary, Java is full stack – all you need can be embedded as a library in your app, and you know for sure it will work on any valid application server
- Relatively slow language (real time interpreted)
So again, it is a mixed world out there – php is not the best technology available, however it is there and at least personally I have to use it (I wrote some personal stuff in .net and Java and had to rewrite it in php). Java is much better but you cannot use it in 100% of the solutions.
Personally, for personal projects I am stuck php. Not that I like it – actually I don’t, but here I am working php apps
selten so einen blödsinn gelesen
@Dwoos “PHP is easy but it’s hard to perfect and impossible to master”
If PHP is not relevant tell that to facebook with 800 Million Users, Google and Yahoo… who use PHP and wordpress that use in this site. Its easy to make things hard and hard to make it easy. Only people make hard to theme selves like java do.
I recommended both PHP and Java but more favor on PHP