Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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

by radiantmatrix (Parson)
on Aug 02, 2006 at 16:04 UTC ( #565253=note: print w/replies, xml ) Need Help??

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

Hm. Most of your points seem to come from an incomplete understanding of Perl. Let me address a couple of big ones:

  • PHP is built from the ground-up with database functionality built in, particularly MySQL functionality. Perl is not.

    Perl's database capabilities are impressive. DBI is a flexible system that supports Oracle, MySQL, Sybase, any ODBC source, and many more. Built upon it are things like the DBIx family of modules that allow for robust database access without writing SQL.

    Perl may not have had database support early in its life, but as it currently stands, its support is much more mature and robust than PHP's.

  • In Perl, however, programmers are encouraged to use print statements to generate the HTML. True it is possible to implement templates in Perl (with more difficulty than in PHP) to separate code and HTML, but 90% of sample Perl code on the web doesn't do that.

    Programmers are most decidedly not encouraged to use print statements to generate HTML. Programmers are encouraged to use Template Toolkit, HTML::Template, or other easy-to-use templating systems. Of course, Perl lets developers shoot themeselves in the foot -- but so does PHP.

    Later in the same point, you say "An important code management technique for programmers is separating code from data", and templating systems do that. Marking PHP code between <? and ?> is not separation of code and data -- it's inclusion of code (PHP) in data (HTML markup).


    <p>This is a paragraph with some <? print($generated_content) ?> in PH +P.</p>
    That's code right inside the data. Compare:
    <p>This is a paragraph with some <TMPL_VAR generated_content> using HT +ML::Template</p>

    That's a placeholder for code to act on. And that's separation of code and data.

  • Perl scripts tend to have more security holes. This is because PHP has built-in a lot of the internal operations of dealing with web page requests and serving information.

    True, PHP has web functionality in the core language since it was developed with the intent of being a web language. However, to suggest that dealing with page requests and serving information is something that each Perl developer has to deal with in their own way is naive. Included with every modern Perl distribution (that is, it's in the Perl core) is the CGI framework, which handles all of the web-request architecture. Trivially available from CPAN are such things as CGI::Application, CGI::Simple, the FastCGI extensions, even complete web-application frameworks like Mason and Catalyst.

  • PHP is easy to learn in comparison to Perl. ... The Perl style of programming is unique, and thus not universally applicable to or from other programming languages.

    PHP was developed with much of the Perl style in mind, and the styles between the two are very similar. PHP does allow a new developer to go from zero to web-enabled app very quickly (which has a lot to do with it's popularity for web apps, no doubt). However, nothing about PHP makes it easier to write good applications when compared to any other language.

    Perl's style of programming isn't that unique -- it's largely an amalgam of elements from various well-established languages. Perl was one of the first languages I learned, and I found that picking up PHP, Python, Java, and even C were made quite easy with a foundation in Perl. This is because these languages borrow from each other significantly.

  • Accessing web form variables in PHP is straightforward, but in Perl requires either detailed knowledge of either HTTP header formats or one of many Perl CGI libraries.

    Accessing web form variables in Perl is easy and straightforward as well. Perl was designed to be an all-purpose language, so yet you have to use a CGI module. But there isn't a whole lot of knowledge involved. Check it out:

    use CGI::Simple; #standard module import my $cgi = CGI::Simple->new; #standard object creation #now I need to get a copy of the userid form var my $userid = $cgi->param('userid');

    It's just an object accessor. If that's not straightforward enough:

    my %formvar = $cgi->Vars; my $userid = $formvar{userid};
  • PHP code tends to be more consistent and modular than Perl.

    That's just entirely a red herring. Consistency and modularity are no more difficult in Perl than in PHP (or vice-versa). It's up to each developer to be consistent and modular, and it has almost nothing to do with the language choice.

PHP does have some advantages over Perl for certain applications: for example, mod_php is ubiquitously available from inexpensive virtual-hosting providers compared to mod_perl. It is certainly worth comparing the languages in terms of when each is the best choice.

However, to simply assert that PHP is a better language than Perl is naive. Specifically, the justifications for that assertion that you supply above are ill-concieved.

A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://565253]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2017-03-26 10:36 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (315 votes). Check out past polls.