Sergio and the sigil

Give JavaScript a chance

Posted by Sergio on 2008-05-03

Let me be the first one to admit taking way too much time to give in and embrace JavaScript. This language is arguably one of the most widely deployed and most misunderstood at the same time. There must be an award somewhere for this amazing feat.

I don't know what causes developers to avoid JavaScript in this day and age. I mean, back in 1995 when it was being introduced, I could understand the disdain. Back then it was a new language with a poorly chosen name (no, ECMAScript doesn't help either) and, probably the biggest problem, a lot of pain associated with the bug-laden and incompatible browser implementations of both JavaScript and the DOM.

Today, on the other hand, I don't see a really justifiable reason for a web developer avoid writing rich JavaScript. We have a very viable install base of browsers with decent implementations of JavaScript and the DOM (not perfect nor uniform, but doable,) we have better development tools, incredible browser extensions, debuggers, unit testing helpers, documentation generators, and, what in my opinion made JavaScript a true professional language: great libraries.

My hat goes off to Prototype.js, Scriptaculous, jQuery, Dojo, YUI, ASP.NET Ajax, etc. The folks behind these libraries really helped JavaScript adoption and boosted developer productivity. They pushed the language to its limits and amazed us with what could be accomplished with a language we used to simply copy, paste, adjust, and pray it worked.

I read this somewhere that I can't remember now, but it's a perfect analogy: You wouldn't write .Net code without the BCL, so why write JavaScript without good libraries?

I see a lot of effort being put into, once again, taking JavaScript away from the developer's code editor, and I honestly don't like that.

Things like GWT, Volta (me too, me too), Script#, and RJS (plus helpers) sound like too much work only to not let developers use JavaScript directly. Why do I need a to write code in one language just to produce code in another language that is perfectly usable? JavaScript is not Assembly, MSIL, or Java byte-code. We can actually write, document, test, debug, version, and deploy JavaScript.

I don't know what is your reason not to use JavaScript but maybe it falls into one of the following categories.

  • You think JavaScript is hard: It's not, I swear. Think about this for a second, JavaScript is considerably smaller than C#/Java/Ruby/VB. Maybe the problem you have is that you are being fooled by the curly braces and thinking JavaScript relates to C or Java or C#. JavaScript only has superficial similarities with those languages. The best advice I can give is to get yourself a good JavaScript book. There aren't many good books but I'll leave links for a couple at the end.
  • It's a lot of effort to get anything done: Just pick a JavaScript library and play with it. There's a wealth of solid solutions and widgets for all sorts of things.
  • I like to write all my code in C# (or VB, or Java, etc) I don't want to get into the debate about polyglot programming in this post but afraid you're setting yourself up for grief and failure. You don't want to ride your mountain-bike in the sand dunes or drive our sedan on the train tracks.
  • But my users can turn off JavaScript in their browsers: That never stopped people from writing VC++/MFC, Java, .Net, or even VB6 applications. You'll have the same problem if you're letting your JavaScript be generated on your behalf.

If you think you need to brush up you JavaScript but don't have a lot of time right now, I'd recommend at least watching the videos linked below.

Links

Libraries

Books

Tools

Videos