Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: The REAL reason for why they choose PHP over Perl.

by exussum0 (Vicar)
on Jun 14, 2006 at 19:44 UTC ( [id://555335]=note: print w/replies, xml ) Need Help??


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

A complete php web application that involves php for say, hello world, is one line of php code. For perl, it's more complex because php hides a lot.
<? print "Hi!" ?>
vs
#!/usr/local/bin/perl print "Content-type: text/html\n\nHi!";
So there's two pieces of complexity. The shebang and the header. Want to refer to variables? In php, it's "easy".

Perl is so modular, you can mix and match things to get a lot accomplished. You can create a module with your core logic, like in php, then reference it via soap, http, command line or corba... unlike php.

Documentation for php leads people to realize, to call a php function, you just call it. In perl, you have the nasty import statement. oh noes!

Then it starts to break down. php needs recompliation for postgresql access and other moduels. In perl, you need to do it as well, but you never have the false idea from the perl documentation that something pre-exists.

Then you run into consistency issues. Perl is not innocent from this, since there's 100 ways of doing anything via modules, but perl is upfront with that. In php, there's usually one way of doing it and you have to find it.

But to solve any of these issues and the others, php has momentum. Providers install a db, php and some core stuff, and you never need recompilation.. until one day it bites you. php has a LOT of people who will point you in the right direction, until the one day you can't do the one thing the way you want to. versus perl which is "too complex" from the getgo and kinda makes people think up front.

There's a touch of sarcasm, and believe-you-me, I favour perl because it makes you think and gives you that flexibility w/o trying to do the web too-well.

Replies are listed 'Best First'.
Re^2: The REAL reason for why they choose PHP over Perl.
by Azhrarn (Friar) on Jun 14, 2006 at 22:18 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:
    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. :/
      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.
      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!)
      The BAD thing about mentioning Movable Type is it is not free any more.. for 1-5 users you are looking at $200USD.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://555335]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-29 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found