From PHP to Perl
Submitted by Nola Stowe on Tue, 2006-06-06 15:24.
PHP parameter order
CPAN vs PEAR
In recent months I've been moving away from PHP, a language for which I have developed in for 6 years. I learned it because it was free instead of learning ASP. I made a website for my boyfriend so he could write articles about computer gaming hardware. I interned at a place and did PHP, and then moved to another company doing PHP.
I was pretty content with PHP ... until I saw Ruby first, then made friends with some Perl geeks, realized they weren't all arrogant l33t language snobs and took another look at Perl. Hey, its kind fun! PHP had become boring and Ruby and Perl gave me a new challenge. At first, I only read them thinking "how can I do this in PHP.." and managed to get my company where I did PHP to send me to YAPC. But after a time, I realized I didn't like PHP anymore and I wanted to do Perl or Ruby.
I've written a few articles on CodeSnipers on the differences between Ruby and PHP. I wrote one on datatypes in PHP vs Perl. Click on the Ruby topic on the side to find those articles.
Since I have been coerced into giving a 5 min talk at Perl meeting tonight about this.. Here's some of my thoughts in a blog...
Reasons why now I prefer Perl to PHP:
PHP parameter order
I didn't really think about this till someone mentioned it to me and since then it has really bugged me! Now I know why I am constantly opening up php.net to look up functions.
You would think they could come up with a standard and stick to it..
strstr(haystack, needle) array_search(needle, haystack)
CPAN vs PEAR
Then, there's the holy war on CPAN vs Pear. I used to watch the Pear lists closely and the occasionally dipwad would come in and present his Most Awesome Code and it would be rejected by the "core members" then he would go on some rant about how great CPAN and why PHP people suck. There is also the PHPClasses.org website which accepts any php code, so they tell him to go post his code there.
Then you have competing classes like Template engines. Although I like a good programmer fight, some things are not worth fighting about.
Awhile back, the folks on the PEAR list were going to write to write one unified interface for all the templates, so you could switch out the engine. I was thinking, HUH? ... I'm all for flexible, modular code but there comes a point where you need to stop abstracting and get work done.
One of the things I like the most are the tests in Perl. I wrote about testing PHP with test-more (a ripoff of the Perl mod, no actually I think it was made so you could use TAP to test PHP) on my blog sometime ago.
I like going to the command line to look up docs: perldoc Test::More ...I wished there was one for PHP. I download PDF of the PHP docs, I go to php.net, I have the windows chm file... but I still like perldoc better. AND there are even tests you can run to see if your code has enough documentation (enough in terms of number of characters, obviously only a human can determine if it is sufficient).
Perl Critic ROCKS, a module that checks the style and syntax of your code, allowing you to set your own rules. Works in conjunction with the Perl Best Practices book, even giving page numbers as references.
BTW ... I start my new job with Perl in less than 2 weeks. So long PHP.