Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Perl vs. PHP

by jerrygarciuh (Curate)
on May 20, 2002 at 19:53 UTC ( [id://167932]=perlquestion: print w/replies, xml ) Need Help??

jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

It seems unlikely that this has not come up before but my searches and supersearches yield no nodes.

My question is this:
While at a geekfest last night I was told for the third time in recent memory that PHP is far better than perl for most web programming. In particular PHP was touted as THE tool for database interfaces. I would like very much to hear from monks who know both as to when (or if)they would forsake perl for PHP. As of this writing I use DBD::DBI, HTML::Template and CGI for all of my webly needs.
TIA
jg
_____________________________________________________
Think a race on a horse on a ball with a fish! TG

Replies are listed 'Best First'.
Re: Perl vs. PHP
by Beatnik (Parson) on May 20, 2002 at 20:24 UTC
    Altho I was considering not replying, here goes...(Adding my 0.02 Eurocents in the flamewar)

    PHP, IMHO, is oki for quick layouts, vague DB stuff and lite code. It is, however, no match for Perl.

    The abstraction layer Perl has with DBI (not DBD::DBI as you noted) is unfound in PHP. Every RDBMS in PHP has it's own function for querying, connecting etc (thus making portability rather difficult). The PHP syntax is based heavily on Perl but I fear some more powerfull functionality has been dropped.

    The fact that hashes and arrays are one and the same, the fact that both scalars and arrays/hashes are accessible thru $ (bye bye % and @) makes it a bit weird if you're making the step. The power Perl has lies in the fact that you can have a plain console tool and port it to CGI in a matter of minutes (if you're used to doing that stuff). I acknowledge PHP has PEAR but it doesn't have the diversity CPAN has. Ofcourse Perl has an advantage of several years but Perl also has the advantage of being multipurpose, a step PHP only recently took by doing GTK+ functionality. I also feel that the core functions provided in PHP are too numerous. Considering the speed claim... PHP is an Apache module. mod_perl runs as fast, even faster than PHP. PHP can be run as CGIs too and I'm sure Perl beats it at that too. What about the embedding? Perl has embed solutions too, several actually.

    Rasmus and his team do deserve the attention PHP is getting, since it's fun, easy and flexible and they did a great job designing the language. But for some reason EVERY PHP programmer I know claims Perl is not as good as PHP. For some other reason, EVERY PHP programmer I know who wants to take that extra step in his programming career, switches to Perl and doesn't look back.

    End Remark: It's not in the language, it's in the programming style. Every programming language has it's strength and it's weaknesses. Perl is powerfull at this, PHP at that. If we all stopped bickering for a second ...

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      > ... and they did a great job designing the language.

      Gahh!!! /me pulls on hair screaming.

      Puuuuhhhhleeeze. My favorite "design" in php is their well thought out naming conventions for standard functions such as always abreviating string as str, oh... that is except when it's abreviated as strn or good ol' fashioned string, and of course the underscore, underscore, who's got the underscore game that you have to play with every method.

      If the million monkeys jumping up and down on typewriters came out with a programming language, it would be closest to PHP.

      /me goes back to working on his submission for PEAR.

      ()-()
       \"/
        `                                                     
      

        Not to claim that I know anything about PHP (I don't), but I have dim memories of C (and I just took a look at your links), and I will indulge in one smart-ass nit-pick: if you're confusing strcmp and strncmp, you may be in for a nasty surprise... that 'n' isn't part "string", it's an integer argument to the function telling it how many characters are significant for purposes of this comparison (that is, strncmp("bar","baz",2) indicates no difference).



        If God had meant us to fly, he would *never* have given us the railroads.
            --Michael Flanders

Re: Perl vs. PHP
by broquaint (Abbot) on May 20, 2002 at 19:59 UTC
    I'd recommend this node for a good comparison between PHP and Perl.

    PHP does have a very nice interface to databases (PEAR ain't too bad afterall) and I do prefer it to vanilla DBI, but it's still lacking in many other areas in terms of mature and stable libraries (although to be fair, nothing really comes close to CPAN ;-)
    HTH

    _________
    broquaint

Re: Perl vs. PHP
by g_schloss (Initiate) on May 21, 2002 at 03:35 UTC
    I've been active with PHP and Perl for a couple years, and here's my take on it:

    Database Interaction:
    PHP Comes standard, but lacks a standardized interface (outside of PEAR)
    Perl You need to go get it, but DBI provides a standardized api, making it very easy to switch backend databases with minimal code change.

    Web Programming:
    PHP Php is really fast and benefits from being designed as a web programming language. Much easier to throw together quick pages. Also, the creation of super-globals for server and form/cookie data is very nice for web programming as well.
    Perl Apache::ASP to be almost as clean as php, as can embperl.

    Power and Flexibility:
    PHP clunky interface to system calls, no interface to the apache api. My php and zend extensions had to be patched differently to compile/run under every minor version of php since 4.0.2
    Perl You can write full Apache modules in pure perl. Perl modules written in C/xs seem much more stable (most of mine required no changes throughout the perl 5 lifespan).

    Overall, php is quick, easy and not a bad language choice. Perl is almost as quick for straight web-programming, but is a more mature programming language that gives you greater flexibility in the long run. At least that's my $0.02.
(wil) Re: Perl vs. PHP
by wil (Priest) on May 20, 2002 at 20:25 UTC
    While going back through old usenet postings for this question which has been addressed, well a few times before, I came across a rather amusing post from the long time Perl veteran Tad McClellan :)

    - wil
Re: Perl vs. PHP
by jerrygarciuh (Curate) on May 20, 2002 at 20:36 UTC
    Thanks to those who replied. The links were especially helpful and led me to a nicely branching tree of opinion and history.

    To those who are SO aggrevated that I asked I will remind them that someone important to our community has said: "Go ahead, be a heretic."
    jg
    _____________________________________________________
    Think a race on a horse on a ball with a fish! TG

Re: Perl vs. PHP
by ignatz (Vicar) on May 20, 2002 at 19:59 UTC
    Please, no.
    ()-()
     \"/
      `                                                     
    
Perl is the way to go
by inblosam (Monk) on May 21, 2002 at 07:14 UTC
    Perl definitely has a lot more behind it as far as resources, modules, etc. PHP is more for the web designer who knows a little coding who hates putting all the HTML inside code and would rather put code inside their HTML. Perl is the way to go because it is so expandable. Your brain is the limit, essentially.

    Michael Jensen
    InBlosam Productions
    http://www.inblosam.com
Re: Perl vs. PHP
by DamnDirtyApe (Curate) on May 21, 2002 at 02:04 UTC

    One of the biggest (albeit certainly not the only) thing I prefer about Perl to PHP for web programming is the Template Toolkit. It may just be my lack of through knowledge of PHP, but I am not aware of anything that measures up to the Template Toolkit in PHP.

    I am a University student, and have been working the past few months on a research project for one of the professors, writing an eCommerce application in PHP. The way in which I feel compelled to write the code makes me cringe. If the project weren't as developed as it is, or I was going to be involved for much longer, I would certainly campaign to redo it in Perl.

    Afterthought: One other thing that has bugged me on this project: I haven't been able to figure out how to inform a PHP script what CGI variables were passed to it. After a bit of reading, I found that Perl's CGI module makes this as easy as @names = $cgi_obj->param.


    _______________
    D a m n D i r t y A p e
    Home Node | Email
      Afterthought: One other thing that has bugged me on this project: I haven't been able to figure out how to inform a PHP script what CGI variables were passed to it. After a bit of reading, I found that Perl's CGI module makes this as easy as @names = $cgi_obj->param.

      You want to be looking here for that information. PHP distinguishes between GET and POSTed variables. So the PHP equivalent for

      @names = $cgi_obj->param();
      is
      $names = array_keys(array_merge($_POST, $_GET));
      $_POST are all the POSTed keys and values. $_GET is the same for variables passed on the GET string.

      Hope this helps.

      jarich

      disclaimer:I don't really like PHP anymore. The DB stuff drove me nuts. Try porting from mysql to postgresql or such. Change the syntax for all the functions, change the order for some of them... argh! Nevertheless, sometimes you have to use it, and it can do almost everything you want it to... if you look hard enough. :)

Re: Perl vs. PHP
by Anonymous Monk on May 23, 2002 at 05:30 UTC

    I have used both Perl and PHP in the past several years. They each have their strong points. Those who tell you that PHP is far better for most web programming are probably used to small sites or sites with limited functionality. I have heard the debate often in the different "strategy" sessions.

    What it really boils down to is what is your application? Are you looking at maintaining a system of applications that are going to intertwine (try writing glue code with PHP) or are you writing a bunch of simple web pages never to be revisited again.

    The problem with the claim that PHP is best for most web pages is evident in the claim itself. From the perspective of a single web page, PHP is indeed simpler for the inexperienced. (Personally, writing web pages is simple in most languages for simple web pages if you know the language). However, the reality is that most web pages are part of a Web Application. Whether it be a reporting tool, a client support tool or something else. These applications typically require working with outside libraries as well as being able to write semi-complicated code. This is not something I have seen as being easier in PHP.

    Another important point to consider is where will this be in 6 months, 1 year? Which language gives you the most flexibility in the future? PHP looses big time here. Try switching Databases. Major rewrite in PHP. Perl is a more powerful and flexible language.

    One of the complaints PHP evangelists give is that there are too many ways to do a thing in Perl. What they miss is that it is much more likely that a Perl programmer will develop a working solution for a hard problem than a PHP prorammer because Perl lends itself to *how you think*. That is dismissed by many programmers as an open invitation to sloppy code. That any programmer would claim this shows (IMO) a lack of real world experience. I have not seen any language that forced clean, intelligible coding. Only programmers (and good managers). Try reading garbled C, C++ or Java (highly structured languages.) - you may Perl obfu not so obfu.

    Several people above stated some good reasons to go with Perl. Look at the road you are going to travel down. Think about the possible future. If any degree of complexity, glueing or other interprocess communications are required, Perl is the answer. If on the other hand, the whole system will never move to another DB, never be more than simple pages and forms, never link up with external apps, ... go PHP (and good luck in the future).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-19 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found