First experiences of jQuery
October 18, 2006
I latched on to dojo early in my Ajax career (that would have been, oh, say 4 months ago). The approach the dojo developers take to modularity, classes and so forth appealed to the Java programmer in me. It made things familiar enough to get a handle on easily. Plus, I went to see Dylan Schiemann present a workshop and was impressed by the depth of his knowledge.
However, as I started to work seriously on our application, I began to get the feeling that I was missing something fundamental about JavaScript by hiding it behind the familiar constructs of classes, inheritance and encapsulation in the form that I am used to. Because real work (you know, the stuff that pays the bills) came up I needed to pause what I was doing with JavaScript, but in the meantime, I began to take a close look at HTML and CSS design. In my spare minutes I re-developed our company website to use the ideas I was learning from Andy Budd and others about separating content from presentation, making the design flexible to handle different screen sizes and printers, and things like using CSS for rollovers rather than JavaScript actions.
Then, last month, I came across jQuery for the first time. The first thing that impressed me was the documentation. It’s not 100% comprehensive, but it’s a lot better than dojo’s documentation and good enough to get going straight away. The other thing that struck me, however, was the different focus it has. Using dojo, I felt as if I was using a programming language first and DOM stuff second. I’m not saying that that is the fault of dojo, but its efforts to make things more Java-like meant I didn’t need to break out of my mental model. Also, jQuery has the feel of a second wave of toolkit, building on the lessons learned from things like dojo and protoype.
jQuery most definitely focuses on the DOM first. It provides a lean, but well-formed set of constructs to search and manipulate DOM trees. The searching bit uses CSS selector strings (or XPath, but I like the CSS) which are now more familiar to me. My own focus has now shifted and I’m seeing the client-side application as primarily visual elements with behaviour attached, rather than application behaviour with views attached as I had been. I can see pretty clearly now how this fits in with an MVC-style and how I can connect it up with the messaging system we wrote earlier to reflect changes in our business domain objects.
A bonus is the large number of plugins that exist for jQuery, written by third parties. I am making use of the drag and drop features of the Interface plugin and already I am seeing a big reduction in the amount of code I am having to write to get things done.
Throughout the 25 years or so that I have been writing software I’ve looked at a lot of different languages. I’ve always believed that even if a language was not practical to use for whatever sort of problem I was trying to solve at the time, it is still valuable to be pushed into thinking about things in a different way. I’m starting to feel that JavaScript and jQuery are causing me to think in new ways
Technorati Tags: jquery, programming, javascript, Web2.0