Last weekend I decided to try a bit of PHP programming. I wanted to see what the language was like, whether it was any easier to create pages, etc. I'm a little experienced with JSP programming, and in the long distant past I once wrote my own page template engine around TCL because at the time there was nothing else available.
To compare PHP versus J2EE is utter nonsense, because they serve completely different purposes. J2EE is very rich in capabilities, ones that appeal to large enterprises or very busy web sites. These are capabilities the PHP programmer can only dream of, because PHP doesn't provide anything like it.
It seems fair to keep the comparison to the closest analog to PHP, namely JSP.
Another note is that obviously I have a Java bias, given that my job involves working on Java.
With that out of the way ... what do I think?
Learning curve
Well, PHP is pretty easy to learn. I simply stumbled my way over to php.net, found the online manual, and read a few things, and said "hey! that's easy" and started coding. Within a few hours I had a website whose pages are dynamically built from a database. I'd previously written some JSP pages to use that same data, displaying it in the same format, so this is a fair comparison.
The JSP pages I'd written also went very quickly. Except, by the time I wrote the JSP pages I'd already gone through the steepish learning curve to learn JSP and JSTL programming.
Here's the rub with JSP, that somehow JSP programming is somewhat difficult to pick up. I think it stems from a couple places: a) the servlet/JSP specifications are written in a difficult legalistic style, and b) there's baggage from the early servlet history.
If one were to stick purely with JSP and JSTL then programming JSP's is pretty simple. Even writing new JSP tags is very simple, if you use the new XML-tag file format. But unfortunately the books that teach JSP and JSTL have to talk you around all the old baggage.
In comparison I found the PHP model and documentation to be very clear and easy to understand. Like I said, after a couple hours I had some pages going, having never done anything with PHP other than glance at a few source files. That's a pretty easy learning curve so far as I can see.
Capabilities
I find great fault with PHP in its capabilities.
First PHP ignores the MVC model. The "business logic" is hopelessly intertwined with the presentation. In the pages I've been writing, the core of the presentation is embedded in strings in echo statements. This in turn makes it very difficult for a WYSIWYG style web editor to do much to help you lay out your pages.
By ignoring the MVC model, this relegates PHP programmers to indirectly coding the page layout, rather than designing the layout through direct manipulation in a WYSIWYG editor. By comparison, JSP (if you use the modern JSTL or STRUTS approaches) can show quite a lot through a WYSIWYG editor, and dynamic pages can be designed through direct manipulation rather than indirect coding.
Second, PHP as a language isn't very scalable. Since JSP resides atop Java, you have a tremendous, modern, object oriented programming language with tons of software modules ready to be tapped upon. PHP doesn't have this backdrop, hence this world needs to be reinvented for PHP in order for a PHP programmer to use it. Also object oriented programming is a new feature to PHP, which I've not studied yet, but I expect since it's a new feature layered on top of a non-OO language that it's likely going to be clumsy.
Market realities
On the other hand, it's clear that PHP is very popular with some. For example I've spent a lot of time looking at hosting providers. I know it's trivial to find a hosting provider that offers PHP service, and that it's very difficult to find one offering JSP service.
That distinction has given me a lot to ponder. The conclusion I've reached is that the hosting providers have razor thin margins and need to keep costs pared to the bone. This means open source solutions are great for them, because the cost is minimal. Now, the Linux+Apache+MySQL+PHP (LAMP) is very easy to install and relies completely on open source software packages. Comparatively Linux+Apache+MySQL+Tomcat+Java is pretty darned difficult to install, if only because the mod_jk (or is it mod_jk2) installation is a mess. The installation process is very poorly documented, and it is being completely unclear whether one is supposed to use mod_jk or mod_jk2.
Putting myself in the hosting providers shoes, it looks like Java/JSP is too difficult and possibly with a low payback. Even if one were to use a different appserver than Tomcat it's almost certainly going to involve money, which the hosting provider can't afford (razor thin margins).
So in summary I think JSP is capable of a lot more than PHP, but hampered by a steepish learning curve and a difficult installation process. (2005-03-08 11:05:34.0) Permalink Comments [7]


Posted by 80.179.73.38 on March 08, 2005 at 02:02 PM PST #
Posted by 129.174.172.26 on March 08, 2005 at 04:03 PM PST #
Posted by Steve Kurzeja on March 08, 2005 at 05:04 PM PST #
Posted by Doug Bromley on September 22, 2005 at 04:04 PM PDT #
Posted by Steve on January 11, 2006 at 01:32 PM PST #
Posted by David Herron on January 11, 2006 at 01:46 PM PST #
Posted by Steve on January 11, 2006 at 02:03 PM PST #