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."

19 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 DigiShaman · · Score: 4, Funny

      Ouroboros?

      --
      Life is not for the lazy.
    2. Re:Javaception by afabbro · · Score: 4, Funny

      10 Write Browser in Java

      20 Write Javascript engine in Browser

      30 GOTO 10

      --
      Advice: on VPS providers
    3. Re:Javaception by game+kid · · Score: 4, Funny

      Now we just have to do all of that in a Minecraft map so the CPU collapses under its own virtual weight!

      --
      You can hold down the "B" button for continuous firing.
    4. Re:Javaception by Joce640k · · Score: 4, Funny

      Ummmm, Java != Javascript.

      I thought that bit of confusion was cleared up by now. I was wrong.

      --
      No sig today...
    5. 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
    6. Re:Javaception by sydneyfong · · Score: 4, Funny

      but it wouldn't be "virtually impossible"

      Exactly. It'd literally be virtually possible if you control the whole virtual machine...

      --
      Don't quote me on this.
    7. Re:Javaception by StripedCow · · Score: 4, Funny

      This is modded "funny", but actually this would be very useful. Because you could send the browser along with your HTML and be done at once with all browser-compatibility problems. Plus you could make browsers supporting other languages (e.g., Python, Haskell, you name it).

      Of course javascript would not be the appropriate target-language for this (I guess, due to efficiency issues), but the idea in itself is very interesting. A better target-language would be closer to the machine (no closures, and no garbage collection); the NaCl project might actually be a better candidate.

      I'm betting that somewhere, somebody is already writing a browser in NaCl.

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
  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. yo dawg by Anonymous Coward · · Score: 4, Funny

    So we heard you like java...

  4. Hey Bro... by bennomatic · · Score: 4, Funny

    ...I heard you like Java in your script so I wrote you a JVM in Javascript so you can run Java while you're scripting.

    Joking aside, this is not going to help the amount of confusion people have with regards to Java not being the same as Javascript *at all*.

    --
    The CB App. What's your 20?
    1. 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. Yo dawg.. I heard you like Java, so by D,Petkow · · Score: 1, Funny

    {yo,sup} dawg, I heard you like Java, so I put an Java Virtual Machine on top of your your Java, so you can compile Javascript while running the JVM.

  6. Yo dawg, I heard you like bloat by wye43 · · Score: 4, Funny

    ... so I've put bloat in bloat, so you can wait while you wait.

  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.

    1. Re:This is completely unnecessary. by jenic · · Score: 4, 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.

      Yes, that's why this is completely unnecessary.

  8. Re:This is nonsense. by Adrian+Harvey · · Score: 3, Funny

    It's like writing a C compiler in Bourne shell. The point is less about the name than about the complexity and absurdity.

    Isn't it more like writing a C compiler in C-shell - at least name-wise :-)

  9. Re:This is nonsense. by deniable · · Score: 4, Funny

    More like writing a Python interpreter in Perl. It'll work, but you'll feel a little dirty afterwards.

  10. Re:This is nonsense. by Oligonicella · · Score: 4, Funny

    That's a byproduct of Perl. What you write has nothing to do with it.