php-versus-perl

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.)

0 comments: