24 Oct 2008 badger   » (Journeyer)


JavaScript is a mass of failures. But it's also a fun language. Why the contradiction? I get the impression that it just isn't a very complete language in a lot of ways. Here's my short, top-of-the-morning list of JavaScript shortcomings:

  1. No way to specify dependencies between modules.
  2. Lack of a comprehensive standard library.
  3. No standard method of taking well organized code (for instance, separate files) and turning them into something that is efficient for the network.
  4. Using prototype for inheritance has a few corner cases that you have to have knowledge of in order to avoid pitfalls (this could just be me, though).

Most of the major JavaScript frameworks out there have some code in them to address these failings. This is both a plus and a minus. On the one hand, it means that it is possible for JavaScript to be extended to work around these problems. On the other hand, it means that instead of learning JavaScript, a serious programmer has to learn jQuery or Dojo or Prototype. And it means that when you find that you really love one feature about one framework and a second feature about another framework you either have to make the user download both frameworks (with all the duplication in functionality between them) or suffer through a suboptimal means of doing some things since you are restricted to just one.

And now that I've got the rant out of my system, let me tell you what I like about Dojo and jQuery and why I wish JavaScript made it easy to use both together:


  • jQuery has a very rich querying method for selecting JavaScript nodes that extends the standard CSS selectors in useful ways.
  • jQuery has an equally rich series of methods that operate on the queried nodes. Even though Dojo has a query() method that can do similar work as jQuery, the richness of methods that can apply is somewhat restricted in comparison.
  • In other words, jQuery has an area of specialty: selecting nodes from the DOM and manipulating them. It's the best framework I've encountered for doing that


  • Asynchronous programming in Dojo is easy with the twisted-style Deferred. Programming network requests and other long running or recurring events asynchronously is natural with Dojo.
  • Specify dependencies from within JavaScript files. You don't have to use html script tags to specify all the JavaScript files to load or where to load them from; the dependencies mechanism does that for you.
  • Build system to take your organized code and make it suitable for deployment. Lots of little files become one JavaScript file so the browser doesn't have to make multiple requests or even an option to allow asynchronous loading.
  • dojo.declare() makes object oriented javascript much easier. It's fun working with prototype and the nitty gritty of JavaScript's prototype-based OO because it's different than the class-based inheritance that I'm used to but I also get extremely tired of debugging problems with prototype inheritance because there's just one little thing that I don't understand (and seemingly, no one else on the internet does either :-) or writing boilerplate over and over.
  • In other words, where jQuery makes it easy to do all things DOM related, Dojo makes it easier to develop and deploy the rest of your application.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!