The Curse of JavaScript: Avoid the powertools until you understand the drill bits.

If I were a gambling man I would bet that everybody that has or is developing using JavaScript (today that is probably all if not most web developers) has started out one day by copying and pasting some script from some site that did something fancy such as a calendar or some nifty navigation menu. I would also bet that many JavaScript developers today still do that – even after many years of JavaScript development. See JavaScript is this funny little misunderstood language that started out back when the industry called it “DHTML” i.e. making your website a little more dynamic and interactive like desktop software. Today we don’t call it “DHTML” anymore since that is not as sexy as the terms “rich”, “web 2.0″ and “AJAX”. JavaScript succeeded in fusing itself to tons of online applications, across different industries, and both enterprise and consumer.

The problem with JavaScript really is how most web developers stumbled across it i.e. copying and pasting it from some other site. Unfortunately many still do that today which usually results in fairly poor JavaScript architecture and implementation. Any web developer worth their salt knows JavaScript, but they also don’t know JavaScript. It just became a common expectation that everybody can do it and as a result very few actually do it well.

Now we introduce all these JavaScript libraries and toolkits – mainly the ones that are easier to learn and also facilitate the copying and pasting. I’m pointing my finger at toolkits such as jQuery, Prototype, and Script.aculo.us. These are all great tools that make building web apps so much more productive, however these tools are also a curse.

These tools made it so easy for anybody to whip up some cool DOM manipulations and fancy Ajax loaders with little to no understanding of what is actually happening in the DOM nor within JavaScript code itself. You just needed some programming knowledge just to manage to hack and slash at it a bit and you end up with something awesome. Maybe you are wondering “but who cares Nael? I just need that feature for my site” and that is exactly the problem. Once you go down this path, it is pretty hard to do it otherwise when you are building something much bigger than a site with fancy navigation. What ends up happening this way is you eventually end up with a dozen different widgets and scripts from different vendors and other sites and you have no idea how they all interact together and what any of them are actually doing. Are they impacting page load somehow? are certain objects colliding with each other? But also the worse problem is you end up confusing the framework with the language. I have interviewed professional web developers that use jQuery who could not explain how $(“#some_id”)  worked but they just know it does. And that is just a simple example – just for that I would not hire you on my team.

I think today JavaScript is probably the best language to learn for anybody trying to get into web development. It’s simple enough to get you started today with nothing more than a browser and a text editor (both you already have on your computer). Also with the hundreds of open and available APIs you can build a ton of cool stuff without even figuring out how to install a database or even a web server. My advice for you is:

Forget the toolkits until you have seen the bad parts of JS
It is so easy to jump into jQuery or another toolkit, but you won’t learn JavaScript. You will learn jQuery and on your next project that is using something else you are SOL because you don’t know JavaScript.

Forget the toolkits until you have discovered the good parts of JS
There are a lot of great parts of JS that allow you to produce fairly powerful and flexible code patterns. Once you understand “this” and “closure” and can develop your own closures and high performance JS application you know you are almost ready for the toolkits.

Forget the toolkits until you have discovered that JS is a functional language
 The great thing about JavaScript is that you can go from an imperative style where statements change state to a functional style. When you start your learning you will start in the imperative style with global functions all over the place. Slowly you move onto the imperative object oriented style. But finally when you understand that everything is actually an object -even functions themselves- and that you can combine and mix objects together on the fly during execution then you can start looking at toolkits. Only then will you understand how all these libraries and toolkits such as jQuery, Prototype, Dojo, YUI, Sencha and tons of others work and only then can you really say you know JavaScript.

As a side note, but I’ll leave this for another post – beware of the magic black boxes that generate JavaScript for you just because you would like to avoid learning it. Its best to leave learning these power tools once you have understood the drill bits.

This entry was posted in front end architecture, Software, web apps. Bookmark the permalink.

One Response to The Curse of JavaScript: Avoid the powertools until you understand the drill bits.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>