Comparison Between PHP and Perl

pudge on 2000-04-17T18:45:42

Giorgio Valoti writes "Hi all, I was asked to make a comparison between PHP and Perl based solutions for dinamic web sites and/or web apps. I appreciate the power, flexibility and portability of Perl, but what about PHP? Has someone of you tried these solutions and doesn't mind to share the pros and cons? "


PERL vs PHP

precision on 2000-04-19T19:33:59

In my experience for building web applications PHP is the way to go. It's been designed since the beginning to be a web programming language. It has all the features I need, it's fast, and it's stable. From my experience with mod_perl it's been slow and it seems to leak memory. I don't if they've fixed this yet though. Don't get me wrong I think that perl is great, I just also think that each language has it's place and in my opinion PHP is better for web stuff.

Re:PERL vs PHP

pudge on 2000-04-19T20:22:10

I've never seen any good evidence that mod_perl is slow in comparison to PHP. Do you have any?

Re:PERL vs PHP

duff on 2000-04-20T02:32:17

I too would like to see some timing characteristics of mod_perl vs PHP. A good test would be programs that do the following:

  • Nothing (The empty program)
  • Only loops
  • build a small array
  • build a large array
  • build a small hash
  • build a large hash
  • reads a file and writes a web page
  • ... (you get the idea)
  • some arbitrarily complex operation

(Keep in mind that I don't know or use PHP; but if anyone has some good data that could change ;-)

I'd be interested in memory consumption as well as timing if anyone is up to the task.

Re:PERL vs PHP

chip on 2000-04-20T13:15:32

Memory leaks were pretty much eradicated in 5.4. That's what made mod_perl workable in the first place.

On the other hand, mod_perl requires some tricks to minimize total memory usage. But those tricks are well-known and documented by now.

PHP vs Perl

gaudior on 2000-04-20T17:30:58

I am using both in the intranet/extranet project I am contracting on. PHP has some nice features wrt embedding code in HTML. I've never used any embedded perl, so I can't comment on that. PHP's syntax is sometimes maddeningly close, but not close enough to perl that it drives me batty. It also has the annoying property of explicit function calls for everything. I would love to have the simplicity of $x =~ s/foo/bar/g; as opposed to preg_replace();

On another hand, it does a nice job with HTTP handling. Form variables are passed transparently, which makes chaining applications very nice. It's a good tool for basic forms, and simple database work. The database access is not nearly as concise as DBI, however. If you are using MySql, you use $result=mysql_query("select * from foo",$dbhandle);. If you later switch to Sybase, you have to change your function to sybase_query();

On the whole, I would have preferred to use mod_perl start to finish, but some decisions were made before I arrived. I have used perl for authentication, FTP scripts, and a little CGI. The bulk of the site is straight HTML, and the admin screens are PHP. My impression of PHP4 is that it is close to mod_perl in performance, but I have not done an objective benchmark.

Re:PHP vs Perl

tdenkinger on 2000-04-21T12:28:58

> PHP has some nice features wrt embedding code in HTML.

This is actually one of the things I don't like about PHP and other, similar tools like ColdFusion. I used Cold Fusion for years and have evaluated PHP as a replacement. Embedding code in the HTML gets messy fast. For smallish applications it's not too bad, but if you have to do complex or large applications, trying to work around the HTML get's frustrating.

I prefer to keep the code and the content as separate as possible.

Re:PHP vs Perl

gaudior on 2000-04-24T12:20:40

Embedding code in the HTML gets messy fast.

Agreed. But for quick forms processing, canned queries, and prototyping it works well. Rigorous adherence to coding style standards helps a great deal. (which is true for any other programming venture)

I prefer to keep the code and the content as separate as possible.

As do I. Templates and fully dynamic, database-driven sites are the things I am starting to focus my attention on.

Re:PHP vs Perl

brlewis on 2000-06-29T18:07:12

An even better tool for forms and simple database work is BRL, which I wrote. The syntax is not maddeningly close to perl; it's based on Scheme. Database access is extremely concise and database-independent.

Re:PHP vs Perl

perriko on 2002-06-18T11:20:23

I'll have a look at it and try it... I don't need big fancy stuff... but YAL (yet another language??)