develooper Front page | perl.advocacy | Postings from August 2001

Re: My list of PHP's shortcomings

Thread Previous | Thread Next
From:
Andy Wardley
Date:
August 22, 2001 13:08
Subject:
Re: My list of PHP's shortcomings
Message ID:
20010822123912.A35403@dog.ourshack.com
Nathan Torkington, High Priest of the Slippery Lighter, wrote:
> Here are my reasons why the idea of using PHP on big projects scares
> me:

Forgive me for slipping into marketing buzzwords, but I think
the most succint description of PHP's downfall is that it 
doesn't support an "n-tier" model.  It doesn't support 3-tier
and it doesn't even support 2-tier.

When we talk about "n-tier" it's just another way of saying
"clear separation of concerns".  2-tier is when you separate
the presentation from the application logic.  3-tier is when 
you also abstract out the data model.  

PHP embeds programming logic directly into the presentation
logic (code in templates).  This is effectively the same thing 
as embedded Perl.  It's very quick to get up and running, it's 
very powerful, but it doesn't scale well.  It's 1-tier.

On this level, the comparison is just.  One can argue that 
PHP isn't as good a programming language as Perl, but that it
is more closely tailored to the immediate needs of hapless
"HTML Programmers" who want to add Kewl Funktionalitee to 
their web pages.  

But I think the fundamental difference goes much deeper.
PHP is just an embedded language.  It only exists inside 
template files.  You don't write scripts or modules using 
PHP (or rather you shouldn't, but I had one email from a 
guy asking advice on how to write a parser in PHP so that 
he could write a template processing language for it!).

A better comparison to make in the Perl vs PHP debate is to
compare PHP with the likes of the Perl + Template Toolkit + 
DBI + You::Name::It::We've::Got::A::Module::Which::Does::It.pm
combination.  You can argue that TT gives you a decent 3-tier
model and that running Perl behind-the-scenes gives you as 
much programming power as you'll ever need but within a 
framework that allows it to grow and scale well.

And of course, if you don't like the Template Toolkit, then
you can switch the template language to HTML::Template (a
very respectable 2-tier language), or HTML::Mason (typically
1-tier but nevertheless, far more scalable than PHP), or one
of the other fine modules.  If you can't find a template 
module you like then simply write your own.  That's what
everyone else does. :-) 

In fact, wasn't that how PHP began life?  

PHP: Perl Hypertext Preprocessor (IIRC)

> I'm not saying Perl is perfect 

Perl isn't perfect, but it gives you the option to use it with 
something that is more closely aligned to your needs.  For one
project it might be Perl + TT + Tangram + DBI, for another it
might be Perl + HTML::Template + CGI + DBI.  

You can do that with Perl, but not with PHP.  



A


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About