Coding Horror

programming and human factors

JavaScript: The Lingua Franca of the Web

Mike Shaver, a founding member of the Mozilla team, has strong feelings about how the web became popular:

If you choose a platform that needs tools, if you give up the viral soft collaboration of View Source and copy-and-paste mashups and being able to jam jQuery in the hole that used to have Prototype in it, you lose what gave the web its distributed evolution and incrementalism. You lose what made the web great, and what made the web win.

The radically open source, viral nature of the View Source menu is certainly a key part of the web's success. But that's only part of the story. The increasing maturity of the JavaScript implementation in modern browsers is the foundation of the web's present and future:

One ingredient of [Web 2.0] is certainly Ajax, which I can still only just bear to use without scare quotes. Basically, what "Ajax" means is "Javascript now works." And that in turn means that web-based applications can now be made to work much more like desktop ones.

Like many programmers, I initially wrote off JavaScript as a toy language. Even Douglas "my middle name is JavaScript" Crockford was guilty of this misconception:

When JavaScript was first introduced, I dismissed it as being not worth my attention. Much later, I took another look at it and discovered that hidden in the browser was an excellent programming language. My initial attitudes were based on the initial positioning of JavaScript by Sun and Netscape. They made many misstatements about JavaScript in order to avoid positioning JavaScript as a competitor to Java. Those misstatements continue to echo in the scores of badly written JavaScript books aimed at the dummies and amateurs market.

Regardless of your original feelings towards the language, JavaScript has come a long way since the bad old days of 1995. We've got CPU power to burn on the client; so much power, in fact, that even an interpreted, dynamic language like JavaScript can be a credible client-side development environment. The language has been standardized as ECMA-262, edition 3 since 1999, so there's now a reasonable expectation of compatibility across browsers.

More and more websites leverage JavaScript to stretch the boundaries of what the browser can do. The idea of browsing today's web with JavaScript disabled is almost quaint. With the success of so many startups based on nothing but JavaScript, HTML, and the server-side language of their choice, you'd think JavaScript would enjoy some hard-won respect by now. But I still see a lot of angst and ennui towards JavaScript from developers, even today. Scott Koon had a clever way of putting it:

[JavaScript won] by default. People wanted to build better web applications. Programming against Flash movies sucked. Javascript was already in all the browsers. If you're the last man left on earth, it doesn't matter how ugly you are when the women come to re-populate the planet.

Some programmers will do almost anything to avoid getting their feet dirty in the highly imperfect world of JavaScript. Vendors are all too willing to offer up their alternatives:

Despite all the pretenders to the throne, JavaScript isn't going away any time soon. JavaScript is the world's most ubiquitous computing runtime. It's time we learned to accept and embrace JavaScript rather than blindly fighting it. That doesn't mean we can't explore alternatives-- but the best way to transcend the limitations of JavaScript is to immerse yourself in those limitations. At least that way you know what you're fighting for, and what the alternatives really mean.

Is JavaScript annoying at times? Sure. Is it aggravating to deal with all the cross-browser issues you'll inevitably run into? Absolutely. Is debugging in the browser a pain in the butt? You bet it is, although FireBug helps. But JavaScript, in its way, is as groundbreaking as it is infuriating:

JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.

JavaScript is the lingua franca of the web. Ignore it at your peril.

If you're looking to get reacquainted with JavaScript, the best single resource on the web is still Douglas Crockford's site. I can also recommend Douglas Crockford's series of Yahoo videos, which provide an excellent overview of modern thinking in JavaScript.

You can download the companion slides for these presentations from the excellent Yahoo User Interface Blog.

There are some exciting JavaScript alternatives on the horizon. Some will be successful; some won't. In all the hubbub over new tools and new choices, don't forget that JavaScript remains an excellent choice for rich internet application development -- and as the existing lingua franca of the web, its success is guaranteed.

Written by Jeff Atwood

Indoor enthusiast. Co-founder of Stack Overflow and Discourse. Disclaimer: I have no idea what I'm talking about. Find me here: