Know the language? Why bother

I’ve spent the last few months really digging into jQuery. From in-depth reads of the source code, to examining plugin patterns, all things jQuery have fascinated me lately. The more I dig into the library, the more I have realized it has the possibility of wild power and abuse, mostly because it makes JavaScript look magical.

For even seasoned JavaScript veterans, the ease at which jQuery can do the seemingly impossible is awe inspiring. With a single command, you can select elements at least 3 different ways. That may sound simple, but it’s pretty far from simple under the hood. For instance, you can select an element by Id, class or a collection of elements. The following code illustrates these points:

jQuery('#myId');
jQuery('.myClass');
jQuery('div');

How on earth can jQuery pull this off? Under the hood, jQuery works hard to make your life simple. But, that doesn’t make it fast, or a good idea. And it’s not until you check the JavaScript profiler that you realize that jQuery isn’t magic. It isn’t doing anything you can’t do. It’s just making complicated DOM selection commands easy to access.

Douglas Crockford has long argued that JavaScript is fast, but it’s the DOM [Document Object Model] that makes JavaScript slow. I agree on this point, but without the DOM, JavaScript isn’t really all that useful. Sure, the XHR (ajax) request object is cool. But if you can’t display that ajax data, what’s the point?

Understanding how JavaScript behaves in all browsers is a daunting task to say the least. But really it’s how the DOM behaves in different browsers that is the more surreal challenge. There aren’t too many different ways a for loop or an if conditional can behave. This is where libraries like jQuery, MooTools and Dojo come in. Libraries make the DOM API more consistent for application code, essentially, they make my life easier and maybe yours too.

Libraries like jQuery, which has an amazingly low learning curve, excite people about JavaScript. It makes even total beginners appear good, and also dangerous. And that’s the fun part. jQuery lets you build an application that has an impact. That’s fun to use. And, that’s fun to build.

Cranky JavaScript veterans get frustrated by libraries. People rarely take the time to learn JavaScript, let alone a library API. Why bother reading the source code when examples are a Google away. This behavior leads to scary things, like including multiple libraries on the page or writing JavaScript code that crawls the entire DOM. These are the types of things experienced veterans shake their head over. Several times over the past few months I have reviewed other people’s code and been shocked by some of the things they are doing. I have shaken my head at them. Even scowled a little, or a lot. But it wasn’t until recently that I realized that it doesn’t matter.

It doesn’t matter if you have the most amazing grasp on JavaScript and can work on Crockford’s level. It doesn’t matter if you’re the most horrible coder and make bad decisions everyday. None of that matters. You’re skill in a language is a personal struggle. The public struggle is the experiences you’re building, whether or not your jQuery application engages its users. I want to get better at coding because I enjoy it. But that’s not universal. The only universal thing we can share is the community you build around a product, whether or not you know the language doesn’t matter, why bother.

  • juliomiy
    Very interesting argument and one I have to think through to decide whether I agree or not. It is true that the experience is the thing in the end. Let's face it, who is looking at the code (even if you can) when you are experiencing a web product. If the experience is good, then that is what brings you back. Nevertheless, you can say analogous things about those bridges that collapse due to heavy traffic or some weather event. If you are not keen on your craft whatever it is , there may be nothing to come back to when it collapses or fails to evolve because the code was unmaintainable or not extensible.

    Having the absolute grasp of anything doesn't translate directly into something tangible other then maybe a piece of paper called a college degree.
    Nevertheless it can in the right hands be what produces something valuable. Not sure what not caring or not having a grasp can produce.
  • It's definitely true that when it comes to civil engineering, the construction is a critical component. But in those cases, there isn't a worry that another company is going to come along and "eat your lunch".

    If the product never ships, there will be no site to enjoy... or ever come back too.

    I'm definitely not suggesting that if you know how to write it correctly, you should be lazy. But if you can bootstrap and achieve solid results, whether or not the code is perfect is secondary.. it's personal.
  • juliomiy
    I agree with the how you have explained it. I believe we probably think alike here. BTW - how are you handling all the comments on this blog?
    Sorry couldn't help it!
blog comments powered by Disqus