JavaScript JVM runs Java
JavaScript JVM runs Java
Written by Mike James   
Sunday, 20 November 2011

The world of software is made slightly crazy because of the huge flexibility within any computer language. Once you have absorbed the idea of a compiler written in the language it compiles what else is there left to gawp at? But... a Java Virtual Machine JVM written in JavaScript seems like another level of insanity.

In fact it is a quite reasonable idea which is only made mad by the usual positions that Java, the top dog, and JavaScript the underling, usually occupy. Java is compiled not to machine code but to a special byte code which is then run on a virtual machine which is usually implemented in native machine code. There is, however nothing stopping an intrepid programmer from implementing it in any language you can name. The only real problem is that you need the implementation to be fast so that the byte code runs at an acceptable speed.



Until recently implementing a JVM in JavaScript would have been difficult because of efficiency problems but there have been huge speed increases in JavaScript engines. So much so that a lone coder, Artur Ventura, has implemented a large part of the standard JVM using JavaScript and you can check the code out on Github.

The motivation for this effort is put very well in Artur's blog. He argues that rather than build JavaScript into web browsers they should have a virtual machine so that any language can be used. As well as this advantage, he also points out that with a JVM type approach you get automatic sandboxing and simply sending the JVM to the server provides browser independent persistence.

It really does make much more sense to have a JVM build into the browser but failing that why not simply emulate the JVM in JavaScript which is built into every browser. This is just another aspect of the steady conversion of features provided by plugins to JavaScript implementations - codecs, pdf, zipping and so on.

After 6 months of work the result is BicaVM which, it is claimed, runs 60% of byte code. It hasn't been optimized as yet, but it does run on the iPad/iPhone and it supports a JNI interface to the DOM.

Will this result in anything practical?

Probably not. It is a proof of concept and the idea that the browser should be treated as a virtual machine in its own right isn't at all crazy. It is a little strange however to think of JavaScript actually running Java programs. Perhaps it is the assembler of the internet age.



More Information

Surf the Edge (Artur Ventura's blog)


Related News

JavaScript H.264 decoder


To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter or Facebook or sign up for our weekly newsletter.



Packt Skill Up Survey Shows Programmers Are Mostly Full Stack

Packt has shared the results of its recent Skill Up Survey. It joins the line up of reports that give us insights into the current developer population and reveals some interesting differences. & [ ... ]

Udacity Launches Data Scientist Nanodegree

Udacity has launched a new Data Scientist Nanodegree program. At an advanced level it has projects designed by Bertelsmann, Figure Eight, IBM Watson, Insight, Kaggle and Starbucks which map to the ski [ ... ]

More News

Last Updated ( Sunday, 20 November 2011 )

RSS feed of news items only
I Programmer News
Copyright © 2018 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.