Codes from the Underground

Ben Coe is a software developer based in SF. He currently hacks up a storm at @attachmentsme His interests include climbing, coding, and being awesome.

(Follow Ben on Twitter, My Projects on GitHub)
Apr 25

Why I’m Becoming a JavaScript Convert

I remember the first time I played with JavaScript, it was around 1999, and I was 16. I had bought the reference book ‘JavaScript for dummies’ (a seminal work in the field) and was having a lot of fun adding interactive widgets to my website — I remember specifically ripping off the Windows 98 ‘Start Menu’ …

Fast forward a few weeks, and I am quickly becoming frustrated with cross-browser compatibility problems. Furthermore, there was a strong prevailing prejudice against JavaScript — this helped push me out of the world of front-end web-development and towards ‘software-development’.

It’s now 11 years later, when I look at the world of ‘software-development’, the most exciting software products I can think of are on the web. I recently started work at FreshBooks, a company making one of these exciting products. While trying to figure out my niche as developer in the company, I found myself working on a lot of front-end stuff. This has pushed me into using JavaScript, for the first time since I was a frustrated teenager.

Things I’ve learned:

  • Closures in JavaScript are amazing!
  • Prototypes rock.
  • Leaning on libraries like jQuery makes cross-browser annoyances much less annoying.
  • JavaScript is an elegant language! it’s not a toy (this shocked me.)


This brings me to a bet I made with my co-worker on the flight from Toronto to jQuery conference in San Francisco.

“Mark”, I said, “I bet I could build Tetris in JavaScript, during this plane trip.”

To which Mark replied,

“I doubt that.”.

What is relevant about this? — I feel the hastily hacked together Tetris code I wrote on the plane is a great demonstration of the power of JavaScript.

Let’s look at the design:

  • I used John Resig’s Simple JavaScript Inheritance. This is an awesome micro-library that wraps prototypes into a function that gives them behavior closer to classical inheritance.
  • I used jQuery for DOM manipulations, event handling, etc.
  • I used an HTML 5 canvas for drawing.

Without further adieu, here’s the obscenely slap-shod code I wrote in 3 hours on the plane:

Play It

So there you have it, pretty sloppy, but I feel an awesome argument for how powerful JavaScript has become, and will continue to become as technologies like HTML 5 get wider adoption.


  1. bencoe posted this