You’ll probably notice an emerging theme over the next few weeks of comparing PHP to Java. Please understand, that I know very little PHP. I am a Java Architect and Developer. But that said, there are a lot of problems in the Java industry right now, and I’m finding it very interesting to compare it to PHP. Perhaps, at the very least the Java community can learn some valuable lessons from PHP.

The Server Side has an article about comparing CMS/Portals in Java and PHP. They found what I have found in comparing many other apps, and that is that PHP generally offers more choices and more functionality. You can read more here.

One of the replies to the article was by Dave C, and I just have to put the text of his comment here. Its has some truth in it. Java can of course, be as simple as he is describing PHP, but as he says, “Java programmers tend to overengineer everything”. I have a gut feeling that he is right, and that in the past, I may well have done that myself.

Here are the rest of Dave C’s comments:

It’s just a royal pain compared to PHP (or equiv). Part of it is because of the dynamic/scripting nature of PHP, but a big part of it is that Java programmers tend to overengineer everything. Consider showing a list of content entry titles. In Java, you’d probably set up some DataContainers/JavaBeans, a big layer of abstraction to access the database, and a bunch of session beans to keep everything nice and separated. In PHP, you’d just (forgiving some syntax errors):

while ($row = $db->sql_fetchrow($db->sql_query("select id,title from content order by id desc")))
$id = $row['id'];
$title = $row['title'];
// Output them as HTML/links whatever
if ($count == 10) { break; }

the PHP solutions won’t result in the cleanest most maintainable code (phpNuke is a f**king mess), but it’s really easy to implement, doesn’t result in poorly performing code, and can allow you to implement lots of features quickly. Meanwhile, the Java guys are deciding how to implement the Abstract Factory pattern and writing XML configurations for PicoContainer….

I have a lot more thoughts on the future of Java and web development and over engineering, and I’ll probably use this blog to help walk through those thoughts, and possibly even come to some very new conclusions for myself.