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.

 

javaandscript

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.

 

javaandscript

More Information

Surf the Edge (Artur Ventura's blog)

BicaVM

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.

 

Banner


Google Gets Closer To Killing Old Style Browser Plugins
25/11/2014

Google announced last year that it was planning to remove support for NetScape style plugins. Now the timetable for removing the feature from Chrome has been announced. How big a problem does it pose? [ ... ]



F# 4.0 Preview
02/12/2014

Microsoft has announced a pre-release version of F# 4.0 and the latest Visual F# Tools for Visual Studio 2015 Preview.


More News

Last Updated ( Sunday, 20 November 2011 )
 
 

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