Just another weblog

JavaScript as Byte Code – C#, Java, etc to JavaScript Compilers and Cross-Compilers

Posted by damuchinni on March 7, 2009

HTML is great for document layout. Its fast, clean and everyone knows it. Sprinkle a bit of JavaScript on that, and you have a nice interactive document. But HTML was never designed to be the basis for an application platform, and really is a pretty poor application platform. But despite the features of other platforms, and the number of times HTML and JavaScript is pronounced dead, something breaths life back into it.

It started with FireFox, and continued on with the awefully impressive Google Maps. Google has a large interest in keeping the browser alive and relevant. The longer it does so, the longer it has a platform on which to compete with Microsoft that is already deployed to 99% of the world’s user base. A “Google Flash” may not be feasible, because of the deployment nightmare involved, but as HTML evolves with offline capabilities, richer CSS and faster JavaScript engines (see Google Chrome), it becomes a platform that can largely compete with the rest.

And for this reason, Google has cleverly turned the browser into their own RIA platform. The “Google Virtual Machine”, as you may call it. To do this, they’ve leveraged the existing tools that Java has to offer, and created Google Web Toolkit – a Java compiler that can compile Java into cross-browser JavaScript. And on the client side, they’ve added Google Chrome. You can easily consider Google Web Toolkit and Google Chrome to be a full RIA platform, with JavaScript as the byte code transport. And not only that, but its an RIA platform fully backwards compatible with the existing deployed base of browsers.

Perhaps the most interesting thing is that Google Web Toolkit is not the only JS or cross-compiler. A variety for compilers have been built for this purpose. Microsoft Research has Script#, which compiles C# to JavaScript, and a bunch of projects use JSC, a cross compiler that compiles MSIL into JavaScript (and therefore any .NET language). With a whole variety of tools out there by different vendors to compile to JavaScript, it appears that JavaScript has become the new universal byte code. It can be processed by a whole variety of browsers, and produced by a variety of tools – one of the only computing platforms that that is true for.

And compiled JavaScript can also be pretty fast and make applications that are rich and look good. While it doesn’t compare to the offerings of Cocoa, WPF or Silverlight, the quality of application that can be achieved is good enough for most consumers. In the case of GWT, it is not only fast, but also efficient – and best of all, code can be shared amongst client and server.

I don’t like HTML as an application platform, and I am not very fond of running every application inside the browser chrome. But as business strategy and deployability have become increasingly important to me in my recent venture, an RIA application based around the native browser has become my platform of choice. Cross compilation, in my experience, has proven an effective way to make a very rich client that can even handle push-data.


One Response to “JavaScript as Byte Code – C#, Java, etc to JavaScript Compilers and Cross-Compilers”

  1. […] Read more:  JavaScript as Byte Code – C#, Java, etc to JavaScript Compilers … […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: