bck2brwsr a JVM in Javascript

Hi I just found a really nice little project.

A kind of JVM in javascript. website example

As far as I understand it, the concept is like this. You provide your application as a Jar and when the website loads it checks if the client has a Java Plugin to run the jar if not the Jar is interpreted by a javascript JVM.

only interesting if it would be fast enough for games D:

Even if its not super fast, still seems like a nifty way to sneak applets into your page without a couple dozen security popups showing their ugly heads.

why not? you can use all the browser APIs like canvas WebGL and so on, would be easy for the libgdx guys to add another backend for this

That is interesting. From that website example I don’t think that java is being run on the client, it’s all in javascript. From the source code on this page (http://xelfi.cz/bck2brwsr/) there is no applet being executed.
The website is not very descriptive and doesn’t explain what it does very well. The javascript of that page is just 3 lines here:

        <script src="bck2brwsr.js" type="text/javascript"> </script>
        <script src="lib/archive.js" type="text/javascript"> </script>
        <script src="zip.js" type="text/javascript"> </script>

The bck2brwsr.js file is huge and appears to be a javascript VM. So i think that the jar files for the calculator are downloaded, maybe in the archive.js file, and read by the javascript jvm and executed. Crazy! I wonder how he was able to write a javascript VM?! My guess is that the VM is very slow, obviously it could only be an interpreter and not a Just In Time compiler. Pretty cool nonetheless.

did a little total unprofessional micro-benchmark.

did some math with sqrt etc. and it run approx. 30 times slower then “native” java. I guess using some cross compiler like GWT is still the preferred choice.

I read some time ago about asm.js with which they got nearly the same speed as our “native” JVM when they cross-compiled C++ to JS.

That’s interesting, and i guess that the performance would vary a lot from browser to browser depending on their js engine.
If only all of the browser vendors would fork openjdk and include it natively in their browsers. Then we wouldn’t have to deal with js at all and these hacky workarounds.