RoboGeek

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


« PHP versus Java/JSP/... | Main | Test tools across... »
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]

Trackback URL: http://blogs.sun.com/robogeek/entry/re_php_versus_jsp_etc
Comments:

> I thank the nice and friendly commenters for setting me straight on a couple points. I think you are just FUDing with this post. What is the point you are trying to say? You only know a tiny portion of PHP. It's similar like a PHP expert who starts using JSP for a week and start listing down the things he/she doesn't like and are believed to be wrong. If you don't know much, you are just spreading FUD. Stop please.

Posted by Jason Barker on March 09, 2005 at 06:26 PM PST #

Jason, you're suggesting that new users should not write up their experiances. Is that what you really want? Does the mere fact that David works for Sun invalidate him from expressing his personal experiances?

Anyway, I pretty much agree with everything David says, and I have many years experiance with PHP (starting with PHP 3). Fairly recently I evaluated Smarty, including converting a partially-complete project to use it, but I had to abandon it because it has some real limitations which I couldn't work around. Smarty is "yet another templating library". Not that I'm for strict seperation of content from data that many Java developers seem keen on - it's not possible in general and counter-productive if you ask me.

I think PHP is okay for projects which have just one developer. Much more than that and I think its limitations become increasingly serious. I think PHP displays all the classic symptoms of a project that started out small, and had more and more features bolted on without much long term consideration. There's a number of things about the language and libraries that cause me no end of frustrations. I've also noticed that these days pretty much all web sites that seem to have reliability or performance problems are running PHP.

One thing that I often say is that with Java I find myself screaming at the language about once a year and the libraries about once a month, while with PHP I scream at the language and libraries about once a day. I wish I didn't have to use it so much at work... PS It's interesting to note that Zend Studio (a PHP "IDE") is written in Java...

Posted by Chris Rijk on March 10, 2005 at 04:23 AM PST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed