Live data from Hacker News

Java Virtual Machine in pure Node.js

github.com

81–90 of 143 posts

Re: Java Virtual Machine in pure Node.js

#81
post #53
post #52

I hate java, I hate javascript, I hate node.js, so basically, I just leave a comment here, and you can make a conclusion about what I think about all this.

Just out of curiosity, what are your preferred languages and server environments?

Based on his HN profile, my guess is Python.

Re: Java Virtual Machine in pure Node.js

#82
post #41

Interesting! It looks like you've reimplemented portions of the Java Class Library rather than use e.g the existing class files from OpenJDK. My current research project, Doppio [1], implements the native portions of the OpenJDK Java Class Library so it can use an unmodified copy of the OpenJDK JCL. As a result, it can run a bunch of nontrivial programs (javac/javap/Rhino/Kawa-Scheme). One issue you will run into is…

Seems like the "reimplemented" portions are bits that need to interact directly with the script environment -- String is implemented in terms of V8's native strings, etc... That seems like a feature, not a bug -- you wouldn't want the interpreter needlessly doing bytewise diddling of an abstraction that is already very robust in the host environment.

Re: Java Virtual Machine in pure Node.js

#83
Really cool hack, and yet I can't help but think that the mile-high software stack between the developer and the CPU continues to grow meaning we're stuck in a perpetual game of filling up spare CPU cycles with nothing in particular.

I'm sure I'll see a demo showing off something that barely runs on modern hardware that we were more than capable of running with good performance in 1990.

sigh I feel like I'm being such a Debbie-downer even if this is a really cool hack.

Re: Java Virtual Machine in pure Node.js

#84
post #42
post #5

Would be interested in seeing a JVM written in Go.

Considering Go is slower than C, and the JVM is written in C/C++, I'd say the JVM would be slower. I'm not trying to say I wouldn't like to see it, but I don't think anyone would use it, is all. And it's sad when cool software doesn't get used.

Once the JVM emits machine code for the bytecode, it doesn't matter what language the JVM is coded in.

Re: Java Virtual Machine in pure Node.js

#85
post #20

Now I'll have even bigger problem explaining what the difference between Java and Javascript is! :)

It's like Car and Carpet. But it's also the kind of car that you can build out of carpets.

...or the carpet that you can build out of cars, considering the Ringojs.

Re: Java Virtual Machine in pure Node.js

#86
post #70

How hard is it to write a JVM? I'd think it pretty easy, as it's intended to be small and easily portable. You could even write one in Java (and I'm sure it's been done, many times). EDIT e.g. http://igormaznitsa.com/projects/mjvm/index.html Of course, doing all the tricky JIT etc of the JVM is a different story...

It depends on what you consider the JVM. If you're just talking about something that can load class files and do some instruction interpretation (like this project) then that's one thing... if you're talking about implementing all of the JNI functions within the JVM standard library (awt, net) along with the concurrency primitives (conforming to the Java memory model?) then that is a significant multi-year, multi-developer project.

Re: Java Virtual Machine in pure Node.js

#87
post #4

Just a toy implementation[1], if someone is wondering. [1]The basic .class file attribute parsers are located in libs/classfile, while a simple bytecode interpreter can be found in jvm.js. It doesn't load a real runtime library (classpath, apache harmony,openjdk,etc...) but it partially implements a few java.* classes in pure javascript under libs/java.

Please feel free to fork it, improve and post back.

I respectfully decline the offer :)

Re: Java Virtual Machine in pure Node.js

#89
post #41

Interesting! It looks like you've reimplemented portions of the Java Class Library rather than use e.g the existing class files from OpenJDK. My current research project, Doppio [1], implements the native portions of the OpenJDK Java Class Library so it can use an unmodified copy of the OpenJDK JCL. As a result, it can run a bunch of nontrivial programs (javac/javap/Rhino/Kawa-Scheme). One issue you will run into is…

Nice experiment and a huge undertaking, do you already support the current implementation of java.util.concurrent? (requires atomic CAS through sun.misc.Unsafe and ability to park threads)

Re: Java Virtual Machine in pure Node.js

#90
post #68

Finally, I can run JRuby on my node server!

From poster with similar project above: https://github.com/int3/doppio/wiki/Successes > We're also making progress on others, but we're not quite there yet: JRuby, Clojure, Scala REPL I think I just had a micro heart attack reading that.

ClojureScript is probably more efficient for Clojure, but running Scala REPL (and scripts) would be really nice. Some tasks are not CPU-intensive, they mostly wait on network I/O, but expressing them in something like Akka is just cleaner.
Post reply on HN