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

234 comments

  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 Anonymous Coward · · Score: 1

      I hope it supports applets at least. Since applets are rarely supported by the browser itself.

    3. Re:Javaception by DigiShaman · · Score: 4, Funny

      Ouroboros?

      --
      Life is not for the lazy.
    4. Re:Javaception by cb88 · · Score: 3, Informative

      Sun already did that with HotJava it supported javascript.

    5. 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
    6. Re:Javaception by KarolisP · · Score: 1

      I have a feeling it would take a bit more lines than that :D

    7. 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.
    8. 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...
    9. Re:Javaception by Anonymous Coward · · Score: 1

      The article is about a JVM that is written i Javascript. Think before posting please.

    10. 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
    11. Re:Javaception by DrXym · · Score: 1, Insightful

      It couldn't either. Stuff like threads would be virtually impossible to do on Javascript, even with web workers. I suppose what it might do in the dim and distant future is allow tools like GWT to deploy jar files straight to web sites without any of the usual nonsense of translating Java source into umpteen variations of JS to cope with browser quirks.

    12. Re:Javaception by Robert+Zenz · · Score: 1

      You mean a Mincraft map with Redstone-circuitry building a 32-bit processor + OS + Browser + JavaScript + BicaVM running Minecraft with that map? Uhh...I feel dizzy...

    13. Re:Javaception by Anonymous Coward · · Score: 2, Insightful

      Not true! Since you're performing the execution of the byte code yourself you could implement the time slicing yourself. It wouldn't be easy sure - but it wouldn't be "virtually impossible". It'd all run within a single thread in the browser but emulating multiple threads in your JVM.

    14. 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.
    15. 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.
    16. Re:Javaception by deniable · · Score: 1

      Geeks: making Marketing's screw-ups reality since the beginning of time.

    17. 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.
    18. Re:Javaception by DrXym · · Score: 2

      Well I suppose Java did come from that situation a long time ago - so called "green" threads. So I concede you could probably use some crappy timer / yield type model. The timeslice / yielding would be the issue and all the synchronization / deadlock issues would be fun too.

    19. Re:Javaception by Lennie · · Score: 1

      I think a large performance gap will be fixed when JavaScript engines support type inference. JavaScript is dynamically typed, which is slower. But if the engine can figure out what type a variable is, it can optimize for that and be just as fast as typed lnaguage JIT VM:

      http://blog.mozilla.com/futurereleases/2011/11/10/type-inference-to-firefox-beta/

      --
      New things are always on the horizon
    20. Re:Javaception by somersault · · Score: 1

      Bonus points if you can do networking using multiplayer characters in mine carts.

      --
      which is totally what she said
    21. Re:Javaception by Anonymous Coward · · Score: 3, Interesting

      If you don't care about the quality of your multithreading (and don't care if the whole thing just runs on one core of your multicore system), then writing threads into your JVM shouldn't be hard (assuming the hard part of writing the JVM has already been done, of course): Just have an interpreter for each thread (holding all thread-specific data), and then just cycle through all threads, letting each non-blocked one execute a fixed number of instructions before turning to the next (the interpreter class would have a method execute_instructions(number_of_instructions_to_execute) which would be called). Since, from the JVM's point of view, everything would run strictly synchronous, synchronization would not be an issue. Note that you'd not even use a timer.

    22. Re:Javaception by Anonymous Coward · · Score: 1

      First post!111!!

    23. Re:Javaception by DrXym · · Score: 3, Interesting

      You'd have to use timers. The JS is running in a browser. If you let code for as long as it likes the browser won't be responsive and eventually will start complaining to the user about the fact. The JS would have to execute a bit of code, find some convenient point to halt, set a timer, drop out back to browser and then execute some more when the timer fired. Even if there was just one thread. When you have more than one thread you'd have to do the same for multiple threads via some kind of scheduler.

    24. Re:Javaception by Anonymous Coward · · Score: 2, Interesting

      A more interesting loop would be this:

      Write Editor with Lisp interpreter in C. (check)
      Write Browser with JavaScript interpreter in Lisp. (partial check -- I don't think w3 supports JavaScript)
      Write JVM in JavaScript. (check)
      Write x86 emulator in Java. (check)

      Now run the editor on your x86 system, run the browser in that editor, run the JVM in that browser, run the x86 emulator in that JVM, repeat.

    25. 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?

    26. Re:Javaception by jonbryce · · Score: 1

      I think the idea is that the browser could run itself inside a window.

    27. Re:Javaception by Anonymous Coward · · Score: 0

      You could incorporate rhino (http://www.mozilla.org/rhino/) with your java brower.

    28. Re:Javaception by EdgeCreeper · · Score: 1

      Or this?

    29. Re:Javaception by Anonymous Coward · · Score: 0

      Whoosh. (Aside: I came to make GP's joke. I was too late.)

    30. Re:Javaception by larry+bagina · · Score: 1

      Sun used to have a browser written in Java. It was supposed to be really awesome but when I tried it (in 2000 or so), it was ugly and outdated.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    31. Re:Javaception by Anonymous Coward · · Score: 0

      Yo dawg I herd you like Java so we put Java in your Java so you can code while u code.

    32. Re:Javaception by Anonymous Coward · · Score: 0

      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.

      Finally a way around the Unity app-menu!

    33. Re:Javaception by Anonymous Coward · · Score: 1

      The JS is running in a browser.

      You don't need a browser to run javascript. No clue where you got that idea from.

      Actually, any application that has scripting requirements can embed javascript, for example (but not limited to) games, gameservers, and a certain NoSQL database. You could go as far as running javascript stand-alone, offering only some basic IO functionality.

    34. Re:Javaception by nschubach · · Score: 2

      For instance...

      See: http://nodejs.org/

      JavaScript outside the browser.

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    35. Re:Javaception by Anonymous Coward · · Score: 1

      Reminds me of the claim by the marketing department of one company that their virtual machine executed code 1.5 times faster than native compiled code on the same platform. So in theory, having a chain of virtual machines running instances of that virtual machine would execute code with exponential performance limited only by the number of virtual machines in use.

    36. Re:Javaception by Anonymous Coward · · Score: 0

      40 PROFIT

    37. Re:Javaception by DrXym · · Score: 1

      I never said you needed a browser to run JS, but that is where it is typically run.

    38. Re:Javaception by Rysc · · Score: 1

      That isn't shameless self promotion, that's topically awesome.

      --
      I want my Cowboyneal
    39. Re:Javaception by Rysc · · Score: 2

      How long before CPU benchmarks are measured in how deeply you can nest this and still achieve some fixed number of results per second with a computationally intensive task?

      "Doom3 is running at 30FPS... inside 8 levels of emulation."

      --
      I want my Cowboyneal
    40. Re:Javaception by Darinbob · · Score: 1

      Threads aren't hard. You don't need OS support for threads, and if you're at the byte code already then it's trivial. Essentially the Javascript is just emulating a computer.

      Really, there's nothing new or special about this trick it's been done for decades in other languages. All it shows is that Javascript isn't as primitive a language as some may have thought.

    41. Re:Javaception by Darinbob · · Score: 1

      Ah, you may be missing the key point there. The Java inside a JVM written in Javascript is not intended to actually be a practical thing to do in a browser. The performance may be too slow even single threaded or be highly dependent upon the performance of the Javascript engine. This is just a cool hack and not a breakthrough to help out some IT team. The JVM has to be written in some language, so why not Javascript?

    42. Re:Javaception by Spudley · · Score: 2

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

      And if you run it in a modern browser, it would still run faster than javascript in IE8.

      --
      (Spudley Strikes Again!)
    43. Re:Javaception by Anonymous Coward · · Score: 0

      Why would you have to use timers? You run a threads byte code so you decide when to stop it and start executing another ones.

    44. Re:Javaception by recharged95 · · Score: 1

      So, what takes 10secs to startup in JavaScript will take 10mins in the Java version under the Javascript engine.

    45. Re:Javaception by DrXym · · Score: 1
      In browsers you would have to. Browsers are event based - GUI events and timers cause JS to be executed. The browser executes JS associated with an event and synchronously waits for it to complete before it can do anything else (e.g. update the DOM / layout). If the JS never returns the browser becomes unresponsive and eventually complains to the user about the JS and asks if it should be stopped. So if you were running a JVM in that environment you would most likely have to find some break point during JVM execution to halt execution, save state, set a timer and return to the browser. When the timer fired you would wake up again, restore state and continue for another timeslice.

      I realise JS doesn't have to run in a browser, but I would argue that the most useful place for a JVM over JS would be in a browser. It doesn't make sense to me to want to run a JVM over JS on a server or in a standalone JS script because in either place it would be likely be easier to install and invoke a proper JVM which wouldn't suffer from any limitation or slowdown associated with running over JS.

  2. First I was like D: .... by Anonymous Coward · · Score: 0

    then I was like :D

    Sounds lame for about 2 seconds, then it hits you... run software in a browser with no plugins (albeit at a very low rate of speed...)

    1. Re:First I was like D: .... by Joce640k · · Score: 1

      If it means not having the Java runtime installed on my machine then I see no downsides to it.

      --
      No sig today...
    2. Re:First I was like D: .... by deniable · · Score: 1

      Microsoft JScript JVM anyone? I can see 'tweaks' to this JVM happening a lot. Then it's write once, test everywhere you can find, pray. Anything web guys can mess with...

    3. Re:First I was like D: .... by Lennie · · Score: 2

      Actually, if the engine to run javascript is loaded from the website where your java app is downloaded from there is a much higher chance it will work.

      It is what a lot of java programs already do, deliver their have their own JRE in a directory.

      --
      New things are always on the horizon
  3. 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
    1. Re:Anything which can be written in JavaScript ... by Anonymous Coward · · Score: 0

      I'm pretty sure we're ready to generalize that by adding the corollary, "Anything can be written in JavaScript."

    2. Re:Anything which can be written in JavaScript ... by Anonymous Coward · · Score: 0

      ... and now you have two problems. -Jamie Zawinski [paraphrased]

  4. Not A New Concept by DERoss · · Score: 3, Interesting

    Forty years ago, a major software system for operating unmanned space satellites for the U.S. Air Force was written in a language called JOVIAL J4. The JOVIAL J4 compiler was itself written in JOVIAL J4.

    Originally intended for a lifetime of 10-15 years, the system was actually in use for 20 years.

    1. 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
    2. Re:Not A New Concept by afabbro · · Score: 3, Informative

      Forty years ago, a major software system for operating unmanned space satellites for the U.S. Air Force was written in a language called JOVIAL J4. The JOVIAL J4 compiler was itself written in JOVIAL J4.

      Hardly unusual. GCC is written in C.

      This is not quite the same thing.

      --
      Advice: on VPS providers
    3. Re:Not A New Concept by Joce640k · · Score: 1

      Nothing unusual about that...most C compilers are written in C and the first C++ compiler was written in ... C++.

      --
      No sig today...
    4. Re:Not A New Concept by TheRaven64 · · Score: 4, Informative

      Most compilers work like that. The Java compiler is written in Java (as you discover when it crashes and you get a Java stack trace). Smalltalk was written in Smalltalk and even modern Smalltalk implementations like Pharo are written in Smalltalk. The typical trick is to write a small compiler for a subset of the language in another language and then use it to compile the rest of the compiler. For example, the core of the Squeak VM is written in a subset of Smalltalk that is fairly easy to translate to C. This is then translated to C and compiled with the target system's C compiler. You then have enough of the VM running for it to load the rest. Early Pascal compilers did the same. In the '70s, having the compiler written in the language was considered a test of whether something was a 'real' language (since then we've learned that languages that are good for writing compilers are not necessarily good for other things. Well, some of us have...)

      --
      I am TheRaven on Soylent News
    5. Re:Not A New Concept by lucian1900 · · Score: 2

      Even CoffeeScript is self-hosted.

    6. Re:Not A New Concept by wed128 · · Score: 1

      No it wasn't; if it were, how was it compiled?

      likely C++ features grew in C compilers (like cancer), sort of like how C99 features were implemented in GCC.

    7. Re:Not A New Concept by Anonymous Coward · · Score: 0

      Lookup bootstrapping a compiler.

    8. Re:Not A New Concept by Just+Some+Guy · · Score: 4, Interesting

      The JOVIAL J4 compiler was itself written in JOVIAL J4.

      Want something really mind-blowing? PyPy is a Python interpreter written in Python. It includes a tracing JIT compiler to optimize hotspots as it runs to get about 5 times faster than the native C Python. I've used it and I still can't quite believe it.

      --
      Dewey, what part of this looks like authorities should be involved?
    9. Re:Not A New Concept by Anonymous Coward · · Score: 0

      the first C++ compiler was written in ... C++.

      So how did they compile it?

    10. Re:Not A New Concept by Anonymous Coward · · Score: 0

      Uh, duh... No shit, the original assembers were written in assembly. There were punchcard programs for compiling punchcards.

      Nothing special about any of that, it's practically a requirement of running any computer since computers were invented.

    11. Re:Not A New Concept by Anonymous Coward · · Score: 0

      Feh!
      I can write a Javascript interpreter in Javascript.... in just one line!

    12. Re:Not A New Concept by Anonymous Coward · · Score: 1

      Not completely true. PyPy is written in RPython, which is a restricted subset of Python that is easily translatable to C code. Then this C code is compiled into a VM with a kickass JIT compiler.

      The PyPy project is actually designed to make writing virtual machines with a good JIT easy to do in its restricted subset of Python. The PyPy interpreter is a proof of concept of writing the python virtual machine inside of the PyPy environment.

    13. Re:Not A New Concept by wondershit · · Score: 1

      There is a JVM targeted for research named Maxine that is written in—you guessed it—Java. It needs to be bootstrapped by another JVM in order to compile itself with its JIT compiler and after that it runs by itself. I recently attended a talk by one of its developers and it looks very interesting.

    14. Re:Not A New Concept by Anonymous Coward · · Score: 0

      How is this possible? How was the first c++ compiler compiled, if there was no c++ compiler existing before it was compiled?

    15. Re:Not A New Concept by Darinbob · · Score: 1

      This is traditional. Many (maybe most) compilers are eventually written in themselves. This is particularly true of older compiler where the new language is more expressive than the older ones, so certainly you'd prefer writing Pascal in Pascal than Pascal in Fortran.

      This has changed in the modern era for some reasons; it's nice to have a common backend with different front ends for different languages, such as with GCC, and porting the backend optimizers for each language is cumbersome and makes maintenance a pain (find a bug in the C backend then you'd have to see if the same bug was in the C++, Pascal, Fortran, Java, Euler, Eiffel, or whatever backends).

      Of course the first compiler has to be written in a different language. This is what trips up students because they hear "Ada is written in Ada" and start getting dizzy. But if they learn instead "Ada is written in Pascal first and then later written in Ada, and then later written in Ada again, and then later in Ada again, and so forth". The first C compiler was not written in C.

      Interesting too are things like Forth cross compilers written in Forth (often called meta compilers or meta Forths). There even the assembler code is written using Forth syntax, and the Forth code will hop back and forth between different domains: target run time, target compile time, host run time, host compile time.

    16. Re:Not A New Concept by Darinbob · · Score: 1

      The first C++ was CFront. Which was written in C and produced C output instead of assembler or object code. But there are people out there who seem to feel that CFront wasn't really a compiler and just a simple translator (untrue), so I suspect they may think that the first "real" C++ compiler was in C++ but they're just messing up the definitions.

      C was not a proper subset of the very first C++ language semantics (mostly with respect to typing rules), so you can't even say that the first C++ was compiled with a subset of C++.

    17. Re:Not A New Concept by Darinbob · · Score: 1

      Writing a compiler is a good test of being able to support relatively complex data structures, complex algorithms, and requires a fair amount of coding organization. A language that fails some of these will make writing a compiler in itself a bit painful. It's reasonable proof that a language is general purpose.

      Practically though, the reason many wrote a compiler in itself is that they preferred the new language to the old language. I'd much rather write a newer compiler in C++ than in C (or at least a subset of C++) just because it makes a lot of things easier. C is typically used for the pragmatic reason that it's the C compilers are the most commonly available. When GCC was new just about every machine it was ported to had a C compiler already, and just about every new architecture coming out has a C compiler from a vendor soon enough. The intent of GCC was was that end users could download the sources to their machine and compile it there.

    18. Re:Not A New Concept by larry+bagina · · Score: 1

      In October of 1979 I had a preprocessor, called Cpre, that added Simulalike classes to C run- ning and in March of 1980 this preprocessor had been refined to the point where it supported one real project and several experiments.

      ...

      Cfront was originally written in C with Classes (what else?) and soon transcribed into C84 so that the very first working C++ compiler was done in C++. Even the first version of Cfront used classes heavily, but no virtual functions because they were not available at the start of the project.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

  5. yo dawg by Anonymous Coward · · Score: 4, Funny

    So we heard you like java...

  6. 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
    2. Re:Hey Bro... by Anonymous Coward · · Score: 1

      Those who care know there is a difference, those who don't ask for a mug...

    3. Re:Hey Bro... by Anonymous Coward · · Score: 0

      A language is just a language. The interpreted/compiled descriptor just says how it is normally used.

    4. Re:Hey Bro... by Anonymous Coward · · Score: 0

      Calling Java a compiled language is quite a stretch. The java compiler just compiles to bytecode in a completely unoptimized fashion that reduces some small overheads the Java Virtual Machine (in other words: an interpreter) would otherwise have. So what he's really doing is running a bytecode interpreter in an interpreted language.

    5. Re:Hey Bro... by PCM2 · · Score: 2

      Hey, 1996 calling. Does our interpretation of how Java works still fit? Because if you're not using it anymore, we'd like it back.

      --
      Breakfast served all day!
    6. Re:Hey Bro... by DrXym · · Score: 1

      It is a compiled language. It's compiled into bytecode. Whether it's optimized or not is a function of the compiler implementation. It's true the default compiler doesn't do much optimization,but that doesn't mean it is not possible. The Eclipse compiler and Jikes have some optimization settings and you always run a file through proguard too.

    7. Re:Hey Bro... by deniable · · Score: 1

      They're working on JIT compilers though. Not sure when they'll be ready. It will allow the local machine to optimize the byte-code for local conditions.

    8. Re:Hey Bro... by deniable · · Score: 1

      Just run it inside VMWare or Virtual PC and you won't have any problems.

    9. Re:Hey Bro... by TheRaven64 · · Score: 2

      What is this, 1998 appreciation day? They were working on JIT compilers for the first release of Java! Modern JVMs all use JIT compilation extensively. The only ones that don't are ones designed to run on very small embedded systems, which use Jazelle, which is basically a Java bytecode decoder on the front of an ARM chip that executes most bytecodes directly and traps on the difficult ones.

      --
      I am TheRaven on Soylent News
    10. Re:Hey Bro... by Anonymous Coward · · Score: 0

      If you want your head to explode even harder, realize that JavaScript code is also compiled to some extent as well now.

      I think I might need to call an ambulance, I feel my brain bleeding.

    11. Re:Hey Bro... by Anonymous Coward · · Score: 0

      Why not both?

    12. Re:Hey Bro... by Trails · · Score: 1

      ...so I get a mug?

    13. Re:Hey Bro... by JSBiff · · Score: 1

      "my tears will probably fall sideways upwards now."

      Even worse, they just stay at the surface of your eyes and pool in your eyes so you can't see, which makes you cry more, and then you see even worse. . .

    14. Re:Hey Bro... by Anonymous Coward · · Score: 0

      Exactly. cf UCSD P-System

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

    1. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 1

      Even sandboxed in a VM, I'd be inherently wary about executing server-compiled byte-code. Isn't this why we got rid of Flash?

    2. Re:DOM-Interface for byte code by xororand · · Score: 1

      more proprietary code

      How is this progress? Why would we want to go backwards?
      If anything, we need less proprietary code on the web.

      We should have learned from the consequences of lock-in by now. See: Flash, Java applets, ActiveX.

    3. Re:DOM-Interface for byte code by devent · · Score: 4, Insightful

      Yes, would make sense, wouldn't it? Instead that every browser have to interpret the slow JS language (yes, JS language is slow to interpret, because of the design choices. Just watch some of Doug Crockford videos), we could all just agree on a byte code standard like the Java byte code standard.

      Then you could develop web applications in your choice of language and not just in JS. On the server you upload just the byte code, like the compiled Java source code (.class).

      For example, you could develop in Ruby, Python or Java, and compile the code to the byte code for browsers. Then you deploy the byte code on the server.

      But the web-developers are so stubborn with their JS language, I don't know why.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    4. Re:DOM-Interface for byte code by martin-boundary · · Score: 4, Interesting

      I'd rather have source code than byte code. The web was built on visible code like HTML. Do you think it would have exploded if people couldn't look at the source to figure out how some neat web page was written?

    5. Re:DOM-Interface for byte code by hpoul · · Score: 1

      well, somehow google thinks javascript IS bytecode :) they compile java to javascript (GWT) and (until it's supported in any browser) their own language http://www.dartlang.org/ (dartc) .. so the missing part is not the browser-bytecode.. simply write your compiler to output javascript instead of bytecode ;)

      --
      Find me at http://herbert.poul.at
    6. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 0

      You get downvoted because running remote bytecode in web browsers is a stupid idea. There's nothing stopping you writing the interpreter in javascript if you wish -- knock yourself out!

    7. Re:DOM-Interface for byte code by devent · · Score: 2

      What have that do to with your argument? Libraries like JQuery will still be open source.
      I would rather think that Web exploded because it's build on open technologies and open source software.
      And if the Byte Code is a standard, it's as simple as a editor or disassembler to use to see the code.
      Also, I don't think you can read that code: http://code.jquery.com/jquery-1.7.min.js

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    8. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 1

      Um, so? (sincere question, not being a prick.)

      The web already exploded. We're now well past that DIY point.

      Yes, sure some enthusiasts still code their own, but we're way past where knowing some HTML was how you got a site up. Individuals have long moved to templates - blogs, wordpress, facebook, tweets and whatever.

      Browser incompatibility successfully killed the original DIY plan. I'm nostalgic and sentimental about it, but it's gone. Coding is a pro game now. So why not byte code?

    9. Re:DOM-Interface for byte code by jimicus · · Score: 2

      Of course we had that with Java applets a few years ago - they didn't really take off.

      A number of reasons for this exist: first is there were a couple of implementations of the JVM and they weren't all compatible with each other. Second is that the same version of the same JVM (Sun's at the time) exhibited subtly different behaviour on different platforms - meaning it was fantastically easy to wind up with something that only worked well on one or two platforms. ISTR font handling in the UI was a big killer - there were a few ways to do it and unless you did it a particular way, you wound up with an applet where the widget text was only readable on Windows.

    10. Re:DOM-Interface for byte code by chrism238 · · Score: 1

      "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." You're not Andrew Tanenbaum by any chance, are you?

    11. Re:DOM-Interface for byte code by Bomazi · · Score: 1

      It is not 100% working yet but it already exists. There are standard java bindings for the DOM. As an example, rhinohide allows java applets to access the DOM via the standard bindings thanks to a javascript bridge. In this demo, which should work in firefox, a java applet modifies the document it is embedded in via this mechanism.

    12. Re:DOM-Interface for byte code by the+entropy · · Score: 1

      Yes, but what is different about what the first poster in this thread was suggesting is for that bytecode to have DOM bindings. Java applets were self-contained applications that ran in a window within the page and touched nothing outside of that(and had to do all the drawing themselves and were completely inconsistent with the rest of the page with regards to look and feel as a result).

      What is being suggested here is something that would replace javascript that would interact with and modify the whole page through a DOM interface, completely unlike an applet and much more useful.

    13. Re:DOM-Interface for byte code by jimicus · · Score: 1

      Ah, I hadn't fully registered that.

      You're quite right - but then you immediately start to run into sandboxing & security issues.

    14. Re:DOM-Interface for byte code by the+entropy · · Score: 3, Interesting

      How is what we have now with things like minified js any different than bytecode? Have a look at the source for gmail, or the minified version of jquery. You need analysis software to have any hope of making any sense of it and it's exactly the same then as a bytecode decompiler.

      jQuery is open source, which means you can get the non-minified version and read that to know how it works, but I would dare anyone to make sense of the 100s of KBs of obfuscated js that is the gmail interface(or quite a few other popular products and services for that matter).

    15. Re:DOM-Interface for byte code by Lennie · · Score: 1

      Writing Java VM in JavaScript, is like downloading de JRE to the browser to run some applets. Is that a good thing ? Or a bad thing ?

      It would mean it is a lot more compatible, but it would also be slower than just use JavaScript.

      --
      New things are always on the horizon
    16. Re:DOM-Interface for byte code by Lennie · · Score: 1

      I think that is called CoffeeScript.

      --
      New things are always on the horizon
    17. Re:DOM-Interface for byte code by TheRaven64 · · Score: 2

      Even sandboxed in a VM, I'd be inherently wary about executing server-compiled byte-code

      Why is this any different from executing server-supplied source code?

      --
      I am TheRaven on Soylent News
    18. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 0

      Oh, I never knew you could read binary+media formats. That's some skill man.

      The web has changed. This is NEEDED more than ever. JavaScript is way too slow.

    19. Re:DOM-Interface for byte code by gbjbaanb · · Score: 1

      we could all just agree on a byte code standard like the Java byte code standard.

      hahahahahahahhahahaaaaa.

      agree on something like this, oh boy, that's a good one. I mean, the old Java standards were incompatible. Even Microsoft's .NET has differences between C# and VB.NET (ie - those 2 languages have different features that the other doesn't have).

      I think the web devs are stubborn with JS because its there, it works and they can get on with work in stead of arguing the toss over which language is better - the lucky buggers only have 1.

    20. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 0

      Mod parent up.

      Free software/open source is about an idea. It's a promise from the developer that you will be able to use, study, modify and redistribute the program. Look at Python's bindings to Qt - technically it's open source, but what is distributed as "source" is obfuscated and auto-generated code. Neither the license nor Python's scripted nature help here.

    21. Re:DOM-Interface for byte code by tepples · · Score: 1

      Flash hasn't been proprietary since the Open Screen Project relicensed the SWF specification to allow making competing players.

    22. Re:DOM-Interface for byte code by devent · · Score: 1

      We not talking about applets. We talk about a byte code that every browser have to implement, like the ECMAScript today. But the byte code could be generated by any language, not just JS.

      It's the same as with Google's GWT, with takes Java source code and compiles it to JS code, so a browser can run it. Now, why can't GWT compile Java to a byte code that can directly be run in the browser?

      If Sun/Oracle could would had more wisdom, we would just have a JVM in every browser. That way you could program in Scala,Groovy,Java,Closure,JRuby,Jython,LUA, and JavaScript for the browser. Just take the current JVM, add some DOM-API to it and be done with it.

      But, no, they had to add some stupid patents to JVM and some stupid politics about the license. So now we still have JS VMs that are like the JVM was in 1995 and with single language attached to it.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    23. Re:DOM-Interface for byte code by martin-boundary · · Score: 1
      There's a huge difference between reading/understanding bytecode and reading/understanding code written in a programming language. Bytecode is designed for efficiency and for compiler convenience, whereas programming languages are designed for human convenience (except brainfuck ;-).

      The average code written in a programming language is always going to be better than the average bytecode generated by a compiler, and if it's an optimizing compiler the bytecode will be even harder for a human to understand.

      The difference between programming code and bytecode may be subtle in special cases, like the difference between BSD and GPL, but the long term effects are major.

    24. Re:DOM-Interface for byte code by martin-boundary · · Score: 1

      The web already exploded. We're now well past that DIY point.

      Nonsense. The web exploded a long time ago, but innovative new ideas keep appearing. Remember when Google first unveiled the autocompletion in the search bar? Everyone got excited and went through the javascript source to figure out how they did it, and then it wasn't just copied, but improved and made its way into all sorts of websites.

      Innovation doesn't all happen at once, it's a small idea here, a small idea there, and then someone combines several ideas and pretty soon you have a full email app in a browser, etc.

    25. Re:DOM-Interface for byte code by martin-boundary · · Score: 1

      Slowness is not a real issue, it's merely a symptom of inefficient javascript interpreters and inefficient threading in the browser. Fix the browser, and slowness won't be an problem. Neither is code size, btw. The difference between bytecode and source code isn't noticeable on today's fast network links, especially with all the other crap that's loaded in a modern web page.

    26. Re:DOM-Interface for byte code by lucian1900 · · Score: 1

      JavaScript is always minified anyway. There's a difference between development packages and distribution packages.

    27. Re:DOM-Interface for byte code by broken_chaos · · Score: 1

      No kidding. I 'disassembled' the YouTube JavaScript once, and I still have nightmares.

    28. Re:DOM-Interface for byte code by am+2k · · Score: 1

      My main reason for not liking the Java plugin to this date is that applets take ages to start up. My MacBook Air literally takes less time to boot than an applet takes time to start up after opening its webpage. Back when they were rather popular, Mac OS 9 would block the whole computer while the VM was loaded up, which would take about a minute or more.

      If the VM would be part of the browser, that problem would be gone.

    29. Re:DOM-Interface for byte code by am+2k · · Score: 1

      but then you immediately start to run into sandboxing & security issues.

      In which way is this different to current JavaScript implementations?

    30. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 0

      I would cry happy tears if we got LUA in the browser.

    31. Re:DOM-Interface for byte code by devent · · Score: 1

      Did you even visit http://code.jquery.com/jquery-1.7.min.js ?
      I would say that's byte code, with just happens to have some ASCII characters in it, instead of just byte tupels.

      In Java almost all important libraries are open source, but very few people would download the source code, they are just happy with the compiled .class (i.e. a jar) files. The same is true for all compiled languages, and for some interpreted, like python.

      As long as the license is open, the original code available, and the common practice of using minimized JS will increase, I don't see any problem or difference with byte code.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    32. Re:DOM-Interface for byte code by Anonymous Coward · · Score: 0

      Correct me if I'm wrong, but Java applets don't have access to the DOM; instead, they're given an area of the page and a sandbox to play in, just like Flash. I'm very much with the GP on this one: a standard VM with direct DOM access (and no other output options) is the way to go. Performance should be better, and developers could use the language of their choice (including Javascript). The current situation -- Javascript or nothing, with subtly different versions in each browser -- is just stupid, especially since we're all racing into teh cloud now.

      That said, I wouldn't pick Java for the VM, considering all the scope that would give Oracle to screw us over. Don't shoot me for saying this, but the Flash VM (on its own, disconnected from all the front-end display stuff) is actually pretty nice: lightweight and fairly fast. It could be improved, but it wouldn't be a bad starting point.

    33. Re:DOM-Interface for byte code by Toonol · · Score: 1

      There's no reason bytecode would be any less secure than running javascript or any other interpreter. Bytecode is just a language with a simple syntax, optimized for fast interpretation. I'd think the simplicity would make it more secure.

      The problem isn't security, it's standardization.

    34. Re:DOM-Interface for byte code by trenobus · · Score: 1

      For years I've been saying that we need a DOM-Interface for byte code in Browsers and everytime I get downvoted

      For years you've been right. But now that dream can no longer be denied by the browser venders.

      Much of the stuff that doesn't make sense in the way we use computers can be attributed to competition between rival companies (or groups). Often competition can be a good thing, such as the current competition of browser venders to make faster Javascript implementations. But sometimes a much better result can be obtained by people cooperating to make a single standard that is in their long-term mutual interest. I believe Javascript became a standard by stealth. If the marketing departments of the companies involved in its standardization had known what it would become, they would not have allowed it to happen. Had they realized the need for large-scale, client-side programs, they would have continued to push proprietary solutions, as Adobe in fact did.

      The thing is, now that the browser venders have been suckered into making Javascript a capable platform in its own right, they can no longer control what developers choose to implement on it. If developers chose to standardize a byte code implementation, and then targeted their favorite languages to it, the browser vendors basically have two choices to gain a competitive advantage. One is to optimize their Javascript for execution of the standardized byte code. The other is to provide a native JIT implementation of the byte code.

      Another alternative for developers is to standardize the back end of a source-to-source compilation system. So there would be a front end that compiles your favorite language to a common intermediate form, and a common back end to translate the intermediate form into minified Javascript. This is not as good as the byte code solution, in my opinion, but if it gets developers writing client code in something other than Javascript, it's a step in the right direction.

    35. Re:DOM-Interface for byte code by martin-boundary · · Score: 1

      Did you even visit http://code.jquery.com/jquery-1.7.min.js ? I would say that's byte code, with just happens to have some ASCII characters in it, instead of just byte tupels.

      Yes I did. Bytecode is a lot worse than that. Try getting rid of functions, if/else and structured loops of all kinds and replace with gotos and memory or stack locations. The wikipedia page has an example of what you can expect in Java for example. Or start with the page on three address code.

      The jquery example you point out is mainly designed to reduce code size and bandwidth costs, but if you want to learn how it does something and that file is all you have, then you can start with a well defined entry point and you can trace what's going on from there. It's painful sure, but an order of magnitude less painful than your typical VM bytecode.

      Modern bytecodes are designed to be very regular because that actually helps optimizing compilers do weird transformations and reorderings that straddle several separate source code statements. If you want the gory details, read the dragon book.

    36. Re:DOM-Interface for byte code by martin-boundary · · Score: 1
      forgot to talk about this:

      As long as the license is open, the original code available, and the common practice of using minimized JS will increase, I don't see any problem or difference with byte code.

      There are other reasons to prefer source code. Maybe you have a security plugin that flags certain code patterns, maybe you want to undo some types of anti-social behaviour like popups/unders and whatever gets invented by the advertisers in the future.

      Open source is great, but its true power is limited if your browser doesn't use it. Alternatively, one could also argue that the open nature of HTML was a kind of forced open source that applied to all web content, with spectacular results.

    37. Re:DOM-Interface for byte code by Richard_at_work · · Score: 1

      C# and VB.net may have differences, but they both compile down to the same Intermediate Language.

    38. Re:DOM-Interface for byte code by SickLittleMonkey · · Score: 1

      => Google Native Client.

      --
      main() {1;} // zen app
    39. Re:DOM-Interface for byte code by devent · · Score: 1

      You could use a decompiler. Here is a list of Java decompilers: http://www.program-transformation.org/Transform/JavaDecompilers
      Since we are talking about making a bytecode standard, it should be very easy to build such decompilers, if needed.
      In Java bytecode the method and class names are saved, so with a decompiler it's a lot easier to understand the bytecode then with the minimized JQuery code.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    40. Re:DOM-Interface for byte code by devent · · Score: 1

      What have the human-readable source code to do with that argument? For such a plugin it's actually way easier to analyze byte code than the source code. As long as the byte code is a standard, which we are talking about the whole time.

      I don't think that the generated HTML code have anything to do with the open nature of the web. It have only to do with one important fact: that HTML is an open standard. We shouldn't care less if (the tag) or 0x02 (the byte) is used, as long as it's an open standard.

      Of course lots of HTML is written by humans so a text token is better, then a byte number.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    41. Re:DOM-Interface for byte code by martin-boundary · · Score: 1
      Good luck with decompilers. A decompiler can only help with high level patterns that it can identify, but those patterns are deliberately broken by optimizing compilers as part of the optimization process. Also, different compilers (and languages) produce slightly different patterns so going the other way you'll need to know something about what language/compiler created the bytecode.

      Incidentally, disassemblers for executable files have existed for many decades on nearly every OS platform, and debuggers can be used to inspect what's going on at that level. It's a popular pastime in the warez scene. But experience shows that just doesn't achieve its potential. "Proper" programming language source code is just an order of magnitude superior and more versatile.

    42. Re:DOM-Interface for byte code by martin-boundary · · Score: 1

      What have the human-readable source code to do with that argument? For such a plugin it's actually way easier to analyze byte code than the source code. As long as the byte code is a standard, which we are talking about the whole time.

      Like I said in the other thread, source code ("programming language code") intended for humans is higher level than source code ("bytecode") intended for compilers and VMs. It's just not comparable, but to truly understand that you have to play around with both types of code for a while. Maybe you have and still disagree, but for now I doubt it.

      I don't think that the generated HTML code have anything to do with the open nature of the web. It have only to do with one important fact: that HTML is an open standard. We shouldn't care less if (the tag) or 0x02 (the byte) is used, as long as it's an open standard.

      The C language is an open standard. Programs written in C and compiled into executables have existed for 30 years. Yet nobody (except for hackers who crack games) inspects the machine code in compiled executables. HTML code is one "view source" button away from being inspected.

      Open alone really has nothing to do with it, it's how "high level" the code is that matters (and ultimately how motivated the person - people with average motivation attempt average tasks, people with high motivation attempt more difficult tasks). The jquery example is somewhere in the middle between fully documented maintainable source code, and bytecode.

  8. Re:This is nonsense. by afabbro · · Score: 4, Insightful

    Javascript != Java. "Javascript" is just a naming rip-off. So what's the big deal?

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

    --
    Advice: on VPS providers
  9. Interesting mind set by sgt+scrub · · Score: 3, Insightful

    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.

    I think it would have been easier to build a VM into a browser but I doubt it would have gotten this much attention. Still. It is a cool project.

    --
    Having to work for a living is the root of all evil.
  10. Java Applets by future+assassin · · Score: 1

    created by Java which was created with Java-script. Have the planets aligned?

    --
    by TheSpoom (715771) Uncaring Linux user here. I have nothing to add to this but please continue. *munches popcorn*
  11. Re:This is nonsense. by Arancaytar · · Score: 2

    Names have nothing to do with it. They could have just as well written their JVM in Python, Perl or PHP - except that none of those languages have undergone ten years of browser vendors fighting head to head to shave off another few microseconds on benchmarks, so their interpreters would be too slow to run an effective virtual machine.

  12. Re:This is nonsense. by DeathFromSomewhere · · Score: 1

    The C# compiler was written in C++.

    For now it is, sure.

    --
    -1 overrated isn't the same thing as "I disagree".
  13. Problem is speed by Anonymous Coward · · Score: 2, Interesting

    I doubt that Javascript accelerators are good at optimizing this, but it's not fundamentally impossible to run it close to JVM speeds. JS is a language that in nutshell is self modifying code, so it can act as a translational layer which in the end enables running Java in a Javascript engine (interpreter,VM or whatever). It could be compared to Dart which also runs another type of language in JS.

    1. Re:Problem is speed by Lennie · · Score: 1

      I think it will be (a lot better) when they've added this important part:

      "Type Inference brings JS improvements to Firefox Beta"

      "Javascript is a dynamically typed language, and without knowing the types of values a JIT compiler needs to generate code that accounts for all the possible types of the involved values. This significantly slows down execution of the program in comparison with a statically typed language like Java. With TI integration into JaegerMonkey, we are closing a significant part of this performance gap. Ongoing Mozilla projects are being built to leverage inferred type information. With these projects, primarily IonMonkey, Mozilla’s next generation JIT compiler, we hope to close the performance gap with Java completely."

      http://blog.mozilla.com/futurereleases/2011/11/10/type-inference-to-firefox-beta/

      --
      New things are always on the horizon
  14. 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.

    1. Re:Yo dawg.. I heard you like Java, so by Anonymous Coward · · Score: 1

      Yo dawg, I heard you liked recursion, so I ran a JVM inside the Rhino Javascript Engine on the JVM.

    2. Re:Yo dawg.. I heard you like Java, so by Robert+Zenz · · Score: 1

      Yo dawg, I heard you got Java and JavaScript swapped!

  15. Re:This is nonsense. by mcavic · · Score: 1

    I'd love to see it done in PHP. Anything to avoid running a Tomcat installation would be useful.

  16. Yo dawg, by boxxertrumps · · Score: 0

    I wrote a runtime in a scripting language so you can code while you script and I can debug while I debug.

  17. Re:This is nonsense. by Anonymous Coward · · Score: 0

    Umm... seriously, comparing JS to the Bourne Shell is a bit unfair.

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

  19. 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.
    1. Re:Really? by dkf · · Score: 2

      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.

      Technically, it's running anything that compiles to JVM bytecode. There are a number of languages that do that, one of which happens to be Java. (Yes, JVM stands for Java Virtual Machine and it would indeed be odd if Java didn't compile to it, but Java isn't JVM bytecode, just as C isn't native machine code.)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    2. Re:Really? by CodeReign · · Score: 0

      As someone who regularly programs in Java and is slowly branching out, I haven't used other JVM languages, are their bytecode primarily the same with optimization to the language or is it entirely different byte code all together for another JVM language.

    3. Re:Really? by tepples · · Score: 1

      There are only two bytecodes used by JVM languages: standard JVM bytecode, used in .class files, and Dalvik bytecode, used in .dex files. All JVM languages compile to JVM bytecode. Oracle is suing Google for using Dalvik in Android instead of standard JVM bytecode.

  20. Re:This is nonsense. by HJED · · Score: 2

    JVM is a run time environment not a compiler (although the environment includes a JIT compiler).
    Also I think the point was javascript is seen as a less powerful language

    --
    null
  21. sort of already done? by Anonymous Coward · · Score: 1

    Sun already made a JVM written in Java, so it can run java. see Maxine

  22. Not mind blowing when ... by fsckmnky · · Score: 3, Insightful

    ... you understand that a computer language, is a mapping of human readable symbols -> cpu instructions, either direct or indirect. If the mapping results in a set of cpu instructions that implements another language, you get another language.

    It's not rocket science people, its just math. Wait, maybe it is rocket science.

    1. Re:Not mind blowing when ... by Anonymous Coward · · Score: 0

      maths r hard

    2. Re:Not mind blowing when ... by MLease · · Score: 1

      Let's go shopping!

      --
      I'm sorry; I don't know what I was thinking!
    3. Re:Not mind blowing when ... by Anonymous Coward · · Score: 0

      If your language is turing complete... you can make it compile/interpret another language. If that language is turing complete, you can make it compile/interpret your original language - and around you go.

      It's math... but really old maths from like the early 20th century! aeons ago!

    4. Re:Not mind blowing when ... by Anonymous Coward · · Score: 0

      it reminds me of a young colleague of mine, who didn't want to use synchronized block around 5 lines of code. he said it would slow down the system. i asked - how long he thinks these 5 lines take to execute. he said "like milliseconds". when i told him it is more like microseconds, he didn't react. for young kids, who have all the time in the world, there is no difference between millisecond and microsecond. no shit they create frameworks that run like a dog just for the sake of creating a framework. this is age problem.

  23. This thing runs on the iPad? by lord_mike · · Score: 0, Flamebait

    What's that I hear? Steve jobs spinning in his grave? He can't be happy looking down at his consumers and them having some choices in what they want to run on "his" hardware. Oh well...

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

    2. Re:This is completely unnecessary. by Anonymous Coward · · Score: 3, Informative

      Dammit, Fabrice Bellard keeps making me feel like I am as dumb as a plate of chicken.

    3. Re:This is completely unnecessary. by Just+Some+Guy · · Score: 1

      No kidding. "Hey, guys! I was bored this weekend so I wrote a zSeries emulator in Haskell. Anyone wanna grab a beer?"

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:This is completely unnecessary. by Anonymous Coward · · Score: 0

      That is easily one of the coolest things I've ever seen. Thanks.

    5. Re:This is completely unnecessary. by Anonymous Coward · · Score: 0

      I would prefer using an ARM emulator instead. You know, ARM needs considerably less power. :-)

  25. it will be useful for ... by georgesdev · · Score: 1

    ... justifying tera-hertz processors!

    1. Re:it will be useful for ... by jonbryce · · Score: 1

      Unless there are future developments in getting things to move faster than the speed of light (0.3mm/ps), Or we can miniaturise a computer to considerably less than 1mm^3, I don't think we are going to see tera-herz processors any time soon.

    2. Re:it will be useful for ... by georgesdev · · Score: 1

      make it "thousand core" computers if you prefer. I just meant this architecture was so inefficient that it would need vast amounts of hardware resource.
      I'm just tired of people making inefficient use of hardware.

  26. Re:This is nonsense. by Shoe+Puppet · · Score: 2

    I can see a use case: Once we have a mostly complete JVM interpreter with satisfactory performance written in Javascript, we can use any language that supports the JVM instead of Javascript.

    --
    (+1, Disagree)
  27. Re:This is nonsense. by Anonymous Coward · · Score: 1

    To the bourne shell

  28. Why now? by thegarbz · · Score: 4, Interesting

    Legit question from a programming novice: Why are all these discoveries coming up now? Hasn't JavaScript been around for 10+ years now? Is there something that has changed recently that makes people pursue these strange coding goals?

    1. Re:Why now? by sydneyfong · · Score: 4, Informative

      Javascript speeds have increased greatly due to the reheated competition by browser vendors (it wasn't too long ago that the only thing really existed was IE6). Thus in the past 10 years, nobody in their right mind would expect a x86 emulator, a JVM etc. to be implementable in Javascript at tolerable speed.

      In fact, few expect these "discoveries" to happen so soon and so quickly, but since somebody proved it possible to do crazy things on Javascript, everyone with too much time on their hands are jumping on board and having fun with these projects.

      --
      Don't quote me on this.
    2. Re:Why now? by fsckmnky · · Score: 1

      It's only a discovery if you're an over-enthusiastic n00b at this game.

      To the rest of us, its same-old-shit-different-day.

    3. Re:Why now? by Anonymous Coward · · Score: 0

      I think in large part one needed a generation to grow up with it. There was too much unjustified hate for it at a certain point in time. People growing up with js as an environment that was free to get started with, had tons of support, and was crossplatform changed a lot of things. Both for themselves, and for people who'd dismissed it early on without watching the changes over the years.

    4. Re:Why now? by jimicus · · Score: 1

      It's not a discovery by any stretch. (And JavaScript has been around a bit more than 10 years, I wrote a fairly basic game in an unholy mishmash of JavaScript and HTML circa 1998-1999).

      Provided JavaScript is Turing-complete (and there are very few useful languages that aren't), basic computing theory teaches us that it's possible to write more-or-less anything you want in it.

      Note the keyword here is possible. Desirable and practical are totally different matters altogether.

    5. Re:Why now? by Anonymous Coward · · Score: 0

      More and more desktop software development is forced to target the browser, where the choice of programming languages is dictated by the collective wisdom of one open source non-profit and a few big companies. Your only real options are Ecmascript with some open source framework or Microsoft's Visual Studio, so these are desperate times that call for desperate measures.

    6. Re:Why now? by Lennie · · Score: 1

      Specifically some primatives/types have been added to work efficiently with binary data when WebGL was added to the browsers (specifically a new type of array).

      --
      New things are always on the horizon
    7. Re:Why now? by slim · · Score: 1

      It's not a "discovery".

      You can emulate any turing-complete system in any other turing-complete system. It's just a matter of having the tools and performance to achieve it without going mad.

      And we don't know he didn't go mad... or start mad...

  29. 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 :-)

  30. This guy needs to see a psychiatrist. by Anonymous Coward · · Score: 0

    What a gigantic waste of time.

    1. Re:This guy needs to see a psychiatrist. by StripedCow · · Score: 1

      Or, more likely, he was already institutionalized decades ago and was just looking for a nice project to spend his time on.

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
  31. LOL awesome.. by holyshitagain · · Score: 1

    But not surprise, since javaScript can implement a Y combinator (a Y-combinator is a function that operates other functions to enables recursion when it can't refer to itself from within itself.)

  32. Cute hack by j1976 · · Score: 1

    Ok, that's about the most amusing hack since someone wrote a fully working web server in postscript: http://www.pugo.org:8080/

    (Still think the postscript web server leads the list of odd hacks)

  33. Redundant acronym is redundant by Anonymous Coward · · Score: 1

    "a Java Virtual Machine JVM written in JavaScript"

    A Java Virtual Machine Java Virtual Machine written in JavaScript..... really?

    A JVM JVM written in JS?

    Right, I need to go and try to rememeber by Personal Identification PIN Number so that I can use the Automated Teller ATM Machine.

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

  35. Boredom by Anonymous Coward · · Score: 0

    You have bunch of developers who are bored and want some attention - that's all.

    After years of designing and coding, everything starts to look the same: problems you're solving, technology, techniques, languages .... it's all more of the same. So, what does one do? Crazy shit like this for the sake of just doing it.

  36. Re:This is nonsense. by TheRaven64 · · Score: 1

    Also I think the point was javascript is seen as a less powerful language

    It's Turing-complete. You can implement any language in it. That's not what people mean when they say it's less powerful, they mean some combination of:

    • Implementing the same algorithm in JavaScript and another language requires a more complex JavaScript compiler to reach the same speed.
    • It lacks access to operating system features via standard APIs (e.g. no threads)
    • It doesn't allow unsafe operations that are required for low-level programming.

    The fact that you can run a slow JVM written in JavaScript doesn't address any of these.

    --
    I am TheRaven on Soylent News
  37. From the notes by kikito · · Score: 2

    "Computers languages are how we tell computers what to do"

    That's so in the past.

    Nowadays, computer languages nowadays are (minus some exceptions) all about telling people what computers do.

    1. Re:From the notes by Anonymous Coward · · Score: 0

      This is one of those things that sound good, but don't bear up under scrutiny. Yes, that way of looking at it does help to hammer home the importance of writing clean and readable code, but it obscures the fact that computer languages are still how we tell computers what to do.

      They are also used to tell humans what computers are doing.

      They do both.

    2. Re:From the notes by Anonymous Coward · · Score: 0

      "Computers languages are how we tell computers what to do"

      That's so in the past.

      Nowadays, computer languages nowadays are (minus some exceptions) all about telling people what computers do.

      And we we will have strong AI when computer languages are all about telling computers what people do. :-)

  38. Re:This is nonsense. by slim · · Score: 1

    Let me introduce you to Jetty.

  39. Halting-complete by tepples · · Score: 1

    That's not what people mean when they say it's less powerful, they mean some combination of: Implementing the same algorithm in JavaScript and another language requires a more complex JavaScript compiler to reach the same speed.

    That or reaching the same speed turns out to be halting-complete due to the complexities of trying to squeeze static typed performance out of a dynamic typed language.

    It lacks access to operating system features via standard APIs (e.g. no threads)

    Exactly. Without threads, how is a JavaScript JVM supposed to implement JVM threads? And without WebGL (which at least one major browser maker refuses to implement for security reasons), how is Java 3D implemented?

    1. Re:Halting-complete by nedlohs · · Score: 1

      Exactly. Without threads, how is a JavaScript JVM supposed to implement JVM threads?

      The way it's always been done. We've had multiple processes and multiple threads on single core CPUs for decades. You just give each thread a time slice and then move on to the next one. Completely trivial.

      And without WebGL (which at least one major browser maker refuses to implement for security reasons), how is Java 3D implemented?

      Slowly. And surely it's not a required feature of java - I would hope the java that runs on my non-3D set top box doesn't bother with it for example.

    2. Re:Halting-complete by Anonymous Coward · · Score: 0

      Without threads, how is a JavaScript JVM supposed to implement JVM threads?

      The same way an OS implements threads on a single-core CPU.

      And without WebGL (which at least one major browser maker refuses to implement for security reasons)

      WebGL is just math.

      how is Java 3D implemented?

      Slowly.

    3. Re:Halting-complete by tepples · · Score: 1

      So in other words, the browser has to be even more of an operating system than it already is.

  40. How to translate into JS? by tepples · · Score: 1

    Say I have an existing application, and it is cleanly separated into logic and presentation. How do I automatically translate the source code of the application's logic part into JavaScript so that I can write a new DOM-based presentation for it?

  41. Other bytecodes by tepples · · Score: 2

    I think aglider's point is that there exist notable bytecodes other than JVM bytecode, such as Microsoft CIL, UCSD p-code, Infocom Z-code, SCUMM bytecode, LLVM bitcode (which is already handled by Emscripten), and more.

    1. Re:Other bytecodes by aglider · · Score: 1

      You hit the point, tepples. It wasn't easy nowadays, but you did it.

      --
      Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
  42. LBA-complete, not Turing-complete by tepples · · Score: 2

    Provided JavaScript is Turing-complete (and there are very few useful languages that aren't)

    No language is Turing-complete because no machine has unbounded memory. A linear bounded automaton (LBA-complete) is a better model of computers that exist in the physical world.

    Note the keyword here is possible. Desirable and practical are totally different matters altogether.

    Especially because even once you've ignored speed, neither Turing completeness nor LBA completeness makes any guarantee about I/O capability.

    1. Re:LBA-complete, not Turing-complete by Anonymous Coward · · Score: 0

      Go fuck yourself. Everyone knows what Turing completeness is generally accepted to mean: Machines or languages that could simulate a UTM if they had unbounded memory. Even with this looser definition, Turing completeness is still a useful distinction in computability since in most proofs the unbounded/bounded memory distinction can be generalized away.

    2. Re:LBA-complete, not Turing-complete by tepples · · Score: 1

      Everyone knows what Turing completeness is generally accepted to mean: Machines or languages that could simulate a UTM if they had unbounded memory.

      In other words, machines or languages that can simulate a universal linear bounded automaton.

      Turing completeness is still a useful distinction in computability since in most proofs the unbounded/bounded memory distinction can be generalized away.

      Then why don't the proofs say "LBA completeness" in the first place? And I haven't seen a lot of proofs that have much to say about I/O capabilities that end users expect of a desktop or mobile computing device.

  43. IE? by james_van · · Score: 1

    But does it work in IE or does it need browser detection and a bunch of conditionals before it will play nice? Seriously, JS is tolerable when you write it for a "compatible" browser, but once you throw IE into the mix it turns into the code equivalent of a water boarding session

  44. drive-by exploits? by xipcloud · · Score: 1

    So does this mean instead of giving the nasty java warning pop-up when running an unsigned applet using jvm, I can do driveby using javascript that implements a jvm...? Oh that sounds great....

  45. Flash by Anonymous Coward · · Score: 0

    Now all we need is a version of Flash that runs under Java and we can reach a new low for mobile speed and power consumption!

  46. Stupid by Anonymous Coward · · Score: 0

    That's the stupidest thing I ever heard of. Write a vm for a compiled language in an interpreted, non-standard piece of crap. Great job, NOT!

  47. Come on! by Anonymous Coward · · Score: 0

    Aw... THIS IS SLASHDOT, for God's shake!

    What are you waiting for, guys?

    IN SOVIET RUSIA, JAVASCRIPT RUNS YOU!

    Crap, someone had to say it....

  48. Just cos it can be done, ... by ThirdPrize · · Score: 1

    doesn't mean that it should be done. I'm just saying.

    --
    I have excellent Karma and I am not afraid to Troll it.
    1. Re:Just cos it can be done, ... by PPH · · Score: 1

      Too late. The idea is stuck firmly in the Slashdot developers' heads.

      --
      Have gnu, will travel.
  49. Re:This is nonsense. by Trails · · Score: 1

    It's also seen as less powerful because it's more confusing (dynamically types and the wacky cross-browser implementations being the main sources of this in my experience). Some of that is also legacy leftover of javascript as a scripting language being conflated with "that script you use to do rollovers" in the ie-netscape days.

    As you say, javascript as a language is plenty powerful, see what can be done in unity and flex for examples.

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

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

  51. Re:This is nonsense. by bill_mcgonigle · · Score: 1

    Sad day - your comment is the only one that comes up in a browser find for 'Turing' on my default page view and that's because I have my friends scoring +4...

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  52. Re:Happy Holidays from the Golden Girls! by Anonymous Coward · · Score: 0

    Go on, keep trying to correct the troll... I'll give you a hint: It will only make you more mad and the troll will be even more successful.

  53. Re:Happy Holidays from the Golden Girls! by Anonymous Coward · · Score: 0

    No, it's consonant, you idiot.

  54. PyPy by gr8_phk · · Score: 1

    PyPy implements Python in Python. Apparently it's a great way to test new features before undertaking an implementation in the C interpreter.

  55. maybe I'm just not seeing it by JustNiz · · Score: 1

    OK bear with me. I'm old school and do a lot of embedded development. I do pretty much everything in C or C++.
    I am not even slightly in tune with the kitchen sink mindset and all technologies you internet-everything developer types use. I've always thought you guys do way too much layering and usually end up making some heavyweight, overcomplex and slow monster with all sorts of dependencies on stuff like web servers and databases to just to do something I could do in a few lines of native C++.

    A JVM based on Javascript seems a perfect example of extreme bloat to me. I'm genuinely interested in whats the benefit of this approach that can outweigh its no doubt massive resource usage and relatively sucky performance, even compared to native JVM?

  56. Ken Thompson Hack by nuckfuts · · Score: 1

    This discussion of compilers written in their own language makes me think of the Ken Thompson Hack, wherein the hacked compiler forever propagates malicious content that is not contained in the source code.

    "This hack can propagate transparently across languages and language generations. In the case of cross compilers it can leap across whole architectures."

    27 years later it's still the most devious backdoor I've ever heard of.

  57. Similar Concepts by Chester+K · · Score: 1

    It's worth noting that Microsoft Research had the exact same idea back in 2007 with Volta, which was an implemention of the .NET CLR in Javascript so you could take the same .NET compiled assembly files that you run on your PC and run them without any plugins in a Javascript-capable browser.

    They eventually ditched the idea in favor of a different approach with Script#, which is a C# compiler that compiles to Javascript instead of .NET bytecode; similar in concept to Google' GWT Java source to Javascript compiler.

    --

    NO CARRIER
  58. Our brains by Jeff1946 · · Score: 1

    Don't we "program" our brains in English using English or whatever is your native language with no initial bootstrap compiler? Yes, I know linguists have studied how much of language ability is hardwired into our brains.

  59. Re:Happy Holidays from the Golden Girls! by Anonymous Coward · · Score: 0

    Go on, keep trying to correct the troll... I'll give you a hint: It will only make you more mad and the troll will be even more successful.

    Actually, given how long that troll has been around- everyone should be clued in by now- I strongly suspect that the "oblivious" corrections made by other *anonymous* posters are now part of the troll itself, designed to attract comments like yours.

    Of course, maybe *your* comment was itself part of the troll designed to get a response from people like me... but I doubt it. :-)

  60. Sour Grapes? by Anonymous Coward · · Score: 0

    Instead of slashdotting the web site where the action is, linking to the web site that broke the story before Slashdot did?

  61. Can I run applets on a iPod now? by Anonymous Coward · · Score: 0

    I knew I should have held on to my hot applet related domain name.
    Just when I'd given up on Applets ever making a comeback, here we are.
    God damn Microsoft's evilness and Sun's incompetence for destroying Java applets in the browser.
    Imagine if you dare, a beautiful world where web GUI design doesn't include worrying about how style sheets and javascript work on dozens of different version of dozens of different browsers.
    A magical world where you can get direct access to the screen pixel data and implement everything from widgets to real time vector and 3D renderers, and know that it will appear consistently for all your users. A world where Flash is totally unnecessary.
    In all seriousness, web programming is for chumps.
    My old client just asked me if I was interested in making some changes to the web application I wrote them. I'm busy, but I told them what desirable experience they would want for my replacement...
    Java, GWT, JEE, EJB, JBoss Seam, JSF, Facelets, Richfaces, HTML, JavaScript, AJAX, JPA, JPQL, EL, Oracle SQL, XML, CSS (targeting desktop and mobile devices)
    If applets had of come to dominate the web, that list might instead be...
    Java, JEE, EJB, Oracel SQL.

  62. Nothing new by Anonymous Coward · · Score: 0

    C compilers have been implemented in C before. Nothing new here.

    1. Re:Nothing new by Anonymous Coward · · Score: 0

      They did not write a JVM in Java. They wrote a JVM in Javascript. Big difference. Java != Javascript.

  63. Re:Happy Holidays from the Golden Girls! by Anonymous Coward · · Score: 0

    No, it's consonant, you idiot.

    Careful, you'll put the troll in a vowel mood!

  64. Re:This is nonsense. by wierd_w · · Score: 1

    A better use case is for pointing out the unsatisfiability of apple's developer restrictions, regarding interpreted languages/emulation.

    This javascript jvm would allow you to run "anything you want" inside the stock idevice browser, since said browser needs to support javascript for a huge number of reasons.

    It wouldn't be as good as a native arch jvm, or even better, native arch software, but the abstraction capability would render *all* modern browsers into a nonconforming state with the developer agreement. Apple would have to either forbid modern browsers, or remove the restriction.

  65. Oracle by jcfandino · · Score: 1

    So, is Oracle gonna sue this time?

  66. So what? by Anonymous Coward · · Score: 0

    Javascript has nothing to do with Java, or the other way around. The javascript language is implemented by browswers that are often written in java, but it doesn't have to be. It could just as easily be implemented elsewhere.

    From wikipedia "JavaScript uses syntax influenced by that of C. JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics."

    This isn't insanity, it just is.

  67. Re:Happy Holidays from the Golden Girls! by Anonymous Coward · · Score: 0

    Actually.. I'm getting quite sick of this one.(including the inevitable 'correction threads').It's clearly not having the effect i imagine it's supposed to. It's not even interesting or funny..

  68. 6 months = 60%, versus 1 month = 100% by Anonymous Coward · · Score: 0

    My students implemented this as a class project: http://plasma.cs.umass.edu/emery/grad-systems-project-1. One month, 100% of the bytecodes.

  69. Another similar project by Anonymous Coward · · Score: 0

    It seems it's based on GWT: http://jainja.thenesis.org