What the Hell is Wrong With Me?

For the past month or so I've written more PHP than every other language combined.  That's including English.  Really.  Four separate WordPress projects (two standalone, two MU), one of which is a blogging platform for Mentor Graphics, and I'm up to my neck.  I'm a CFML developer by profession; I think I got off at the wrong stop.

What I have learned?

  1. PHP's function libraries are insane.  I thought ColdFusion's (now CFML's) libraries had plenty of wonkiness, but PHP makes them look like the friggin' Pope.  Latest example: there is a 'sort' function that sorts an array.  It has an optional second parameter for controlling the type of sort.  But it's a whole separate function with identical parameters (called 'rsort') to sort descending.  Where's the optional third parameter for direction?  Or how implode accepts arguments in either order, but explode (it's inverse) does not.
  2. Dollar signs are harder to type than hashes.  Not sure why, especially with my big hands, but whatever.
  3. PHP's operators are lunacy.  Arrays are declared with "=>" for keys, by dereferenced with "['key']" syntax.  Object members are accessed with the "->" operator, and "." is for string concatenation.  And you can't combine the middle two in arbitrary ways (though some ways do work).
  4. WordPress was designed by really smart people.  A little too smart, I think.  And even aside from the choice of language, the code style confirms without a doubt that they're PHP developers to the bone.
  5. Implicit invocation is great, but while it fosters decoupling, overuse can create a developer's nightmare.  With too much indirection the code can't be easily read, so you have to simply memorize huge amounts of information in order to effectively work on an application.

Now before you go assuming I'm a PHP hater…

  1. I largely put myself in this situation.  I was in charge of selecting WordPress MU for Mentor's infrastructure, knowing I was brining PHP into an 85% CFML / 10% Groovy / 5% Java shop.  Five people (of nine) on the team swear by it for our personal blogs, though I was the only one with any substantial experience hacking the engine itself.  Despite initial reservations from the boss, and others (including myself), time has shown that it was clearly a good choice.
  2. PHP is friggin' fast.  Dear god is it fast.  With no concept of in-memory sharing across requests, everything has to reload on every request and it still screams.
  3. WordPress is a really flexible platform.  It's provides a solid foundation, a kickass application framework built atop it, and a great blogging engine on top of that.  And if you get the right theme(s), you've got presentation and CSS as well.  It's not a CMS out of the box, but for what it's designed to do it's fantastic.
  4. PHP's function types and higher order functions are kind of a mess, but at least they have them, and they support object methods.  You wouldn't believe how often this bites me in CFML.

Am I gonna drop CFML for PHP?  Hell no.  But despite PHP's and WordPress's warts, there's a lot of stuff worth of emulation.  Definitely reenforced my belief that CFML is an inherently iffy language for "down-n-dirty" development, even though it excels at templating and simplifying complex tasks.

On the surface, CFML is no where near as warty as PHP, but looking deeper and the story isn't so clear.  It seems like every couple weeks I discover or learn about some utterly bizarre behaviour that ColdFusion exhibits, and unlike PHP's weird function libraries, they're internal weirdnesses.  Functions can be stupid, but at least they're in your face.  You get a hard fail if you type one wrong.

Long post, and again, no real point.  Whatever.  It's Thursday, and better for my liver than drinking.

4 responses to “What the Hell is Wrong With Me?”

  1. Gaspy

    You summed up PHP's weaknesses pretty nicely.
    I do some PHP coding but (thank God) it's not my daily job.

    It's fast, it gets the job done, but man, it's the only language that I can't code in without having the reference book nearby. They can't even agree on the use of underscores, e.g. we have "isset($var) but is_numeric($var); don't even get me started on the whole ($needle, $haystack) vs ($haystack, $needle) nonsense. Add to that the fact that the language can do things differently depending on how php.ini is set or depending on platform, and you have a potential deployment nightmare.

    Working in PHP helps me appreciate actionscript/java/javascript.

  2. Thomas Messier

    I HATE the PHP syntax with a passion. The whole -> and => just annoys the hell out of me, as does the concatenation. Why did they have to cripple the language in such a way??? Beyond that, I agree with you, it has its pluses, speed being one that can't be neglected.

  3. Kay Smoljak

    Good post. We do a lot of PHP and a lot of WordPress at Clever Starfish – essentially, any project that calls for an off-the-shelf simple CMS or off-the-shelf shopping cart gets done in PHP, while anything different, custom, difficult or requiring cross-system integration gets done in CFML.

    While I don't particularly like PHP's syntax, I often find myself defending it from CF developers who rag on ANYTHING that's not CFML, regardless of how good or bad it is.

    At the end of the day, proficiency in multiple languages never hurt anyone. And you're right, WordPress kicks arse :)

  4. Ryan Mawby

    Snap! I'm primarily an ActionScript developer but have spent the past month or so up to my eyeballs in PHP and Zend – I have enjoyed the break!