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

perl or php?

by perlid (Initiate)
on Nov 23, 2003 at 13:53 UTC ( #309276=perlquestion: print w/replies, xml ) Need Help??

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

Greetings,

I'm a newbie here. I signed up because I've got a question regarding the choice of perl or php for doing CGI stuff. I've some knowledge of Perl but none of PHP. My question is: Which of the two should I use as a backend for web applications?

Recently, I asked a friend about whether he uses Perl and he said, to my horror and dismay: "Perl is dead."

:(

I've heard of Perl 6 and have been following some of its developments. There doesn't seem to be much progress on where it's headed to over the past months.

Does anybody know anything about Perl 6 to shed some light on it?

Replies are listed 'Best First'.
Re: perl or php?
by jdtoronto (Prior) on Nov 23, 2003 at 14:25 UTC
    As you might guess, Perl is far from dead.

    The ranks of PHP programmers might be amazed to hear that. PHP is an easy languge to learn. It is far simpler than Perl, has far less flexibility and far less extensibility. PHP can do a good job of many CGI applications, at least as good as Perl!

    It is true that in the eyes of many teachers of community college level 'web technology' or 'internet programming' course that Perl is dead. One teacher I know told me "I have a couple of hundred hours in which to teach these kids how to do some graphics editing, some animation using Flash, HTML design including CSS, and CGI programming." How do you teach the entire gamut of Perl in a couple of hundred hours? You don't, and where would you find the time to handle all the other niceties of Web work that these students need to know. This teacher works with PHP all day, but when he works for me out of hours it is all Perl, not a line of PHP to be found.

    PHP has its place. It is a great environment which owes its very existence to Perl. It is quite capable of doing much of the day to day basic grunt work of the CGI programmer. PHP can do much but Perl can do so much more.

    Perl 6 is far from stagnant. Totally new languages are not born in a few years. They take considerable amounts of time and effort on the part of many computer scientists. There are some great minds at work on Perl 6, just cruise over to perl.com and look for Perl 6 news. You will see that their is a great deal happening. Perl made its public debut on December 18th 1987, long before CGI was thought of! In the intervening 16 years some of the greatest minds of modern computer science have worked on Perl to make it what it is today. Some of those same minds and more besides are woking to make Perl 6 something truly unique and useful.

    Perl is not dead, but Perl is not just CGI or Web Applications. Perl is also systems administration, network programming, Desktop applications, complex data processing (Perl Data Language), massive database administration and a host of other things.

    PHP is many things too. But to nowhere the same extent. Can I wirte a GUI desktop application in PHP that is portable to most common platforms using PHP? Nope, but I just did it in Perl!

    jdtoronto

Re: perl or php?
by liz (Monsignor) on Nov 23, 2003 at 14:39 UTC
    I see four questions in your node:
    1. Whether to use Perl or PHP for "CGI stuff".
    2. Whether to use Perl or PHP as a "backend for web applications".
    3. Whether Perl is dead.
    4. Whether anybody knows anything about Perl 6.
    Quite a list for a newbie.

    Without anything about your background, requirements for your project, constraints, prerequisites, how can you expect anybody to give a meaningful answer to 1. and 2.? Should I buy car A or car B? Any salesperson of A will say "A", any salesperson f B will say "B". Does that tell you anything? Don't you think you'd need to go a bit further as in "it shouldn't cost more than X, it should be fuel efficient at least as Y, you shouldn't need a drivers license for it, etc. etc.".

    As to 3., I think you can safely say that there are a lot of people developing and using Perl on a day-to-day basis. Would you consider Apache dead because there haven't been that many new versions out lately?

    As to 4., I think only Larry Wall will be able to answer that conclusively. Meanwhile, you better check out his articles on Perl.com and try to grok the Apocalypses as well as Damian's Exegesi.

    Hope this helps.

    Liz

Re: perl or php?
by batkins (Chaplain) on Nov 23, 2003 at 14:22 UTC
    This is just silly. First of all, asking this question on a Perl message board is bound to get you a bunch of Perl-biased answers (like this one). Second, there's no one answer to your question: Which of the two should I use as a backend for web applications? It all depends on the needs of your project. I would opt for Perl, because I find it to be a lot more powerful than PHP - but you knew I was going to say that.

    Also, I don't know why you'd feel horror and dismay simply because someone expressed an opinion about Perl. Perl is not dead, as the activity on this board will attest. And what do you need from Perl6 that you can't do in Perl5? Your implication seems to be that because Perl6 hasn't been released yet, your friend must be correct about the death of Perl. Consider looking at what Perl has to offer right now. Furthermore, there's been plenty of progress on Perl6. Check the Perl6 weekly mailing list summaries over at perl.com and see for yourself.

    Are you sure it was a book? Are you sure it wasn't.....nothing?
Re: perl or php?
by allolex (Curate) on Nov 23, 2003 at 14:42 UTC

    Every now and then, we get a question like this at the Monastery. Since this is the Perl Monastery, you can generally expect an answer supporting Perl. Perl 6 is little far off to talk about its utility to you, so I'll stick to PHP 4 and Perl 5.

    Often when PHP people talk about Perl, they refer to using it with the CGI. CGI is, well, a bit old. It might do what you want, but it turns out that PHP beats Perl via CGI hands down because PHP is actually mod_php and built directly into your Apache web server. Nowadays, people interested in speed tend to use mod_perl instead of CGI (although there are alternatives to mod_perl as well). This comparison turns out to be much fairer. Actually, mod_perl combinaed with something like Mason turns out to be very fast. There is an entire book out on how to use mod_perl.

    In our project, we use PHP because someone got advice like yours. The ironic thing is, we use Perl for absolutely everything else. You see, PHP is limited to being served up via HTTP, whereas Perl can be used to munge data, help you with system administration, build spiders or complex web scraping applications.

    What it comes down to is this: PHP was modeled on Perl and is still a subset of Perl. Sure, there are web-specific functions built in to PHP, but I have yet to find a PHP function that cannot be found in the core Perl distribution or in a module off of CPAN.

    Update: batkins pointed out a muddle. I meant something like "traditional CGI" up there---the one that would even produce output from a shell script. I thought it was clear from the context, but it deserves clarification.

    Update of update: Looks like I was a little too quick to acknowledge someone else knows things better than I do. It turns out that my memory did serve me well. Thanks to revdiablo for looking up the facts.

    --
    Allolex

    Perl and Linguistics
    http://www.wall.org/~larry/keynote/keynote.html

      I love Perl, but actually PHP is not very limited. You can use PHP to "to munge data, help you with system administration, build spiders or complex web scraping applications."

      Oh, and you can also use PHP to build GUIs. Just trying to keep the facts straight.

      As a child of Perl, PHP is growing by leaps and bounds and has a serious Oedipus complex. Watch those spears.

        How do you do GUI's in PHP, jacques? The only toolkit I've heard of is pidget, which does HTML GUI's.

        Are you sure it was a book? Are you sure it wasn't.....nothing?
      Often when PHP people talk about Perl, they refer to using it with the CGI. CGI is, well, a bit old. It might do what you want, but it turns out that PHP beats Perl via CGI hands down because PHP is actually mod_php and built directly into your Apache web server.
      .....What? You still use CGI even when you use mod_perl. CGI is the Common Gateway Interface, the way Web clients pass data such as form entries to an application on a server. Whether your interpreter is running inside the web server or outside, you're still using CGI.

      Are you sure it was a book? Are you sure it wasn't.....nothing?
        You still use CGI even when you use mod_perl. CGI is the Common Gateway Interface, the way Web clients pass data such as form entries to an application on a server.

        Actually, no. CGI is an interface from servers to external applications. Clients have nothing to do with it. And when using mod_perl or mod_php, you are not using CGI. These are apache modules. They run directly in the apache process. In summary: CGI is external, modules are internal.

        [If you don't believe me, feel free to consult the CGI Intro linked from W3's CGI page. Notice the first sentence of that intro says "The Common Gateway Interface (CGI) is a standard for interfacing external applications with information servers, such as HTTP or Web servers." The emphasis is mine.]

      >>Update: batkins pointed out a muddle. I meant something like "traditional CGI" up there---the one that would even produce output from a shell script. I thought it was clear from the context, but it deserves clarification.

      What about just calling it mod_cgi?
•Re: perl or php?
by merlyn (Sage) on Nov 23, 2003 at 15:39 UTC
    Although the other replies in this thread already give the detailed justification for my next utterance, let me summarize them lightheartedly with this:
    PHP is training wheels without the bicycle.
    {grin}

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: perl or php?
by jeffa (Bishop) on Nov 23, 2003 at 14:48 UTC

    I have done my fair share of PHP programming. Honestly, i really like PHP. I really do ... but, the level of programming ability among PHP programmers is much lower than that of Perl programmers. Because PHP is indeed easier to get started with than Perl, it tends to attract less than good programmers. Of course, Perl has it's share of less than good programmer as well, but PHP doesn't have a site like this. :)

    Stick around, not only will you learn a lot of Perl here, you will also learn a lot about Web Programming. I recommend that you learn some Perl, learn some PHP ... heck, a little Python won't kill you either. But by no means is Perl dead. Who is your friend? Send him our way and we'll show him just how ridiculously wrong he is. >:)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: perl or php?
