Languages like Java and Python compile it to an intermediate semi-digested form called "p-code" or "bytecode". Google Web Toolkit (GWT) takes Java source and compiles it into cross-browser JavaScript. Effectively, GWT uses JavaScript as its p-code.
But how good is JavaScript at being a p-code? Probably not great, because it wasn't designed as one -- it was designed as a general purpose programming language. Programming languages are designed to cater for the fact that programs are written by people. So, they have lots of syntactic sugar and usability features. P-code, meanwhile, is never written by hand and so needs no usability features. P-code is something designed to be quick and easy for a virtual machine to interpret and optimise. (See any course on compilers for the sorts of changes compilers make when converting source code to an intermediate representation.)
If JavaScript was an efficient p-code language, and if the "virtual machines" for it (the browsers) were efficient, then GWT applications would perform as well as Java or .NET applications. And yet, GWT actually feels a little sluggish.
So how could Google get around this issue? Well, it's in a uniquely good position to introduce a new p-code into browsers: a proper intermediate representation of JavaScript. The new p-code would be put into Firefox first presumably. GWT would then include some code in the sites it generates to see if the browser supports this new p-code. If it does, it would ask the server for blazing fast new p-code; if it doesn't, it would ask for sluggish old JavaScript. And if GWT sites (like most of Google) were blazing fast on Firefox and sluggish on IE or Safari, it wouldn't take the other browser manufacturers long to say "we'd like some of this new p-code goodness too please".
And then Google would have moved some way towards their goal of the Web being their "universal application platform", rather than the slightly hacky, messy, not quite fit-for-purpose application platform that browsers have always been so far.
Of course all this is purely speculation...
No comments:
Post a Comment