Javascript gets new lease of life

ctodx
22 September 2008

Over the past week or so, I've been using the new Chrome browser from Google -- not because I happen to be a geek fashionista and have to have all the latest gadgets, but to check out its JavaScript interpreter performance with real-world applications, including our own ASP.NET controls.

You may not have noticed but in the arcane world of JavaScript interpreters there has been some remarkable changes in the last few months. In essence, JavaScript interpreters have been gaining just-in-time compiler features, or JITters, just like we have in .NET.

This, to me, or indeed to anyone who has dabbled in JavaScript, is nothing short of amazing. JavaScript is a dynamic, weakly-typed, interpreted (or scripting) language with some very strong functional language features, despite its name implying Java and hence being statically-typed and imperative. The thought that this "freeform" quality can be compiled, and not only that but compiled just in time, seems contradictory and reeking of magic.

Luckily, not everyone is as gobsmacked as me, and they have been working hard to improve the performance of interpreting and executing JavaScript code. After all, most of the Web 2.0 sites out there are heavily using some form of AJAX, where the "J" stands for JavaScript, so a simple way to improve everyone's website performance is to improve the execution of the code.

There have been quite a few developments in the JavaScript interpreter space:

  • TraceMonkey: this is the new JITter/interpreter for the upcoming Firefox 3.1. Firefox 3.0 and earlier use an engine called SpiderMonkey. (In essence, TraceMonkey is SpiderMonkey plus tracing of the code so that sub-method blocks can be nanoJiTted.)
  • V8: the new JavaScript engine in Google Chrome.
  • SquirrelFish: the JavaScript interpreter for Safari 4.0, used in WebKit, the underlying HTML renderer in Apple Safari. (Confusingly, Google Chrome uses WebKit for rendering, but V8 for JavaScript code execution.)
  • Futhark: the engine for Opera 9.5 or later.

The interesting thing about these new interpreters is that they all blow IE's interpreters out of the water. And that includes IE8 beta, as well as IE7. It's becoming clear that if you want superior JavaScript performance for your web apps, you need to specify ABIE (Anything But Internet Explorer).

Currently there are two main JavaScript execution benchmarks: SunSpider (WebKit's benchmark for pure JavaScript, that is, no DOM processing), and the Google Chrome benchmark (again for pure JavaScript with no DOM). The difference between them is that the Chrome benchmark is very recursion intensive, something that TraceMonkey cannot do well at this stage. In Google's defense, using the DOM for anything intensive is going to be very recursion-oriented. (There is a new benchmark being developed that mixes in DOM processing as well, Dromaeo, but it's in its early days yet.) All the beta JIT engines perform extreemly well with these benchmarks, with V8 doing best at Google's own benchmark. IE is a no-show in some of the results since its interpreter has a tendency to crash with some benchmarks.

I do note that the fastest JavaScript interpreters/JITters are still in beta, but the whole area certainly looks very promising. I must admit that I hope the JavaScript execution engines become standalone, so that you can use your favorite browser and plug-in the engine you prefer. Perhaps a vain hope, but a hope nevertheless.

As for Chrome, and speaking as a user, it certainly seems to be very responsive on AJAX-abundant websites, including our own website, demo pages, and community site. The rendering speed is excellent too.

I look forward to yet more improvements in JavaScript performance. Certainly, as Scott Hanselman acknowledged, Silverlight may not yet have the upper hand yet in web applications.

3 comment(s)
RAUL TORTIMA
RAUL TORTIMA

That really shocks me!

If a Dev guy is standing in favour of Chrome, thats because its surely years ahead of IE (8) and Firefox. Indeed, I tested Googles's new browser and my impressions were quickness, and somewhat stability. However, as it happened to many (thousands) others users around the globe, I had several problems in my own applications, most of them written in asp.net using Dev components. I also noticed that Ajaxtoolkit provided by MS just doesnt work fine in Chrome (several chrashes all the time!)...

I wonder if MS will face this new challenge if will embed the V8 technology into IE8 (or maybe the next version after IE8), as a MS fan, I get really sad seeing it losing market-share everyday (either in Mobile field, browser field or, one might say, even in "Windows field")...

Huh, MS, do something, hire Google's architects!

23 September, 2008
Brandon Maness
Brandon Maness

@Raul: I watched Google's video over their release of Chrome, and they released all of the source code for Chrome and V8 hoping that the industry would follow suit, so Microsoft should have no problems implementing V8, as they have the source.. The question is, will they? I suspect that competitive pressure will result in some type of improvement in their browser. I guess time will tell.

23 September, 2008
Ivan  Bondy
Ivan Bondy

Google browser looks ok, but if other Google applications are of any indication Chrome will be in beta for next 2-3 years. Look at Gmail.

23 September, 2008

Please login or register to post comments.