Bashing the JavaScript language is becoming an increasingly popular activity. It’s also an easy target because it’s a language most people over the age of 20 associate with pointless CPU hogging activity.
OK, so JavaScript used to have a bad rep. You’d think that four years or so after Google came out with GMail and Google Maps, we’d be past this. Well, apparently we’re not.
To quote Jonathan Edwards (JavaScript is good enough),
The web development community consciously chose to stick with a pathetically crippled technology to avoid having to change.
Ouch.
That sounds pretty damning, doesn’t it? Luckily, we’re on the Internet, where quotes never get taken out of context and are never used as the basis for an opinion.
In that spirit, here’s another quote, this time from Bjarne Soustrup.
“There are only two kinds of languages: the ones people complain about and the ones nobody uses”.
JavaScript has been with us since the mid-90s. No real programmers complained about it because, well, it was considered a toy language. Why waste time complaining about a language that nobody would take seriously when there were Really Important languages to complain about?
With browsers only allowing JavaScript in browsers to interact with the user and not the server it remained a toy. Something associated with unwanted pop-ups and interference with the user’s browsing behaviour.
Somewhere along the line a programmer at Microsoft was tasked with giving Outlook a web interface and immediately ran into the “JavaScript can’t do server interaction” restriction. This programmer built an extension to IE and (with other programmers) allowed IE to use JavaScript to communicate with the server without changing pages.
And *boom* AJAX was born.
Well, it wasn’t yet, but this is where it started. Around this time Microsoft had killed Netscape, considered itself dominant in the browser space and simply stopped developing Internet Explorer. The state IE was then is still the baseline for all web application development today. Keep that in mind, because it’s important. And bear with me, because I’m going to dive into history for a bit.
Internet Explorer 6 became the dominant browser world-wide. Netscape was dead, its source code open-sourced, but its community hell-bent on a re-write of the whole software. Joel Spolski wrote a (now famous) article on this in 2000 Things you should never do.
It would take years before a new browser emerged from this. In the mean time, other browsers were also being developed. And although compliance with standards was important, all the teams saw the importance of being compatible with IE6. Being compatible with the Microsoft DOM implementation was a lot more work than being compatible with the Microsoft JavaScript implementation (the Netscape SpiderMonkey engine having been reverse-engineered to JScript).
New browsers started to emerge and luckily, Microsoft did not take notice of this. The new browsers could render pages just like Internet Explorer, take plugins like Flash and generally take the place of IE. But what these browsers also did was implement the special functionality that IE used to communicate with the server while staying on the same page.
This was noticed in technical circles but only as an observation. Some software firms experimented with this new cross-browser functionality but it had almost zero impact until Google launched GMail. Once Google lauched GMail, everybody started paying attention. The entire ‘Web 2.0′ buzz started with the launch of GMail.
The ‘Web 2.0′ buzz has rightfully been seen as a new dom-com bubble. But that’s not what Google started. Google showed the world that there are new ways of leveraging existing web technology. After GMail, they upped the ante by bringing out Google Maps.
Since then the development of web-based software has jumped and outside of streaming media, all the developments have been in JavaScript. Even streaming media only uses other languages and runtimes (mostly Flash) only for streaming media. Every other aspect is implemented in JavaScript.
And why not? JavaScript is a simple but powerful language. Even in its mid-90s incarnation it’s more powerful than many ‘modern’ languages. Read up on Douglas Crockford’s classic paper on JavaScript The World’s Most Misunderstood Programming Language if you missed the memo.
JavaScript has its warts and I’ll be the first to admit that. However, the warts are small and it’s easy to work around them. Every language has its ups and downs. Programming C I wish for dynamic structures, programming Ruby I wish for type checking, programming JavaScript (ECMA-262) I wish for co-routines (and ‘watch’ in IE).
JavaScript is the language of the web and as people get used to it, it is starting to grow beyond the browser. There are web frameworks that use server-side JavaScript, One prominent Google employee recently ported the Ruby on Rails framework to server-side JavaScript.
JavaScript’s popularity is also starting to push its way into other frameworks by making the JS environment accessible to developers not working against DOM implementations.
A few years ago the JavaScript engines were limited to SpiderMonkey, its unofficial twin brother JScript, and a port to Java in the form of Rhino. Now we have those, but also Google’s V8, Adobe’s Tamarin, the TraceMonkey engine and Apple’s SquirrelfishCore.
JavaScript is growing and is growing fast. It might not be an ideal language, but which language is? It is a powerful language and one that has depth that is not immediately obvious to casual observers. It is also the language of the web, so either learn it or provide an alternative if you’re going to moan about it.