Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of Zepto.js, of script.aculo.us, and I'm a Ruby on Rails core alumnus. With Amy Hoy I'm building cheerful software, like Noko Time Tracking and Every Time Zone and write books like Retinafy.me.
   Want me to speak at your conference? Contact me!

Prototype.js vs. underscore.js showdown

June 7th, 2012

I recently ported my little CreditCard.js library from Prototype.js to use underscore.js, as I needed that in a project. Here’s what I’ve found—check out the original Prototype.js version first:

And here’s the same thing, but ported to underscore.js:

A few observations that, needless to say, are opinions, not scientific fact:

  • Prototype.js’ direct extensions of built-in prototypes make code cleaner and easier to read
  • Sometimes JavaScript-provided APIs like reduce have their arguments in just the wrong order; especially when used with chained method calls.
  • Some helper functions, like $w are missing in underscore.js
  • curry is more fun than bind, and I don’t need to specify a scope
  • Porting is pretty straight-forward, a testament to Prototype.js’ influential role in modern JavaScript

Prototype.js is still awesomesauce, and in many ways the mother of modern JavaScript libraries. I still prefer the syntax over many of the newer libraries. These newer libs have their own advantages, of course, mainly size and modularity. But sometimes I do long for the good old times.

Want to learn how to master JavaScript? Grab a seat at the JavaScript Master Class, a two half-day live online class with Amy Hoy and yours truly! (Next date: June 14/15, 2012!)