Is the Java vs PHP argument necessary?

; Date: Mon Aug 28 2006

Tags: OpenJDK

This old blog entry, (web.archive.org) Java vs. PHP?, is from last fall and talks about Marc Andreeson making a dire prediction of imminent death for Java because PHP was going to roast it alive. His claim is based on the vast quantity of PHP applications available (in the open source world?) and the scarcity of Java web applications (?in the open source?).

Clearly there are many more PHP web applications than Java, at least in the open source world. However the story is probably very different for "enterprise" web sites where huge scalability (the ability to incorporate large systems, huge databases, etc) is important. Yeah, PHP can handle that level of system too, but the Java EE system was designed for this. Further when you get to large applications you really want a real object oriented system, not a language where object orientation is a bolted on afterthought.

But do the PHP and Java camps need to live in different worlds? What if the PHP and Java camps could collaborate? Just as JRuby or Jython or Jacl allows one to mix Ruby/Python/TCL code with calls to Java objects, why can't PHP programmers enjoy the same flexibility?

The core business logic could be implemented in Java on the Java EE system, while the presentation layer could be written in PHP ... why not shoot for the best of both worlds?

Java, in JDK 6, is growing the ability to natively support other programming languages. There have been projects for years to support other languages on top of the Java runtime. What's different in JDK 6 is this support is upgraded to a feature of the core platform.

At (scripting.dev.java.net) scripting.dev.java.net/ there is information about many programming languages coming to the Java platform using this mechanism. Sure enough there are a couple entries for PHP support.

These two are:

Caucho's Quercus: ( (web.archive.org) www.caucho.com/resin-3.0/quercus/) - pure Java implementation of PHP.

The PHP-Java Bridge ( (web.archive.org) php-java-bridge.sourceforge.net/) - uses the native PHP implementation through remoting.

I've looked at Quercus before in (web.archive.org) Quick test of Resin's PHP support -- using Drupal where I took an instance of the Drupal content management system, and ran it on my Mac using Caucho's Resin server. It took very little effort to get running, the biggest trouble was to work out how to make a JNDI reference to my database. I later looked under the covers and found it had converted the PHP code to Java classes, then compiled those to .class files. Maybe if it had been running on a JDK 6 system (my Mac only has JDK 5) it would have used a different method.

Hmm... that kind of interchange sounds very attractive.

Unfortunately both of the solutions above are limited in scope. First the PHP-Java bridge is rather difficult to install, which to me limits its attraction. Second the Quercus tool is only available in the Resin server.

Source: (web.archive.org) weblogs.java.net

About the Author(s)

(davidherron.com) David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.