I'm a long time Perl programmer that has developed some pretty complex E-commerce sites using Perl CGI and mySQL. I have a brand new site development project which will also be a dynamic, mySQL driven site. I've done some reading about Perl versus PHP and it appears the main conclusions are PHP is easier to learn and faster (much faster than Perl CGI, about the same as mod_Perl) and it makes controlling the dynamic HTML presentation of the page a bit easier (as opposed to having to use a bunch of print statements or CGI.pm functions).

My key objective is to minimize my developement time as the project is a fixed fee so the quicker I complete it, the more money I make per hour. To date, I've found the thing to be most time consuming with Perl programming is the output of the HTML page -- I've been using a pipeline approach in which I include and/or parse HTML templates. I like this approach because of the fact the page logic (the code) is kept totally seperate from the page presentation. That way, I can have anyone and there Mom edit the HTML template and not worry about them messing up or quizzing me down about all the embedded code in the HTML file. However I can convert to an embedded code format if it is going to save me time in development.

So I'm at a crossroad and looking for some insight especially from someone (preferably a seasoned Perl programmer) who has passed this same crossroad. Performance is not really an issue since I can be careful to code this new site very strictly so I can use mod_Perl instead of Perl CGI. I'm embarassed to admit that I never looked into any of these templating systems that work with Perl such as Mason and embPerl. From what I've read though, it sounds like embPerl would be the better choice for my purposes.

And finally, my other consideration is portability. I know Perl and PHP will be around for quite some time to come and virtually all UNIX and Windows hosts now support it. This new site will be a virtual dedicated host, so we won't have total control over it. I don't want to go with a tool set that is going to cause me headaches in the long run when we migrate from server to server. Another consideration is that in many cases, what I developed will later be maintained by someone else. It appears there are 10 times more messages in the PHP forum here than Perl which means there are probably more developers out there than know PHP than know Perl . (of course I think that is because newer/younger developers are choosing the scripting language with the easiest learning curve since PHP is newer and designed specifically for website development.)

So, if development speed and portability is of the essence, what would you recommend?

A) Program in mod_Perl (what I alread know) and continue to use my own internal methods for utilizing HTML templates.
B) Program in mod_Perl and utilize embPerl or another templating tool (would HTML::Template be a better alternative?)
C) Take the time to learn PHP and switch to that?

For those who respond, please provide a little background info on your programming experience if possible so I know where you are coming from.

I recommend you switch over to PHP. It might be a step back for you that you have to learn it, but at the end you'll be more efficient. I can type fast right now and I never took a typing lesson. I know that if I did, at first, I will be typing a little slower learning the correct method and trying to get used to it, but I know once I learn the correct method, I'll be typing a helluvalot faster.

Anyways, I have several reasons. The first one traces back to the birth of Perl. When conceived, Perl was not meant to be a web language. Was not meant to handle processes like web application servers, was not meant to handle sessions, database connections, etc... etc.... PHP is a combination of the best features in C, Perl, and Unix utilities all combined to tackle web applications. Now it's true that you can pretty much do anything PHP can do in Perl, but it has to be extended. By that I mean you have to create your own modules or get them from an outside source like CPAN. The more you extend the language, the more overhead you add. It's not like PHP, where these tasks are already built into the language. Built in functions, as you know already, can be faster and help you develop faster.

I think you'll be able to develop faster in PHP too. I don't know about you, but I've seen some wicked Perl code in my time. Some of the code is like looking at an EXE file in notepad. I really can't tell the difference. PHP's syntax I think is more readable and can help even more if you're working in a team. Most of the people that get into web development have at least taken one C/C++ course in their lifetime. It will be a smoother transition going into PHP rather than Perl I believe.

As a web language, I think PHP is faster. There are so many addons and configurations to really pump up its speed. My opinion is biased, I know. But from experience, and hearing others, I think PHP is faster at processing (when it's configured properly).

Another thing that I would consider is how well it's doing in the business/IT world. Do a lookup of how many companies are using it and have been productive/successful. Go to monster.com and dice.com and type "PHP" and then "Perl" to see which one is more in demand by companies. Almost all host providers offer PHP and make more of a fuss than PHP than CGI (Perl).

The community as you know is large. I think there is a larger chance of you finding useable PHP web scripts than Perl. Also, the community, as you already know, is overwhelming.

Lastly, take a look at PHP 5's new features. It's more object oriented. I don't know about you, but I was never happy with Perl's take on OOP. It's like a fake OOP. In PHP 5 you have Try/Catch blocks, Private, Public, Protected variables/functions, and more. You can also import functions through namespaces. Maybe being a C++ programmer has spoiled me.

Hope this helps. Personally, in my opinion, if you're a freelance web programmer, then I say go with PHP. If you want to work for a big business, then invest time in .NET or even J2EE. I think the fastest method of developing web applications is through ColdFusion, hands down.

These are some of programming languages I've used:
Assembly, C/C++, Java, ASP, PHP, Perl, ColdFusion, SQL, JavaScript, Visual Basic, Flash ActionScript, Pascal, XML, and used to write shell scripts for the cshell, bash shell, and DOS.

Here's info on PHP 5:
http://www.phpvolcano.com/articles/php5/index.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.