Dear PHP, I’m leaving and yes, she’s sexier

Dear PHP,

I know this letter won’t come as much of a surprise to you.  We’ve been growing apart for a while now but today we officially part ways.

It wasn’t easy to write this.  You and I have a lot of history.  Hard to believe it was over 10 years ago when you welcomed me into your arms.  You were young, sexy, and a breath of fresh air compared to my ex, Perl (shudder – lets not go there).  It didn’t take long for our relationship to start paying the bills.  In fact, every job I’ve had in the last decade had you on a pedestal.

We had plenty of good times.  Remember how we survived a front-page CNN link and pulled in $500k in 14 days?  And all the dynamic PDF creation over the years still brings a smile on my face.

But we had our rough times too.  I could go the rest of my life without ever hearing the words ‘register globals‘ again.  And you know quite well that I still bear the scars from creating SOAP clients with you.  While neither of us has been truly faithful (what ever happened to V6 and UTF-8?), we’ve always been able to work out our differences up to now.

But starting tomorrow, for the first time in 10 years, my ‘day job’ won’t include you.  I’m leaving you for node.js.  We were introduced by our mutual friend, JQuery.  At first I thought she was just the latest flavor of the month; popular among the guys on the mailing lists but now I’ve fallen victim to her async charm and really think we have a future together.

When you and I started having fun on the couch a year ago, I thought maybe our relationship would just keep going.  But then node and I spent some time on that couch and – oh, what she can do with JSON makes my toes curl.  To be perfectly honest, you just can’t compete with her.  She’s all that you used to be – young, sexy, and fast.  I’m sure some of your other boyfriends will probably argue with me about it but I’ve been smitten.  While they’re fighting with you over namespacing, she and I will be branching in non-blocking ways and spawning like crazy.

I’m not saying we’ll never see each other again – heck, you’re even serving this blog.  But I’m moving on and I hope you will too.  If you want to see what node.js and I are up to, stop by some time.  Maybe we can even help you keep an eye on all those fatal exceptions of yours.

Sincerely,
Shawn

About Shawn
Husband, father of 7 great kids, and code monkey at NodePing.

