RoboGeek

RoboGeek's (David Herron) Weblog: co-developer of Robot and several other things related to Java testing.


« Previous day (Mar 8, 2005) | Main | Next day (Mar 10, 2005) »
20050309 Wednesday March 09, 2005

Re: PHP versus JSP/etc [UPDATE: I think I want to make clear, that with what I'm writing here, that this is purely my opinion.  I can't pretend to be making any claim/statement about Sun's position in regards to PHP.  So, any of y'all who might think what I'm saying means that Sun hates PHP, please don't use this as any "evidence" of such a slant.  Heck, I don't even hate PHP, I am just witnessing and writing about some flaws.]


Apparently I struck a chord yesterday with my posting about PHP.  I thank the nice and friendly commenters for setting me straight on a couple points.  I have a couple clarifications to make, and I still think JSP is superior in some ways and I want to discuss that.

First about my comment on MVC, or how PHP encoourages the intermingling of layout with application code.  Obviously earlier versions of JSP also had the same problem, which is why STRUTS and JSTL came along.  In the current JSTL and JSP specifications you can define new tags purely through writing some HTML code, which even further separates the layout from application code.

In any case, the commenters mentioned MVC modules being available for PHP.  In particular they mentioned Smarty.  Judging from the documentation Smarty looks to be interesting, though I don't quite get why there's such a fervor about it.  I found myself impressed with its features, but turned off by two things.  First is that the Smary markup is not in any kind of HTML or XML format, which means that you're unlikely to ever see a WYSIWYG editor for Smarty markup.  I suspect that designers, for whom Smarty is targeted, will prefer a WYSIWYG approach rather than the write-some-code-and-preview-it-in-a-browser you'd have to use with Smarty.  But I think that's a workstyle issue, as some designers prefer to work in straight HTML, rather than a WYSIWYG editor like GoLive or Dreamweaver, and would be quite at home with what I see in Smarty.

Speaking for myself, when I write a web page I prefer a WYSIWYG approach even though I'm comfortable with writing HTML code.  I also like the current iteration of GoLive where you can interactively design CSS styling and immediately see the results in the editor.

The second thing which turned me off about Smarty is its use.  It seems a little strange to make the PHP page have a magical incantation to require the Smarty code, instantiate a Smarty object, load up some data, and set that data into Smarty, all before you can invoke the template.  I'm sorry, but to me that looks backwards.  I'd rather have it just be "Smarty" code (or whatever template system you're using), and have the the infrastructure take care of the details. of interpreting its way through the template file.

The other comment was about availability of extra programming libraries.  I must not have been clear enough in what I said, because the comments missed the mark.

What I meant to say is:

  1. Java, upon which JSP is implemented, is an existing language with a wide variety of programming libraries available.
  2. Those libraries can be used for any application, not just server side.
  3. Those libraries are very available to be used in JSP applications.
PHP is a relatively new language.  While quite a few PHP modules have been written and the pear.php.net site does a great job of collecting them into one place, if PHP had been implemented on top of Java then those libraries would not have needed to be written.  That's my point, is that JSP gets immediate use of all the existing Java libraries, whereas if equivalent functionality is needed for PHP it has to be written anew.

Okay, but I see that PHP dates back to 1995.  JSP hadn't been invented yet in 1995.  I remember 1995, and was writing server side scripts by 1997 (or so) myself.  At that time I wasn't happy with the state of server side scripting languages (my hosting provider supported Perl, yuck) and wrote my own template engine built atop TCL.  Again, I appreciated the capability to reuse an existing language and theoretically be able to tap upon an existing base of libraries.  The application I built with my self-written templating engine is still running today at The Reiki Page Practitioner Directory.


(2005-03-09 16:18:08.0) Permalink Comments [2]