by EvdB (Deacon) on Nov 23, 2003 at 15:13 UTC
    As most of the above posts have indicated perl is much more powerful than php, although php is better suited to persons beginning programming on the web.

    The question I would ask you is "Do you want to write a few simple CGI scripts and leave it at that, or are you intending to learn to program?";

    • A few simple CGI scripts: Use PHP, it is a smaller, lighter language which is designed for CGI programming. You embed the code in the HTML and so it is quick to do simplo things such as just changing a single line on the page.
    • More complicated coding: Go for perl (or python, java etc). Perl is very fully featured and extensible, and as such will take longer to learn. However you need not learn all of it to get good results. Perl will allow you to do things that PHP simply is no suitable for, such as templating, controlling other software, inerfacing to C libraries, GUIs etc.

    PHP is a kick bike, perl is a motor bike. If you need to get to the corner now a kick bike is easy to learn and quite quick. If you want to go on the motorway, you'll need to put in the extra bit of effort to ride a motorbike. Just don't forget your helmet( use strict; use warnings and for CGI, perl -T).

    --tidiness is the memory loss of environmental mnemonics

Re: perl or php?
by bart (Canon) on Nov 23, 2003 at 15:10 UTC
    PHP is fine (and fast) for small dynamic websites, but for huge projects, it's a pain.

    I can only point towards an URL that got posted in a use.perl blog. Do read the comments at the blog, too.