27 Responses to Dear PHP, I’m leaving and yes, she’s sexier

  1. snsparrish's Mother in Law says:

    * shudder, not shutter. Your vocabulary sucks

    • snsparrish says:

      Doh! Thanks, mom. I fixed it.

    • Mark says:

      Actually, that is a spelling issue versus a vocabulary issue. Using terms like “sucks” is a vocabulary issue.

    • J Cush says:

      There should be a period at the end of your second sentence. Your punctuation sucks.

      Also, Blog-Comment Nazis suck. But not wind tunnels — they blow.

  2. Bernardo Rosmaninho Oliveira says:

    Hey man, i had great time reading this! LOL!
    Congratsss!

  3. Felipe says:

    Perl > JS. :-P

    Seriously, Perl has some very useful features like “local”, and literal lists. (I cringe all the times when I type function.apply(this,arguments). JS also wastes memory by making every array a hash *plus* array ops.

    Though I may look into CoffeeScript; that at least would give a Perl-ish conciseness of syntax to JS.

    • snsparrish says:

      I’ve also seen and heard good things about CoffeeScript but the thought of having to go through a ‘compile’-like step feels like wearing a neck tie again.

      • Felipe says:

        For the server side there’s the coffee executable. For the web, I’ll bet there’s something out there, in progress, or easy to rig up that sits in the web server, compiles CS on the fly, and caches it à la Perl Template Toolkit.

      • Check out this guys, http://boxjs.com. Boxjs will compile CoffeeScript files, compress and minify them!

      • Morgan Craft says:

        I had the same thoughts, but it easy to use the coffee comand line utility to setup a –watch to compile your code real time as you save.

      • EllisGL says:

        My opinion is that CoffeeScript is like training wheels. They can get you started, but later on they just get in the way. Learn the language. I also share this opinion on ORMs.

    • Mike Shaver says:

      Arrays aren’t hashes but rather contiguous value storage in all modern engines that I know of, unless you stick non-numeric properties on them. Maybe you’re thinking of Lua?

      What are you doing with “local” that’s better than “var”? ES5 has bind, if you want to change the default “this”, but I’m not sure what you’re doing with apply, or what the pattern would be in perl; my perl is pretty rusty. People use literal arrays quite liberally in JS, but maybe you mean something other than that when you describe literal lists. Maybe destructuring?

      • Felipe says:

        In JS, arrays are instances of the Array subclass of Object. Object instances implement hash tables. The fact that you can assign non-numeric indexes to JavaScript “arrays” illustrates my point. Perl arrays are true arrays.

        “local” in Perl does something different from “var”: it takes a value scoped outside the current block (Perl is block-scoped rather than function-scoped.) and “localizes” the global variable, including inside whatever blocks/functions are contained within the block with the “local” statement. You’re probably thinking of “my” as the Perl equivalent of JS “var”.

        JS only has what Perl calls array *references*. In Perl, you can do this:
        my @foo = (1,2,3);
        my @var = ( @foo, 4, 5, 6 ); #same as (1,2,3,4,5,6)

        To do the same in JS, you have to do this:
        var foo = [1,2,3];
        var bar = foo.slice(0).concat(4,5,6);

        Oh, and the other REAALLY big annoyance in JS is the lack of a heredoc. In Perl, I can do this:

        my $long_string = <<END;
        Oh, I will just write
        and write
        and write
        lah de dee!!!
        END

        …but JS has no way of doing that.

        Finally, the lack of variable interpolation in strings makes code needlessly prolix. Witness:

        my $name = 'Felipe';
        my $status = 'cool';
        my $sentence = "Hello, my name is $name, and I am $status.";

        …which, of course, in JS, we construct thusly:

        var name = "Felipe";
        var status = "cool";
        var sentence = "Hello, my name is "+name+", and I am "+status+".";

        Yech.

      • Felipe says:

        I’ve come to see “this” as more of a kludge than anything. Perl has this right, IMO: the “context” argument is more cleanly implemented as just the first argument to the function.

        But, since you ask, I regularly use .apply(this,arguments) in classical inheritance models.

        var Subclass = function() {};
        YAHOO.lang.extend( Subclass, Base );
        Subclass.prototype.foo = function() {
        Subclass.superclass.foo.apply(this,arguments);
        …whatever else I intend for the subclass’s foo() to do
        };

        Of course, the fact that I can’t treat “arguments” as an array doesn’t help much, and I really hate typing Array.prototype.slice.apply(arguments).

  4. Felipe says:

    That said, JS >>>>> PHP. Yech.

  5. Mike Shaver says:

    No, in modern JS engines Array storage is different from Object storage. That Array.prototype delegates to Object.prototype doesn’t mean that the instance objects have the same storage. (I’ve been working on JS implementations since 1997, and did the array storage optimization in FF3.)

    Tracemonkey and related (FF):
    http://mxr.mozilla.org/mozilla-central/source/js/src/jsarray.cpp#42

    V8:
    http://codesearch.google.com/#wZuuyuB8jKQ/chromium/src/v8/src/objects.h&exact_package=chromiumos&q=package:chromium%20class:JSArray&type=cs&l=6728

    SquirrelFish:
    http://codesearch.google.com/#3V6MWLMMTXE/Source/JavaScriptCore/runtime/JSArray.h&q=package:webkit%20class:JSArray&type=cs&l=32

    (If those V8 and SF links don’t come through, search for JSArray in their respective source trees.)

  6. As of monday I too will be leaving my full time job as a PHP developer to work on our node.js startup

    Good luck endeavours in JS

    • snsparrish says:

      God bless your new business, Alex. Go head and put a link to your project here when it’s ready. I love seeing the stuff folks are coming up with in node.js.

      • We are currently in private alpha but will be moving towards a more open alpha soon. We have just been funded by an accelerator program (so my next three months are all node all the time) and we hope to start working at a much faster rate

        You can visit our site here:
        http://wavo.me/

        We do video, image, and music aggregation through recommendations from your social networks and provide an online library and playlists of your favorite media

        Also we are working on a rapid development framework for node (on which Wavo is entirely built) it is very experimental now, but after the current re-write-in-progress it should be much more stable and in a state to try out:
        https://github.com/glesperance/node-rocket/

    • clintonb11 says:

      Seriously? I want a Node.js job. All I do every evening is node.js. Someone hook me up! I want to leave PHP too!

  7. I thought it’s yet another PHP -> Ruby article which makes me sick :) but PHP -> Node.js sounds much better :)

    I had fun of reading this)

  8. Mohammad says:

    Haha, well written – but I feel that one day, you will want your ex. back, she will take you back, but you will regret all the fun times you missed by leaving her for so long.

    • demian.max@gmail.com says:

      Really? Because there are so many people who “come back” to php? All those tech luminaries who love PHP … oh wait, there are none.

      It’s a novice tool, and the people who leave don’t often come back. Unless it’s for a job of course. There is still the business case (tons of cheap hack programmers) for php.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: