Web Automation: PHP vs. Perl vs. PHP Page 2

By Matthew Keller (Send Email)
Posted Jul 7, 2000


As I mentioned before, both PHP and Perl (as applied to Web applications) are interpreted languages. Interpreted languages are not pre-compiled and executed in a binary format, rather, they are parsed by an interpreter on demand and compiled on-the-fly. Because of this, both Perl and PHP are very portable. Both languages can run on any platform that has an interpreter for the language (with subtle difference here and there).

Another benefit of being interpreted is that the coders can tweak their application and immediately see the results and implement the new code, without having to wait for the application to recompile and relink. On the downside, both PHP and Perl are "slower" and "more costly" than their C or C++ equivalent. What this means is that if you wrote a Perl or PHP application in C, it would run "faster" and use less CPU time. I put "faster" and "slower" in quotes because on the Web, unlike on your desktop, application "speed" is dependent on more factors that just the sheer running time of the application.

Syntax and Core Functions

Both PHP and Perl have their roots in UNIX and UNIX-like operating systems (as well as the C language). For this reason, they both have similar syntax and core functions, such as the "chown" and "localtime" functions.

Integration with Apache

mod_perl and mod_PHP are both very well designed modules that allow the interpreter for the language to be embedded into the Apache Web server itself, speeding up run-time execution and offering a wealth of features above and beyond the standard CGI execution. For example, installing mod_perl on the Apache webserver exposes the Apache C API (Application Programming Interface), which allows you to write Apache server modules in Perl instead of C.

Perl and PHP: Their Differences

Here is where the rifts between these two powerful Open Source communities start forming. There are just as many differences as similarities, and I'm only going to touch upon a few of the ones I think are big and important.

Development Focus

Perl is developed as a versatile, powerful language that is easily (trivially, actually) extensible and can serve billions of purposes. Sure, there is a large segment of the Perl community that work on projects such as mod_perl and write Web-savvy modules, such as Lincoln Stein's CGI.pm module, but the focus of Perl development, as a language, is not based on the Web or the Internet.

PHP is developed for Web automation. PHP developers have added features to make Web content generation trivial, as well as provide easy access (trivial, actually) to a wide range of backend databases. Everything about PHP development screams "give me Web-savvy feature."

Target Appeal

PHP appeals greatly to Web-content designers who know HTML inside and out, but want to spice up their site--add a little database interface here, dash a standard "look and feel" template there. PHP also appeals to the person who want to abstract HTML design, from application design. If you want multifile applications that allow you to quickly and painlessly change one file without affecting (we hope) other pages in the application--PHP is your language du jour.

Perl, as far as Web applications go, apply to the more technically minded person, programmer, or power fiend. Perl's infinite extensibility and modular design make it incredibly popular among web application developers who want a single program (usually with a horde of included modules), or a couple programs, to be their application instead of the several hundred HTML pages that the same application might require if it was done in PHP.

Readily Embeddable

I don't know if "embeddable" is a word, but you get the point.

Page 2 of 3


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.