PHP versus Perl comparison

December 26th, 2002

by Stephan Spencer

We recommend writing web scripts in PHP, not CGI / Perl. PHP is much better suited to the Web and takes less “overhead,” meaning that scripts will run faster and the server will be able to handle more simultaneous users on your site. Here’s Why…

Perl (Practical Extraction and Reporting Language) is a great language for some things, just not for programming web pages. Perl is indeed “mature” in that it’s been around for a long time, prior to the Web in fact. But that doesn’t mean it’s the most suitable tool for web development. Indeed it’s not. We know this first hand because we used to code web sites in Perl in Netconcepts’ early days (1995 & 1996). In fact, we were honored with a case study in the book “Using CGI” (published by Que) back in 1995 because we were so ahead of the game in regards to building dynamic database-driven web sites. We were the only case study in that book and had 2 full pages devoted to profiling some of our work. But I digress…. ;-)

I should preface all this by saying: PHP owes a lot to Perl. PHP was first prototyped using Perl. PHP still shows traces of its Perl ancestry in its string manipulation features.

BUT, Perl has a lot of deficiencies compared to PHP. I’ll highlight the main ones:

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.
Don’t just take my word for it. Webmasters are switching to PHP in droves. In fact, PHP has now become the most popular server side language for writing dynamic web pages. More popular Microsoft’s ASP (Active Server Pages), JSP (Java Server Pages), Macromedia’s Cold Fusion, and Perl. PHP is being used by over nine million web sites, that’s over 24% of the sites on the Internet, thanks largely to the benefits outlined above, such as quicker response time, improved security, and transparency to the end user.

(Note that a lot of the above reasoning also applies to why we’ve chosen PHP over ASP, Cold Fusion, etc.)

Spread the word: delicious this:PHP versus Perl comparisondigg this:PHP versus Perl comparisonspurl this:PHP versus Perl comparisonfurl this:PHP versus Perl comparisonreddit this:PHP versus Perl comparisonAdd to Y!:PHP versus Perl comparison

5 Comments

  1. Perl was old hat in 1999!

    And actually it works just fine for the BBC!

    by Damien Jorgensen - Cardiff — May 19, 2007 @ 6:45 am

  2. This is exactly what I was trying to find for a customer… Great comparison!

    by SEO Pakistan — May 23, 2007 @ 1:32 pm

  3. I so much disagree… PHP safer than Perl? How many security holes a week show up in PHP, and how many show up in Perl? Exactly. A lot versus basically none.

    “PHP has internal operations…”. Perl, just like PHP, needs programming to make things safer, such as input validation. PHP doesn’t do any of this automatically, and neither does Perl.

    The ability to embed PHP within HTML is great, however, most PHP programmers embed PHP into a bunch of pages as part of their application, making theming and customization more difficult. Perl programmers however do it the other way around. Perl code reads templates with HTML in it, parse it, and then present it. Thus we use only one template.

    As for the speed thing. PHP has one major problem that most people ignore: it can be embedded within the web server (i.e. Apache) as a module. Load a PHP application with a lot of traffic and you will see how bloated the web server gets and how loaded the server becomes. I run PHP as a CGI to avoid this problem. As for Perl, if you are concerned about the compilation time on execution (which is the same process as in PHP unless you use a caching system such as Zend or APC), use PersistentPerl (pperl) and the problem is solved.

    by Peter — December 3, 2007 @ 10:24 pm

  4. PHP vs Perl a very interesting question and one in which I have to disagree with the article author. Perl is as you said the origionator of the server side language and as such PHP owes a great deal.

    Over the last 6 years I have learnt both Perl, PHP and ASP. There is many pros and cons to each language. However Perl is the winner in both mine and my staff’s eyes.

    As for the age old question ‘which is faster?’ It is a valid opinion that PHP is faster but Perl.

    However…

    Perl has been around longer and there for there is more documentation and solutions to problems. Secondly Perl is more versatile and more secure as the previous person pointed out there is a security hole appearing once a week in PHP where as Perl is far less prone to this sort of problem.

    As for the comment about its easier to learn I dont think thats true. I started my programming days as a Visual Basic 5/6 and progressed to Visual Basic .NET. From this I tried to learn PHP and Perl and found Perl easier to take on board. It wasnt until I had learnt Perl that I learnt PHP afterwards.

    by Mark Greenall — February 2, 2008 @ 7:47 pm

  5. As a software developer turned network administrator, I think the benefits of the language depend a lot on the nature of the problem environment.

    In a Windows environment, I tend to use .NET for everything because the API hooks are there. In a Linux / BSD environment, I tend to use Perl because, as pointed out, it is very mature and well documented. There are also many libraries available that make it flexible, more so than PHP. For web interfaces, I tend to use PHP *because* of the ability to easily write HTML and PHP code top to bottom - making RAD easier for me.

    Were I were to write an actual web application, I would probably prefer PHP which would be faster *for me*. This is simply because I’m familiar with it. If I were to write the same application in Perl, I don’t believe I would be able to optimize it as well given the same time frame.

    Thus, I think the question of what language is faster depends on what you and your staff are most familiar with in terms of the problem domain.

    by James Pearce — July 13, 2008 @ 10:41 am

