News for hackers. Stuff that matters.
Re:Nodyn – Node.js for the JVM by mmanfrin on Wednesday February 26, 2014 @06:54PM (#7309206)
Question from a novice-ish developer: What is the purpose of porting things to the JVM? I had this idea before that porting things like Ruby or Rails to the JVM was meant to offer ruby the advantages of having a java core (better threading, garbage collection, faster). But, as I understand it, Node is faster than JVM languages? What are the other advantages gleaned from porting?

e: Thank you guys for the answers, definitely makes a lot more sense now.

Re:Nodyn – Node.js for the JVM by justinsb on Wednesday February 26, 2014 @07:12PM (#7309298)
The JVM gives you very good JIT, GC, threading, manageability (profiling, debugging, memory inspection etc), scalability to huge machines, a huge ecosystem of software and has basically solved every real-world deployment problem. (Maybe apart from memory utilization!) It is definitely possible to beat the JVM on any one of these facets, but to consistently beat it on all of them is a _lot_ of work. (I'm not sure which benchmark you're referring to where Node beats the JVM, but I suspect it's relatively 'focused'.)

To my mind, the idea of porting is that you face a choice: you can recreate the JVM functionality in your own runtime, or you can port to the JVM. Porting to the JVM is certainly non-trivial, but you then get thousands of man-years of work in return. It's certainly worth doing a project to see whether the porting effort pays off; especially if this done concurrently with working on the language's 'native' runtime.

Re:Nodyn – Node.js for the JVM by dmpk2k on Wednesday February 26, 2014 @07:31PM (#7309384)
but to consistently beat it on all of them is a _lot_ of work.

As long as you aren't native, that is.

Although that's unrelated to the discussion at large.

Re:Nodyn – Node.js for the JVM by pcwalton on Wednesday February 26, 2014 @10:40PM (#7310256)
Even then it's not that easy. A non-optimizing C compiler will have a hard time beating the JVM's slew of optimizations.
Re:Nodyn – Node.js for the JVM by erichocean on Thursday February 27, 2014 @12:50AM (#7310608)
A non-optimizing C compiler

Is there a C programmer on the planet that does production builds with a non-optimizing compiler? How is your comparison even remotely relevant to the GP?

Re:Nodyn – Node.js for the JVM by bruceboughton on Thursday February 27, 2014 @05:30AM (#7311402)
I believe the GP is referring to writing a non-optimising compiler in C. Not compiling your C code using a non-optimising compiler.
Re:Nodyn – Node.js for the JVM by dmpk2k on Thursday February 27, 2014 @04:26AM (#7311226)
That's mostly true, but just like managed languages can leverage JVM, native languages can leverage LLVM.

The advantage of going the native route is that it gives you improved observability and post-mortem. The JVM is a VM (Java's) inside a VM (the OS's), and that additional layer doesn't come for free.

Re:Nodyn – Node.js for the JVM by pjmlp on Thursday February 27, 2014 @05:02AM (#7311330)
Most commercial JVMs also have native compilers for Java, and there are a few projects to run JVMs directly on top of hypervisors without OS in the middle.

Some of those are actually LLVM frontends.

Re:Nodyn – Node.js for the JVM by dmpk2k on Thursday February 27, 2014 @05:17AM (#7311370)
I'm referring to the open Hotspot which almost everyone uses, not some specialized JVM products which are closed-source. You do bring up an interesting point though.

As for the type of hypervisors you're referring to, those things are effectively half-baked operating systems. That's why something like KVM is better -- you're not pretending to be a non-OS while slowly reinventing a wheel that the *nixes have and always will do better.

I think we're beginning to wander massively afield though! :)

Re:Nodyn – Node.js for the JVM by pjmlp on Thursday February 27, 2014 @01:09PM (#7313793)
Hypervisors are older than UNIX, as the first ones date back to the OS/360.
Re:Nodyn – Node.js for the JVM by mmanfrin on Wednesday February 26, 2014 @07:26PM (#7309368)
Very thorough answer, thank you :]
Re:Nodyn – Node.js for the JVM by Edmond on Wednesday February 26, 2014 @08:53PM (#7309773)
Naive (and mostly ignorant) programmers make a habit of sh*tting on the JVM and the Java platform in general.

My usual response regarding the merit of the JVM is this: there is a reason there's jvm on the server, desktop, on your phone, on the rovers on mars and god knows on how many mission critical systems.

And no it isn't because of great marketing, which is another common and lame response from JVM detractors.

The JVM is an impressive engineering effort and the eco-system spawned by it is currently unrivaled.

With the new trend of porting other languages (ruby,python,js..etc) to it, the I see the JVM as the middleware over which most future software would be built.

Re:Nodyn – Node.js for the JVM by pron on Wednesday February 26, 2014 @07:46PM (#7309460)
Node is actually much slower than Java. True, the JavaScript implementation on the JVM is slower than V8 (even Nashorn, the new JavaScript engine included in Java 8). Of course, the main motivation is, as others have said, integration with the huge Java ecosystem, but being able to drop down to Java for performance (when you need it) is a lot easier than writing native V8 modules.
Re:Nodyn – Node.js for the JVM by dmpk2k on Wednesday February 26, 2014 @07:56PM (#7309505)
but being able to drop down to Java for performance (when you need it) is a lot easier than writing native V8 modules.

There's a node-ffi package, although it has some overhead from the call itself.

https://github.com/rbranson/node-ffi

Re:Nodyn – Node.js for the JVM by jonny_eh on Wednesday February 26, 2014 @07:13PM (#7309301)
Imagine that you just started a new job at a big company. It's a "Java shop". You're allowed to use any technology stack you want for your apps, and all the other apps have APIs, but there's hundreds of useful Java libraries that already exist for talking to these APIs.

This would allow you to use NodeJS but still leverage the existing Java libraries, not requiring you to rewrite them.

Re:Nodyn – Node.js for the JVM by dragonwriter on Wednesday February 26, 2014 @07:05PM (#7309257)
> Question from a novice-ish developer: What is the purpose of porting things to the JVM?

Interop with the things that already exist in the Java ecosystem.

> I had this idea before that porting things like Ruby or Rails to the JVM was meant to offer ruby the advantages of having a java core (better threading, garbage collection, faster).

To the extent that those were effects of porting Ruby to the JVM they were mostly secondary, Java interop was the key feature (Rails, BTW, wasn't ported to the JVM, it just runs anywhere you have a functional Ruby implementation -- heck, before Ruby had executable specs, the test for a functional implementation was pretty much "does it run Rails".)

Re:Nodyn – Node.js for the JVM by jmgrosen on Wednesday February 26, 2014 @07:02PM (#7309243)
It seems like a major motivation for this project is to be able to use Java libraries from Javascript (a la Jython). There are a non-negligible number of libraries that only exist for Java, and being able to harness those from JS sounds nice to me, even if it means taking a performance hit.
Re:Nodyn – Node.js for the JVM by mmanfrin on Wednesday February 26, 2014 @07:22PM (#7309342)
Ohhhh, so one would just make like a node interface for some Java library, and it would be available for use in any JVMNode app?

This makes a lot of sense.

Re:Nodyn – Node.js for the JVM by jamesbritt on Wednesday February 26, 2014 @07:01PM (#7309242)
Jruby lets your ruby code use any Java library and gui toolkit. This is quite useful.

Also, if you work at a Java shop having stuff run on the JVM affords a way to sneak in new tech. :)

Re:Nodyn – Node.js for the JVM by moondowner on Thursday February 27, 2014 @07:29AM (#7311752)
In my opinion (I'm a Java dev), the main benefits are being able to run RoR apps on TorqueBox[1] or some other JRuby server[2] and benefit the clustering, HA and other stuff that go with it; and 'the use of "true" native threads'[3].

[1] http://torquebox.org/ [2] https://github.com/jruby/jruby/wiki/Servers [3] http://www.restlessprogrammer.com/2013/02/multi-threading-in...

Re:Nodyn – Node.js for the JVM by ww520 on Wednesday February 26, 2014 @08:01PM (#7309533)
> But, as I understand it, Node is faster than JVM languages?

What is the source for that?

Re:Nodyn – Node.js for the JVM by tootie on Wednesday February 26, 2014 @11:10PM (#7310368)
Node is more adept at handling many concurrent requests due to its architecture but it's runtime is far slower than the JVM. The vert.x framework that is the basis for this project is based on a similar paradigm to node and is far faster.
Re:Nodyn – Node.js for the JVM by peterashford on Wednesday February 26, 2014 @09:38PM (#7309964)
Are you really claiming that Node is faster than Java? Source?
Re:Nodyn – Node.js for the JVM by MichaelMoser123 on Thursday February 27, 2014 @12:07AM (#7310494)
to run it 'in the cloud'; most hosting places will allow you to run java only, this restriction is in place so that everything will seem secure and divided into neat compartments.