What the Hell is Wrong With Me?


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!