Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Vs php? Which one is better?

Comparing Perl & Other Langs

Perl Vs php? Which one is better?

by  133tcamel  Posted    (Edited  )
Perl Vs PHP?
Which one is better?

The simple answer is the former can be better than latter and the latter can be better than former depending on what do you want to use it for. But nonetheless here is a small comparison to help you judge for yourself

Maturity
--------
But to say the least speaking about PHP, it is something prototyped using Perl, so PHP still uses traces of its Perl ancestry in its many respects. PHP is a younger language, Perl has much more depth and maturity of the code. PHP is even know for bugs in its code (speaking relatively, since perl has been here for a longer time, more time went into correcting them).

Code Integration
----------------
The major advantage(most people consider it an advantage) of php is that its code integrates directly with the HTML code, this advantage makes the code much more compact and designer friendly. Perl also offers various solutions like embedperl, mason, Text::Template, but since this is not a part of the core code, it takes some time to get used to this. (On a personal note; I still find it much better to keep the code separate from the template).

Learning
--------
Another advantage of php over perl is that php is a relatively easy to learn language and has a smaller learning curve, Perl requires you to have some knowledge of C and some shell scripting. Not that it means you can't learn perl if you don't know these, but should you know these - perl is much easier to learn. Perl's code often appears cryptic to novices but once you get used to seeing it and get upgraded to a perl hacker this gets more and more picturesque (sorry for straying away from the topic, but just couldn't resist :) What I was trying to say was this cryptic looking code is what makes perl more powerful from any other language.. php often gives you long or absurd function names :), so you have to type a lot of unnecessary code which is unlike perl's nifty code..

Speed
-----
I haven't benchmarked anything myself, but the simple mantra to perl's any speed related problems is upgrading to mod_perl. Actually I don't even need to test if mod_perl is faster than php since I already know the results (YMMV).

mod_perl has to be enabled server additionally after installing perl. This is a little pain if you're running your scripts on a shared hosting.

Also both perl & php can be made to run with FastCGI for better performance too.

Support
-------
Since perl has been here for so so many years, and so has the CPAN (Comprehensive Perl Archive Network); there is no _other_ thing that even comes near to the CPAN. Any module that can be used for general usage is already available on CPAN. The number of perl enthusiast is also very much, no denying that too. Php also has its mailing lists to offer help. But still the bottom line is that the support available for perl has always remained unparalleled and I think it's going to remain the same.

Debugging
---------
Debugging perl's code is much easier than php. I know the instant reaction of some people would be to disagree with me, but try running the perl interpreter with the "-Wc" command you'll know what I'm talking about. Also the availability of modules like CGI::Carp and Devel::Messenger can even go to the extent of instant messaging you the code execution status :) nifty, eh?



Compatibility
-------------
Both php and perl have been ported on Microsoft Windows and MacOS :)

Note: Features like threading, forking (yeah, I know but thats kinda fake:) not available on Win32 due to the lack of support in windows operating system.

Usage
-----
Php is most suited to developing websites. For perl this is just one of the aspects you can specialize in. php has goodies inbuilt for session tracking, etc to make sure that you don't have to do the dirty work in making a website from scratch. Perl too has support for this (CGI.pm, Apache:Session/Authcookie, etc..) but some of these have to be learnt and/or enabled. Where perl wins is that perl can be used in many other fields than just web programming. Perl is also being used in Bioperl, VLSI Perl Scripts, robotics applications, network applications, etc... the list is really endless (one of the reason why I said its like comparing apples and oranges :)

About Me
--------
Written by Sanchit Bhatnagar,
- B.E. Electrical, Delhi College of Engineering (DCE).

I am a freelance developer and I have been programming for about 8 years now. Besides this I've done programming in C, C++, Delphi, Visual C, Pascal, Visual Basic, JavaScript, Qbasic and Assembly8085 (in order of experience). Feel free to use the material presented here for your reference, but do not plagiarize the content, i.e. do not copy text from my articles without giving me credit.

If you have any comments, suggestions, improvements in regards to this, please feel free to send me an email at popularscripts (at) gmail (dot) com

-----------------------------------------------------------
¬ 2003 - Sanchit Bhatnagar.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top