in reply to Re: The REAL reason for why they choose PHP over Perl.
in thread The REAL reason for why they choose PHP over Perl.

Comparing PHP to a Perl CGI install is a bit flawed. To more accurately show the difference, you'd have to be comparing it to something like mod_perl + Mason. Mason example:
m <% print "Hi!" %>
vs PHP's:
<? print "Hi!" ?>
Mason lets you embed in an identical style to PHP, the barrier to entry is due to installed code base with most shared webservers. You want popular forum software? VBB and PHPBB are both PHP. You want a Bloggity blog blog blog? Wordpress, Moveable Type (Edit: MT is perl, woo :) ) and pretty much every other blog outside of Blosxom are PHP. You want a CMS? All those nuke etc sites that aren't based off of the PHP forums are PHP, with the exception of Drupal and Everything engine(Actually Drupal may be PHP now, I forget - point still stands).

I barely touch PHP, but run mod_php on my server due to all the other software that needs it(hosting friends sites and such). Unfortunately that precludes me from running mod_perl on the same server unless I have a high demand app that needs it. Running both simultaneously is only suggested if you enjoy using up all your ram. This also leads to me finding PHP equivilents to the applications I may prefer to have in perl, and jsut contributes to the problem. That, and laziness on my part for not coding more of it :p

One day, I'll probably mess around with Mason again, as the last I checked they didn't have native mod_perl2 support, so I didn't get farther then playing with it. It's really amazing how it addresses everything PHP can do, while adding in new paradigms like init and argument blocks, alongside being able to include other files with said arguments.

Random Examples of Mason awesomeness:
Simple site with dynamic includes:
<& ../check_auth &> <& ../header, title => "Welcome ".ucfirst(lc($user)) &> <& tabrow, active => 'main' &> <& ../iconcol, active => 'user' &> <div class="content"> Woo! Lookit me! I have content! (User/Main) </div> <& ../footer &>
The header included in above site:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=IS +O-8859-1"> <TITLE><% $basetitle %></TITLE> <& css &> </HEAD> <BODY> <%args> $css => "main.css" $cssinclude => 0 $title => "" </%args> <%init> my $basetitle = "MasonTest"; $basetitle .= ": $title" if $title ne ""; </%init>
Damnit, now I have to go play with this stuff again. :/

Replies are listed 'Best First'.
Re^3: The REAL reason for why they choose PHP over Perl.
by exussum0 (Vicar) on Jun 15, 2006 at 04:32 UTC
    Comparing PHP to a Perl CGI install is a bit flawed. To more accurately show the difference, you'd have to be comparing it to something like mod_perl + Mason. Mason example:
    Actually it's quite a fair comparison. As I've stated before, it grows incrementally complex, differently organized and has some user facing architectual differences.

    All you've shown here is a template system that uses perl, which php kinda is already as you've shown. But re-read my post. It's not about tempalting systems. It's ease of getting into it. Sure, I can install mason all over the place, but the subject here isn't just mason. It's perl vs php, where perl is a much larger subject than mason alone.

      Hmm, I think I hit msg instead of reply, sorry.

      I was curious as to what those architectural differences were in an installed system. The difficulty of installing mod_perl and Mason is comparable to a mod_php install, and even easier if you have a packaging system. The only real difference being a split up config file versus a single config, and Mason's caching system. I may be wrong, and there's more, so feel free to enlighten me.

      Once it's installed, using Mason is as simple as setting a handler on a file type (which is what one does for PHP), or designating a directory tree as handled by Mason. With the installation being the main difference, most users of the code don't have to worry about it, as very few of the PHP programmers I've come across administer the servers they code on as well.

      I will concede that there are definite hurdles to installing a Perl handled scripting system versus PHP, which can use some work. As I stated in my previous post, I had to restrict myself to just playing with Mason, because it didn't have proper mod_perl2 support at the time I wanted to use it. My main point however, was that once installed, it is functinally no different then PHP itself, you are simply using perl instead of php code. And you can additionally toss in extra code blocks for more flexibility with init/argument/etc handlers.
        You've ignored something I've said. perl is more than just mason. If you wish to do database work, you have DBI and tonnes of DBDs you can install. You have Class::DBI and many other forms of data access. You have modules for PDF, Word. Mason doesn't support it outright, where php directly does.

        In php-land, some large portion "modules" are actually c extension for php.

        In php, you have the mysql_*, postgresql_* and the direct db functions and that's about it. Yes, pear is an abstraction layer, but nothing beyond abstraction has been done yet. perl has various forms of data access as i've stated before.

        In perl, modules go into a namespace with a PERL5LIB path. Most of your code is written IN perl.

        In php, you are limited to includes which don't use a lib path where most of your modules are written in c.

        You can't write a multithreaded php application.

        And there are differences between php and mason post installation. To add modules is completely different between the languages.

        php is a web language first, and a programming language second. perl is a programming language first, and a web technology second. the internals and the language design lead toward this.

        I could go on and on. but please, stop ignoring that this is perl vs php, not mason vs php. Mason is cute, and it mimics php.

Re^3: The REAL reason for why they choose PHP over Perl.
by iguanodon (Priest) on Jun 15, 2006 at 15:08 UTC
    Wordpress, Moveable Type and pretty much every other blog outside of Blosxom are PHP.
    Minor point: Movable type is written in Perl.

      Woops, dunno why I thought it was PHP, point taken :) (and good to know!)
Re^3: The REAL reason for why they choose PHP over Perl.
by brd (Acolyte) on Jun 16, 2006 at 00:49 UTC
    The BAD thing about mentioning Movable Type is it is not free any more.. for 1-5 users you are looking at $200USD.