Leave a comment




Related Articles

Netconcepts » Articles

  1. Is Your Retail Site Navigation Spamming Google? Tuesday, 3 February 2009, 9:48 am
    If your retail website has deployed filter-based n. […]
  2. New tricks for Old Pueblo Sunday, 7 December 2008, 12:55 pm
    In this article on Multichannel Merchant, Netconce. […]
  3. SEO Toolbox Tips Wednesday, 13 August 2008, 8:03 am
    How current is your SEO Toolbox? Do you have all t. […]
  4. SEO Report Card: Littlepixiegifts.com.au Wednesday, 6 August 2008, 11:47 am
    A SEO review of this site and the Best Practices i. […]
  5. A Natural Disposition for Search Thursday, 31 July 2008, 11:29 am
    Is the use of rich media and new web technologies. […]

Case Studies

Netconcepts » Case Studies

  1. Case Study: Cabela’s.com Wednesday, 27 June 2007, 6:03 pm
    GravityStream empowers Cabela’s marketing. […]
  2. Case Study: HSN.com Monday, 25 June 2007, 10:51 am
    1200% increase in Google indexation Over 25% of u. […]
  3. Case Study: Northern Tool Wednesday, 20 June 2007, 12:00 am
    Six-figure sales in the first month 14,000 produc. […]
  4. Case Study: REI Friday, 15 June 2007, 9:01 pm
    200% gain from overall natural search sales More. […]
  5. Case Study: figleaves.com Monday, 11 June 2007, 10:28 pm
    40% increase in natural search traffic Page 1 Goo. […]

Testimonials

Immediate ROI

300% jumpstart in search traffic

E-commerce consultancy service vital to their success

As critical partner, we made it happen

Partnered with Netconcepts for SEO success

See all Testimonials →

Seminars

Netconcepts » Seminars

  1. Mega Session: SEO Vets Take All Comers Friday, 22 May 2009, 4:42 pm
    This PowerPoint-free panel is made up of veteran s. […]
  2. Duplicate Content Solutions & The Canonical Tag Thursday, 21 May 2009, 4:57 pm
    Duplicate content has long been a worry of the SEO. […]
  3. Internet Retailer Conference 2009 Monday, 27 April 2009, 2:11 pm
    Netconcepts will be exhibiting at the upcoming Int. […]
  4. SEO: From Soup to Nuts Thursday, 29 January 2009, 1:42 pm
    Whether you are a developer or a marketer, a seaso. […]
  5. SEO Status Report Metrics Wednesday, 14 January 2009, 10:38 am
    How are your SEO efforts going from a technical st. […]

Newsletter

Web marketing virtuoso Stephan Spencer, shares a wealth of emarketing experience and hard-hitting, practical advice in our monthly newsletter. It's full of valuable insights...You should subscribe.








Testimonials

Immediate ROI

300% jumpstart in search traffic

E-commerce consultancy service vital to their success

As critical partner, we made it happen

Partnered with Netconcepts for SEO success

See all Testimonials →

Latest posts
Latest comments


Contact Us

HEADQUARTERS
2820 Walton Commons West, Suite 123
Madison, WI 53718 USA
Phone: (608) 285-6600
Toll-free: 888 207-1109

NEW ZEALAND OFFICE
36 Anzac Rd., Browns Bay
Auckland, New Zealand
Phone: (+64) 9 476-4601
www.netconcepts.co.nz
infodesk@netconcepts.com

CHINA OFFICE
806 – Building 12, 93 Jian Guo Rd, Chao Yang
Beijing, China
Phone: (+86) 10 5820 7041
Fax: (+86) 10 5820 7042
www.netconcepts.cn
info@netconcepts.cn