May 27 2009

$$: Cache, or Crash

John

I recently revised my opinion of a little JavaScript framework you may have heard of. Frankly, I just got tired of simulating inheritance on my own, and Prototype does a better-than-decent job of class extensions, which is more than I can say for other libraries like JQuery or MochiKit.

However, that being said, it’s also worth noting the fact that Sam Stephenson – creator of the Prototype framework – is also a lead developer on RoR, which means that no matter what framework he’s building or what language it’s in, he’s going to make sure arbitrary – borderline useless – methods and helper functions plague the code base. Among these are things like Enumerable.zip, Element.makeClipping, and the oh-so-overrated Rails “dollar-w” Array method, $w. Now, one could argue that absolutely every inch of Prototype – or any framework, for that matter – simply consists of convenience methods and shorthand coding patterns – and that may be true. I mean, let’s face it, a framework can only utiliize a languages already-built-in capabilities – it can’t add to them. Regardless, I have become rather fond of using Prototype’s XPath parsing engine.

You may recognize some Prototype functions that utilize the XPath DOM traversal method like $$Element.getElementsByClassName and
Element.getElementsBySelector. However, these are H-E-A-V-Y on your browser. How heavy? YMMV, but generally, pretty fucking heavy. So heavy, in fact, that Google decided this was a good idea.  The question is, do I care? Meh, nah, not so much. I increase browser performance like Chris Brown punches out pop starlets.

Continue reading