Wednesday, November 26, 2008

To PHP or not to PHP. Is that even a questions?

This is still a question, but not as big a one as it used to be. Five years ago I was building web sites with a combination of PERL, PHP, HTML, and JavaScript. Today they are almost entirely PHP. Over the last few years, the PHP language has developed into a powerful, flexible language that has shown strength in not just the web arena, but in mainstream application programming as well.

Recently I was asked to write a script to inject mail to a Mail Transport Agent (MTA) in order to send several thousand emails in a short period of time (no, this was not SPAM) and I had my choice of languages to write it in. My first choice was PERL because I have had great success with PERL when I need to search and strip text data and access databases quickly. However, this time I chose to test how far PHP has really come so I wrote the script in both PERL and PHP and ran them on the same job data.

To my surprise, the PHP script performed as well, if not better than the PERL script. Both were fed the same information and had to perform the same task and over 25000 iterations, the PHP script may have actually beat the PERL script, by a few nanoseconds – too close to call.

I am currently re-writing a couple of my older web applications and replacing all of the old PERL and JavaScript chunks with equivalent PHP and have been able to actually reduce the code size and increase functionality along the way.

The moral here is… if you are a programmer and have ignored PHP because it is “just for dynamic web pages” then take another look. You might be surprised.

No comments: