Ongoing JavaScript library discussion
Posted by mde [ Sun, 21 Jan 2007 04:29:00 GMT ]
PPK over at QuirksBlog has a nice entry on the latest round of discussions about JavaScript libraries in the JS/DOM/CSS blogging world.
The JS library thing continues to provide rich fodder for discussion because it involves so many different layers -- what type of app you want to use the library for, your level of skill with native JS/DOM/CSS, the coding style you're comfortable with, your tolerance for sloppy/undocumented code, your tolerance for download size, your tolerance for corporate overlords, how well your goals align with the goals of the toolkit developers, and so on.
PPK starts off by referencing a post I read last week or so from Stuart Langridge (author of DHTML Utopia, and the tech reviewer for my book), where Stuart seems to moderate a lot of the serious anti-library leanings he used to have. Ultimately however, I don't really buy PPK's final point -- he believes that the current lack of doco means that the only people who can use the toolkits are the experts who don't need them. He writes:
Right now it doesn't seem that Stuart's nine-to-fivers will actually benefit from libraries, unless they're pretty decent scripters to begin with, which makes their using a library less necessary (hence less likely).
First of all, I think there are plenty of nine-to-fiver developers out there plugging in one toolkit or the other, squinting at the scant online docs, and hammering at it until they get it to do what they want. For most of those guys it still beats trying to write a CSS fadeout transition from scratch. And second, it's pretty obvious even to a diehard do-it-yourself-er like me that even experts can get a lot of benefit from leveraging the work of a larger group of experts like themselves.
Similarly to Stuart, my opinion of the use of libraries or toolkits has evolved, as the kinds of things I want to do with JavaScript has changed, and as the quality of the available libraries has improved. Relying on a set of tools used by a larger group of developers gives you significantly more power with a lot less effort than if you were to try to do all that stuff yourself.
But you do give up some degree of freedom. In the words of Wooderson , "Oh, yes you do."
First of all, you have to do some stuff the toolkit's way whether you like it or not. I've used both Dojo and Prototype now enough to know that both of them do things in ways that seem less than optimal to me. Dojo's packaging and namespacing stuff feels kind of Byzantine and overengineered to me, for example. Prototype's Event.observe is pretty underwhelming, and I find the bindAsEventListener thing seriously awkward. Not to dump on those two libraries -- in return I get a bunch of well-tested functionality for free.
More importantly, you become dependent on the developers of the library to implement the features and fixes you need. If you've got that library code rooted deep in your app, it becomes a genuine concern to you that the library developers not do things that will totally break your shit. In theory, you do always have the freedom of not upgrading your main JavaScript library. Ever. But how appealing is that in a serious Ajax app that's under heavy development?
We use Dojo in the Cosmo app, and the news that Dojo is jumping from 0.4 to 0.9, with no backward-compatibility code in the new version , doesn't give me a warm, fuzzy feeling inside. Libraries are supposed to make your life easier, and the words "comprehensive porting guide" sound suspiciously like "a bunch of extra work" to my jaded ears. I'll withhold judgement until I see how extensive the changes are.
I feel like now I have a pretty even-handed view of the positives versus the perils of using a third-party toolkit in your Web app. The peril part is one of the reasons I keep working on the Fleegix.js library for use in my personal projects. Okay, that, and the fact that I just genuinely enjoy playing with this stuff.