Over on The Server Side I spotted this thread on Java losing ground to LAMP and .NET. Being a Java bigot I dismissed it out of hand, but then I got to thinking…
It’s clear that for pure web development, PHP is much better than Java. No matter how much I’d like to believe it, JSP still sucks. My personal complaint about PHP has always been not with the language itself(although there are some oddities), but about the way people use it to build applications. Being a scripting language, it tends to breed a lot of two tiered applications with the PHP presentation layer talking directly to a DB. This is poor because once you embed database logic into the presentation layer, it becomes very difficult to extricate it and build a nice scalable multi-tiered solution. I have always advocated against building large complex systems with PHP for this reason. Java does a much better job of architecting for multi-tiered solutions. They have solutions like the full J2EE specification to show that they have at least thought a lot about separating presentation, business and database layers. Not that I love J2EE, but at least it shows they have thought about building n-tiered applications, which is more than I can say for PHP.
I think what has made me rethink this is the rise of Web Services, SOAP and XML-RPC. Java is a great solution when you have a pure Java environment and you want to build the most scalable solution. The reality is that no large system is built as a pure Java solution. Every company I’ve ever been at wants to grow their business by opening at least a little bit of their sytems up so strategic partners, affiliates, and customers can exchange the information they need.
Nowadays when I build a system I think of what parts I would want to open up to other developers, and I ask myself how would they want access to it? I cannot assume they are going to want to program in Java. I’m a huge Java advocate and even I don’t want to do everything in Java. So I want to expose an interface using the the best supported cross platform technology which is probably Web Services. If I’m exposing a Web Services interface to other developers it needs to be solid and tested. A great way to ensure that the Web Services layer works well is to use that API for my own presentation layer. This means that the presentation and application layers are decoupled and therefore I can use the best tools for the job on both sides. And the best tool for the presentation layer is PHP and the best choice for the application layer is up to the developer. Personally I’d do some application layer stuff in Java, some in Python or Perl depending on the complexity.
This post is already too long with too many what ifs and whys but hopefully you get it.