Which is faster? Java or PHP

I’ve written web sites in both PHP (around 50 sites) and Java (around 20 sites) for the last 7 years and I don’t think there’s much difference in terms of speed. It’s not true that one is faster than the other for heavy database use or that one will withstand a lot of site hits. If you write your app correctly and optimize for speed using strategies appropriate to that language then there’s very little difference.

I’ve found my Java apps easier to maintain (because you have to do OOP with Java) whereas the PHP apps tend to gradually disintegrate into a big ball of mud (too easy to hack loads of dodgy code together)

I’ve found Java much harder to run on shared servers (here in the UK most hosting companies will refuse to set up Tomcat because they don’t know how to do it) and I’ve also found that Java apps eat more memory than equivalent PHP apps. For most of my Java sites, I’ve ended up setting up the server myself whereas with all the PHP apps I’ve used off the shelf hosting.

Java is much easier to code because IDEs like Intellij, NetBeans or Eclipse are around 10 times easier than trying to use Dreamweaver or PHP Eclipse. I find that I can write Java a little quicker than PHP but there’s very little difference and anyway, you don’t have to write
as many lines of code in PHP.

I think that it depends on your preferences, your experience, your client’s preferences and budget.

Unless the site is a really small one, I prefer using Java. I’d definitely use Java if there are complex server side things to do (like bulk image processing or running Flash XML servers)