9 ms·
Doppio: JVM written in JavaScript
- fredley 9y agoI would like to run this in Rhino[1] - Mozilla's Javascript engine written in Java - just because. Turtles all the way down... [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rh...
- flukus 9y agoDoes it run java applets?
- quickthrower 9y agoI'd love it if it did. Use a sane programming language on the web again.
- pjmlp 9y agoIt will, just wait for WebAssembly to be more mature.
- expertentipp 9y agoJava applets for JVM written in TypeScript transpiled into JavaScript will be the next big thing. Freeze any browser, anywhere, instantly. Imagine the print out of stack trace with error - so exciting.
- mehrdada 9y ago(2014)
- bwidlar 9y agoJVM written in Javascript, what could be wrong?
- msgilligan 9y agoDon't worry, it has Nashorn ;)
- Randgalt 9y agoLike Taco Town :D Run Javascript in the JVM in Javascript
- rorosaurus 9y agoYour scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should.
- flogic 9y agoAssuming it worked well enough, you could use it to run legacy Java applets without having the Java plugin installed. That would at least improve the security situation a bit while still allowing for legacy applets.
- Scarbutt 9y agoImpressive, loaded a clojure.jar, got a repl and wrote/called some silly functions, it worked...
- amelius 9y agoOf course, the Java bytecode has only a limited number of instructions.
- the_duke 9y agoBut... why?? Edit: > This paper presents DOPPIO, a JavaScript-based runtime system that makes it possible to run unaltered applications written in generalpurpose languages directly inside the browser. Someone should really have told them about webassembly...
- wgjordan 9y agoThis paper was first published in June 09–11 2014 (first commit Feb 11 2014), Webassembly was first announced on June 17 2015.
- jryan49 9y agoThe paper was released at least a year before WebAssembly was even announced...
- shakna 9y ago... and a year after WASM's predecessor was announced.
- jryan49 9y agoDirectly from asm.js FAQ (http://asmjs.org/faq.html http://asmjs.org/faq.html): Q. Can asm.js serve as a VM for managed languages, like the JVM or CLR? A. Right now, asm.js has no direct access to garbage-collected data; an asm.js program can only interact indirectly with external data via numeric handles. In future versions we intend to introduce garbage collection and structured data based on the ES6 structured binary data API, which will make asm.js an even better target for managed languages.
- Koshkin 9y ago> (Read the academic paper) I admire the effort, but: doesn't "academic" mean "scientific"? Can there possibly be any "science" in having a well-known VM reimplemented in a well-known programming language?
- bdcravens 9y agoYes, in the sense that it's called "computer science" with little scientific method involved.
- amelius 9y agoI got an error, so I falsified it according to the scientific method: Error extracting doppio_home.zip: Error: ENOENT: No such file or directory., '/persist/vendor/java_home/lib/images/cursors/cursors.properties'
- emeryberger 9y agoFile a bug report, please. Doppio is actively maintained, though our current focus is on Browsix (which incorporates and extends some of Doppio's functionality -- see browsix.org).
- deleted 9y ago[deleted]
- Spivak 9y ago> Academic: of, relating to, or characteristic of a school, especially one of higher learning. It appears as though this was a university project, the kind of project one completes for their masters even. Academic seems to be precisely the right term.
- nteon 9y agoPlease take a look at the contributions in the paper at the end of the introduction. The JVM uses operating system abstractions (like a file system, threads, and synchronous APIs) that were non-existent in the browser when the paper were published, and are still widely unavailable natively. Figuring out how to construct the functionality necessary not to just simply execute Java bytecode but to provide a full Java Virtual Machine, and then show how this could be generalized beyond a JVM, is a CS contribution. Disclosure: I'm a labmate of the author.
- deleted 9y ago[deleted]
- brad0 9y agoThis is cool. Not because it's useful or performant etc. but because it shows how simple java bytecode is. After seeing this I wanted to know: - how many opcodes exist in the JVM - how easy would it be to create another language that compiles to the JVM. - how does the JVM represent basic data types The list goes on. All because someone built a JVM in JS. What happened to the hacker mentality of HN? Where's the curiosity gone?
- tathougies 9y agoPeople have written x86 emulators in javascript. That doesn't make x86 bytecode simple.
- winter_blue 9y agoThis. I don't think enough people appreciate how the simple and clear the JVM byte code's design is. Most platforms in use today are so complex. Take a look at x86, or one of the latest ECMAScript specifications. Even LLVM bitcode is a bit complicated compared to the JVM bytecode. I think in programming language research, going forward, we need some research into "high-level bytecodes". I.e. bytecodes that capture high-level concepts in a clear and simple way.
- jdmichal 9y agoI've actually found CIL to be simpler than JVM bytecode, even with additional capabilities. Simple addition is a good example: JVM: dadd, fadd, iadd, ladd. Addition for double, float, int, and long data, respectively. CIL: add, add.ovf, add.ovf.un. Addition, signed addition with overflow check, and unsigned addition with overflow check.
- kodfodrasz 9y agoI also prefer the CIL and also the C# language to Java (though I really like Java and its ecosystem), but we have to admit that MS had 5-10 years to learn from the Java design decisions and their effects, and still did not manage to overcome every problematic point :)
- mintplant 9y agoA similar project from Mozilla: https://github.com/mozilla/pluotsorbet https://github.com/mozilla/pluotsorbet It was targeted toward running J2ME apps on FirefoxOS phones. With that project dead it's no longer under active development.
- didibus 9y agoThis is actually quite awesome.
- cobookman 9y agoSo now you can run the JVM in JavaScript running in the JVM.... For those who don't know the JVM comes with a JavaScript engine by default: http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html http://www.oracle.com/technetwork/articles/java/jf14-nashorn.... And you can even get v8/nodejs to be compiled in your java jar binary: https://github.com/eclipsesource/J2V8 https://github.com/eclipsesource/J2V8
- Capt-RogerOver 9y agoThis is very cool. You can basically even call all Java classes (and the other way around) from that JavaScript! (And reliably limit the classes that can be used if you want to execute JS in a safe environment.) Why isn't this used more often? (Or is it used more often?)
- james-mcelwain 9y agoHere's a great testing library that leans heavily on Nashorn. https://github.com/intuit/karate https://github.com/intuit/karate. I find this a beautiful use of JavaScript in Java.
- cderwin 9y agoI can't speak to whether it is used more often, but I would bet the java-based Nashorn vm is significantly slower than the c++-based nodejs. In fact, a cursory google search shows this is the case, and it's not even close. See: http://blog.jonasbandi.net/2014/03/performance-nashorn-vs-node.html http://blog.jonasbandi.net/2014/03/performance-nashorn-vs-no... http://pieroxy.net/blog/2015/06/29/node_js_vs_java_nashorn.html http://pieroxy.net/blog/2015/06/29/node_js_vs_java_nashorn.h... (I can't speak to the quality of either of these tests, but the results seem decisive)
- Capt-RogerOver 9y agoWhile it is of course going to be slower, "it's not even close" is a judgement claim. The tests you have link talk about 1.6-2-3 times the difference. In a lot of applications the performance hit is going to be worth gaining access to the whole Java ecosystem of libraries. Also the performance is very likely to increase with newer versions.
- trynumber9 9y agoSee also luje. "An experimental (read: toy) Java virtual machine written in pure Lua." https://cowlark.com/luje/combined.html#index https://cowlark.com/luje/combined.html#index
- sandGorgon 9y agoI think it is impolite not to give accurate credit. It is Typescript... and not vanilla javascript. https://github.com/plasma-umass/doppio https://github.com/plasma-umass/doppio
- rounce 9y agoMay as well write Java.
- mercer 9y agoHow so?
- thangngoc89 9y agoUse Java to create bytecode which is executed in JS to produce JVM bytecode
- ndr 9y ago"Any application that can be written in JavaScript, will eventually be written in JavaScript." - Jeff Atwood
- colordrops 9y agoSo, every application will be written in JavaScript?
- fredley 9y agoEvery application that can
- colordrops 9y agoVery few can't
- chii 9y ago"and any application that can't be written in javascript will soon be compiled to javascript" -- me
- ianopolous 9y agoI investigated trying to use Doppio for Peergos. It is a very cool project. In the end we decided against it because it wasn't fast enough for our use case yet, and it requires the page to download the whole JVM (at least the rt.jar - the runtime) which is >60 MiB. We managed to get around this by manually stripping out the parts of the JVM that we didn't need, which brought it down to a few MiB. I imagine that once they update it to Java 9 with the modular JDK (and resultant splitting of rt.jar) this reduction will largely happen automatically with it lazily downloading the parts that it needs.
- apignotti 9y agoIf you like Doppio JVM, you may find our project interesting too http://blog.leaningtech.com/2017/06/announcing-cheerpj-java-compiler-for-webapps.html http://blog.leaningtech.com/2017/06/announcing-cheerpj-java-.... Our approach is to rely heavily on AOT compilation of JARs to JS to achieve higher perf, while still supporting full reflection. Moreover the RT is automatically split to reduce download time and bandwidth. A Swing application starts with ~15MB on our system. http://cheerpjdemos.leaningtech.com/SwingDemo.html http://cheerpjdemos.leaningtech.com/SwingDemo.html
- emeryberger 9y agoAlso, see our follow-on project, Browsix (http://browsix.org http://browsix.org), which makes it possible to run Unix applications inside the browser.
- crncosta 9y agoAtwood's Law: "Any application that can be written in JavaScript, will eventually be written in JavaScript."
- mi100hael 9y agoCorollary: "Any module written in JavaScript will eventually be ported to Go."
- kodablah 9y agoDone [0] and done [1]. Though, the latter one at least, isn't really in a production state because compiling the JVM stdlib takes hours in Go. 0 - https://github.com/zxh0/jvm.go https://github.com/zxh0/jvm.go 1 - https://github.com/cretz/goahead https://github.com/cretz/goahead
- z3t4 9y agoWould be cool if it could run GUI programs!
- peoplewindow 9y agoThere is also TeaVM: http://teavm.org/ http://teavm.org/