Re: perl or php?
by perrin (Chancellor) on Nov 23, 2003 at 22:10 UTC
    There is nothing terrible about PHP, and if you like it you should feel free to use it. However,

    1. More large sites run on Perl than on PHP. Amazon.com, CitySearch.com, Ticketmaster.com, IMDB.com all run Perl. Yahoo uses some PHP, but they also use Perl, and pretty much everything else.

    2. More good programmers use Perl. PHP doesn't have the same culture around things like unit testing, separation of application from interface (with MVC and templates), and reusable code (CPAN) that Perl does.

Re: perl or php?
by Cody Pendant (Prior) on Nov 23, 2003 at 20:40 UTC
    I'm not even going to comment on "Perl is dead", of course it isn't, but sometimes it's invisible.

    I don't know if people have been following the Microsoft/Eolas case, but it may mean that web pages have to be re-coded for a new version of IE, if they contain plugins like Flash.

    Macromedia, the makers of Flash, came up with what they called a "command line utility" which you could use to check which pages on your site were vulnerable to this problem.

    They say "command line utility" but you and I might just call it a "Perl script"...

    So when there was a big text-munging problem that needed to be solved quickly, they used Perl. They just didn't say they used Perl...



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
Re: perl or php?
by ysth (Canon) on Nov 23, 2003 at 18:21 UTC
    $ fgrep 2003 perlhist.pod Rafael 5.6.2-RC1 2003-Nov-08 5.6.2 2003-Nov-15 Fix new build issues 5.8.1-RC1 2003-Jul-10 5.8.1-RC2 2003-Jul-11 5.8.1-RC3 2003-Jul-30 5.8.1-RC4 2003-Aug-01 5.8.1-RC5 2003-Sep-22 5.8.1 2003-Sep-25 Nicholas 5.8.2-RC1 2003-Oct-27 5.8.2-RC2 2003-Nov-03 5.8.2 2003-Nov-05 Hugo 5.9.0 2003-Oct-27
    Doesn't look dead to me. (Update: credit where credit is due: the grep doesn't show it, but 5.8.1 was by Jarkko)
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2023-01-27 18:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?