Prototype.js vs. underscore.js showdown
June 7th, 2012I 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 thanbind
, 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.