[ILUG] [OT] Perl v.s PHP?
phil at redbrick.dcu.ie
Thu Feb 22 22:03:37 GMT 2001
Cormac McClean's [cmcclean at ait.ie] 34 lines of wisdom included:
:>What do you feel are the relative merits of Perl v.s PHP
:>for inclusion in a course in Web application development
:>(including database connectivity)?
:>Which is more widely used currently, and is this likely
:>to change in the future?
At the moment I'm not sure which I could say it more used, but PHP
is certainly being used more and more by "professional web
programmers", PERL is being phased out and for a good reason.
UNIX principles teach the "right tool for the right job", it's built
up of small programs which each do their own job properly and right,
instead of one big huge thing which tries to do everything, this is
where it's succeeded.
Getting back on-topic to your mail, PERL (IMHO, but there are plenty
of people on this list who disagree) is suited for simple Sysadmin
tasks, I've used it for keeping user database records, routinely
doing backups and generally stuff using DBI.
After using PHP for web backend, not a chance would I use PERL
again, unless I was restricted.
:>Apologies for the OT-nature of this post, and here's hoping
:>it's not starting a Holy War (along the lines of Star Wars
:>v.s Star Trek).
It would have probably been more appropiate on the webdev list, but
you woulda got way too much "PHP is da bomb, never ever use PERL"
postings, so you're probably better off you posted here :)
It's very hard to talk about programming languages, people have
different styles of programming, people like difference languages
for the different functions they use, and if you've been using one
language for years and years, you're not going to turn around and
start advocating something else.
PHP's core language is quite small, and it's API is quite large,
making it quite a nice language. What this means is that, the
programmer very rarely needs to know anything about HTTP concepts,
i.e. variables are automatically read from the form, unlike PERL
where you have to process them (Yes, I know you can use CGI.pm or
cgi-lib.pl, even at that, that's a steeper learning curve than PHP).
PERL has a different (best way I can describe it) programming style,
it's unique, I suppose, and code can be obfuscated (opaque or just
plain awkward to read) very easily by beginner programmers, without
proper techniques being taught. Another con, being that perl has to
manually print out data, whereas PHP has separators, for embedding
the PHP code into HTML data.
<B> Hello </B>
phpinfo(); // Some PHP stuff in here
<!-- Some more HTML out here -->
Again, with PERL you can use templates, or some versions of perl
support separation of code and HTML (but most of them don't!).
One thing about PERL (which IMHO, makes it FAR more attractive as a
practical system programming language) is it's extensive list of
modules (http://www.cpan.org), it has much more support, basically
because the programming language is older, however PHP support,
maturity and knowledge is growing rather rapidly.
I wasn't a big PERL head when I first started PHP, so PHP was a good
choice, however big mad PERL heads are probably better off sticking
to it for CGI, because they know their way around the language.
Look at the FAQ for PERL and for PHP...
"Perl's process, file, and text manipulation facilities make it
particularly well-suited for tasks involving quick prototyping,
system utilities, software tools, system management tasks, database
access, graphical programming, networking, and world wide web
programming. These strengths make it especially popular with system
administrators and CGI script authors, but mathematicians,
geneticists, journalists, and even managers also use Perl"
"PHP Version 3.0 is an HTML-embedded scripting language"
"The goal of the language is to allow web developers to write
dynamically generated pages quickly."
Their goals are very different, PERL has a broad range of uses while
PHP has one very focused (it's still broad, but not AS) one.
More information about the ILUG