Slashdot Mirror


JavaScript JVM Runs Java

mikejuk writes "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. 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. Notice this isn't a Java to JavaScript translator but a real JVM that runs byte code. This means it could run any language that compiles to byte code." Bonus: on Ventura's website is a set of visual notes from a talk he gave titled "My Language Is Better Than Yours."

11 of 234 comments (clear)

  1. Javaception by embolalia · · Score: 5, Funny

    So you could write a browser that supports JavaScript in Java, and then run the browser in itself?

    1. Re:Javaception by linuxgeek64 · · Score: 5, Informative

      It doesn't implement that much of the standard JVM.

    2. Re:Javaception by TheInternetGuy · · Score: 5, Funny

      Think before posting please.

      Seriously, if we are going to put that kind of requirement on posters, I will probably have to cancel my slash dot account

      --
      If my comment didn't sound as good in your head as it did in mine, then I guess we all know who's to blame
    3. Re:Javaception by alexhs · · Score: 5, Interesting

      So you could [...] run the browser in itself?

      Old news. Try chrome://browser/content/browser.xul in Firefox (doesn't seem to work as a clickable link, though).
      See here for more options.

      --
      I have discovered a truly marvelous proof of killer sig, which this margin is too narrow to contain.
    4. Re:Javaception by Zortrium · · Score: 5, Interesting

      Warning: shameless self-promotion ahead: I've also written my own JVM interpreter in JavaScript, which supports a substantial amount (perhaps most?) of the standard JVM, including threading, synchronization, reflection, rudimentary I/O, and most of the standard library classes (e.g., HashMap and Random). There's a lot of hackery involved but it's totally doable.

      Also, mine runs on Rhino, which is itself written in Java, so it's C (JVM) running Java (Rhino) running JavaScript (JSava, my interpreter) running Java (the user program). How's that for meta-execution?

  2. Anything which can be written in JavaScript ... by Musically_ut · · Score: 5, Funny

    ... will be eventually written in JavaScript. ~ Atwood's Law (circa 2007)

    --
    Never trust a spiritual leader who cannot dance -- Mr. Miyagi
  3. Re:Not A New Concept by bucky0 · · Score: 5, Interesting

    I feel like that sort of bootstrapping is normal. GCC's written in C, afterall.

    --

    -Bucky
  4. Re:Hey Bro... by Mitchell314 · · Score: 5, Funny

    Of course there's a difference. Java is defined as the language that runs on top of javascript. This is simple, it's just a compiled language that runs atop of an . . . interpreted . . . of an interpreted . . . it's a compiled . . . it's a compiled language that runs on an interpreted . . . okay guys, really, what the fuck? I think I just heard the sound of part of the universe and a good chunk of logic spontaneously imploding. I'm going to go cry now, and thanks to these dipshits my tears will probably fall sideways upwards now.

    --
    I read TFA and all I got was this lousy cookie
  5. DOM-Interface for byte code by maweki · · Score: 5, Interesting

    For years I've been saying that we need a DOM-Interface for byte code in Browsers and everytime I get downvoted. Nice to see people exploring in these directions now.

    "we do need DOM-Bindings for Bytecode now more than ever. It would be so great to write code in a language of my choice and compile it to Browser-Bytecode with DOM-Bindings. This would make it possible to deliver more proprietary code without making browser-plugins or something similar."

    "What we really need are DOM-Bindings for Bytecode. So you can use every language you want that is capable of compiling to bytecode and send it to a browser. This would make it easier for the developer and bytecode is easier and faster for the browser to execute."

  6. Really? by aglider · · Score: 5, Informative

    This

    This means it could run any language that compiles to byte code.

    shoud read as
      This means it could run any language that compiles to Java byte code.

    --
    Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
  7. This is completely unnecessary. by DamnStupidElf · · Score: 5, Funny

    Fabrice Ballard already wrote an x86 emulator in javascript. Just install the standard x86 JVM inside of that and you're good to go.