August 10, 2006

I Want Java to be More Like PHP

Is PHP ugly? Often. Is PHP well designed? In some respects yes and in some respects no. What is arguably the best feature of PHP? It's just so easy to get started. Just edit a file and reload your web-browser. No compiling. No deploying. No restarting Apache because the file changed and Apache has a cached version of the wrong thing. Just edit and hit reload.

So what's the state-of-the-art with Java web applications? Running them as an entirely separate process in a wanna-be-a-full-scale-webserver-but-I'm-just-a-servlet-container tomcat instance (or JBoss or Websphere or whatever.) You want to start using the Java language to create dynamic websites? It's so simple! All you have to do is download an entirely unfamiliar program (tomcat), edit a "user-friendly" XML format, start the tomcat daemon, learn the servlets' API, edit a Java source file, build it with an unfamiliar "make" tool that supports ".war" files, and tell tomcat that you want to deploy the file so that it can reload it's internally cached version. Yup, just 7 easy steps with hours of reading and learning just for "Hello World." And strangely enough, this user experience is brought to us by the same people who brought us the simplicity of the Apache web server.

Gosh, why even bother with Java at all? Well, the Java community might point you to excellent performance and process isolation (which is true), but you'll probably get at least one answer involving babel like "enterprise integration of application stack technologies to support high-performance web frameworks." But good luck with the simple question, "Why do I have to perform 7 complicated steps just to write and execute 'hello world'?" You'll probably just get a blank stare. What, you don't get a warm feeling in your bosom every time you learn an API? You must not be a real Java hacker!

In response to this insanity, there's mod_gcj. That's right, an Apache module that lets you run Java just like you would a PHP script, or a Python script, or a Perl script, etc. No more "It's cool to have my web server take 3 seconds to respond because my CGI has to launch a JVM with every hit!" No more "we use servlets because that's what good Java programmers do." Simply write Java code, compile it, reload your web page. No really, just that. You might even be able to get up and running faster than you can say, "But Sun didn't tell us to do it this way!"

It will be fun to see where all of this goes. One strange back-alley of mod_gcj is Rhinola. Have you ever wanted to use JavaScript on the server-side to develop web-based applications? That's right, server-side JavaScript! What a strange idea, but at least it's way easier to deploy than Java...ahem...than Java used to be. (Thanks mod_gcj!)

(Note: I'll keep you all updated as I play with mod_gcj some more.)

Posted by enigma at August 10, 2006 01:50 PM
Comments

You know what, I've always wanted to be a code/programer guy. Alas, I am not. But I have a lot of friends who do the JAVA thing and the stuff that they complaine about is all the stuff that you've listed here.

Posted by: Trinity at August 14, 2006 11:02 AM

Nate and I were talking about this very thing the other night. Java has been the promised golden child of programming for so long, however unfortunately it's just a beast. It takes way too long for the "app" to start up, it's hugely memory intensive; it just FEELS heavy.

Nate's points were more along the lines of what you have to do to be able to just USE it. That's the beauty of PHP and Ruby and perl. You can sit down and bang out a few lines and test it and change something and test it, etc. There's more of the instant gratification with perl, ruby and php. There's also not a lot of 'builtins'....languages like perl seem to have a fairly robust native library (regular expressions, hello?)...wheras in Java you have to know to import the right class and build the statements and execute them....wheras in php and perl (and I would assume ruby), it's just another function call.

OO is good for code reuse but I think java has over re-factored itself.

Posted by: Dave at August 18, 2006 05:42 PM
Post a comment









Remember personal info?




Type in the security code: