Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: perl or php?

by allolex (Curate)
on Nov 23, 2003 at 14:42 UTC ( [id://309283]=note: print w/replies, xml ) Need Help??


in reply to perl or php?

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

Replies are listed 'Best First'.
Re: Re: perl or php?
by jacques (Priest) on Nov 23, 2003 at 17:15 UTC
    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?
Re: Re: perl or php?
by batkins (Chaplain) on Nov 23, 2003 at 15:06 UTC
    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.]

Re: Re: perl or php?
by BUU (Prior) on Nov 23, 2003 at 15:38 UTC
    >>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?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-16 20:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found