Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by zentara (Archbishop)
on Jun 11, 2006 at 11:47 UTC ( [id://554668]=note: print w/replies, xml ) Need Help??


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

why does everyone seem to prefer PHP nowadays

Because PHP requires less brains than Perl, and the colleges are full of wannabes these days, who are passed on curves, for the tuition money. The colleges have to make it as easy as they can for the dimwits to pass.

Ask the college admissions office how many of them get hired after graduation as web programmers.


I'm not really a human, but I play one on earth. flash japh
  • Comment on Re: The REAL reason for why they choose PHP over Perl.

Replies are listed 'Best First'.
Re^2: The REAL reason for why they choose PHP over Perl.
by Polonius (Friar) on Jun 11, 2006 at 16:58 UTC
    Because PHP requires less brains than Perl

    Do you really believe that? That Perl is difficult? That it doesn't make "easy things easy and hard things possible"? Part of the reason people choose not to use Perl is that they think it's difficult. Do you want to encourage that view?

    Polonius
      Do you really believe that?

      Yes, in the sense that Perl is "bigger in what it encompasses", and therefore requires a bit more background knowledge. Perl is a more complex tool. But maybe I was a bit too harsh, I hate full moons on Sundays......it brings out my biting nature. :-)


      I'm not really a human, but I play one on earth. flash japh
Re^2: The REAL reason for why they choose PHP over Perl.
by adrianh (Chancellor) on Jun 11, 2006 at 18:12 UTC
    Because PHP requires less brains than Perl,
    1. You think that's a bad thing?
    2. In my experience the opposite is true. It takes more understanding to write decent PHP than it does to write decent Perl - because the language makes some things harder than the equivalent perl.
      This page show the bigs diferences: PHP in contrast to Perl:
      • Arguments and return values are extremely inconsistent
      • PHP has separate functions for case insensitive operations
      • PHP has inconsistent function naming
      • PHP has no lexical scope
      • PHP has too many functions in the core
      • PHP lacks abstraction and takes TIMTOWTDI to bad extremes
      but PHP5 is more OOP.

      I suppose the best reason are these:
      • PHP is built from the ground-up with database functionality built in, particularly MySQL functionality. Perl is not.
      • PHP code gets embedded into HTML pages, unlike Perl. This makes it very fast to code web pages and fast to deploy a new site, thus speeding up Web development and lowering overall cost of ownership. An important code management technique for programmers is separating code from data. This allows us to make changes to the code or data without affecting the other. PHP uses the tags to indicate "code inside". 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.
      • PHP is secure. 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.
      • PHP is easy to learn in comparison to Perl. It's easier to learn than C, Python, Java, and most other programming languages used in web development, for that matter. The Perl style of programming is unique, and thus not universally applicable to or from other programming languages. 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.
      • PHP takes less "overhead" than Perl, meaning that PHP scripts will run faster than CGI scripts written in Perl, and you'll be able to handle more simultaneous users on your site. Benchmarking tests show time and again that PHP runs faster than other web programming languages. Check out these benchmarking analyses done by major computing magazines.
      • PHP code tends to be more consistent and modular than Perl.
      Humm... Some points are debatables, of course.
        Hi explorer,

        "PHP code tends to be more consistent and modular than Perl."

        Surely (don't call me Surely) this would depend on the people doing the actual coding? However "PHP is secure" is quite a bold statement to make.

        Martin

        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).

          Observe:

          <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.

        <radiant.matrix>
        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

      Depends on the POV. If you're a programmer, sure Perl gives you better tools, if you're not biased. If you're just a wannawebpage newbie, things like lexical scoping with my, closures, map, grep, contexts and alike are things you can't imagine to be useful. You just want HTML escaping, mysql (and all other supported database drivers) all other tools you use stuffed right into the namespace of your mywebpage.php4.

      Sure PHP has bigger usages and *is* and *can* be professionally used. But in my view that's neither the majority nor the part that started this hype.


      Ordinary morality is for ordinary people. -- Aleister Crowley
        But in my view that's neither the majority nor the part that started this hype.

        The vast majority of Perl, on the other hand, is produced by programming gods, and is always a thing of beauty :-)

        Seriously though - I agree completely. It's just that PHP is neither:

        • Half as bad as many people say it is - especially since PHP 5
        • Only used by incompetents.

      I don't know that it's a good or a bad thing; the point appears to be that if it's easier, more people will want to try it, regardless of whether it's better (or even acceptable). It's kind of like looking for your lost wallet under a streetlight (even though that's not where you lost it), because there's more light there. So, even though PHP may not be a good candidate for certain tasks, people may prefer it because it's easier to use for some purposes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found