
Running Node.js on the JVM - irbull
http://eclipsesource.com/blogs/2016/07/20/running-node-js-on-the-jvm/
======
pfooti
Sure, this sounds pretty clever, but...

What's the use case here? Maybe you have some legacy java business library but
also need to do something with node? Wouldn't it be smoother / simpler /
easier to use services for this? I'd waaay rather have java do its thing and
node do its thing in different processes or containers, and have some api
layer between them.

Having node running in JNI in the _same process_ as the JVM just sounds like a
recipe for double the buffer overflow attack surface, for example.

On the other hand, maybe I'm just missing something critical. Can anyone point
out a system where this would be useful?

~~~
irbull
You're right, you could separate them into two containers and build a
networked API between them, and in many cases that may be the right approach.
But I wouldn't completely throw this solution away yet (I'm the author of this
solution, so I guess I'm biased).

For example, if you want to call an NPM module (say Grunt) from and Java /
Maven build, it may be easier to bundle this in the same process rather than
trying to provision node in the middle of the task. Also, if you have existing
Java libraries and want to make use of them as you migrate to Node, it might
be easier with the shared memory approach (through ByteBuffers and
TypedArrays) that J2V8 offers, than to try and pass the Data between services.

This isn't meant to replace services, it's just another technology choice on
the spectrum.

And finally, I thought the problem of integrating Node and Java sounded
challenging and cool, and I enjoy challenging problems :).

~~~
pfooti
True enough - something like "because it's there" is certainly a pretty good
reason to climb a (metaphorical) mountain.

~~~
irbull
Also (for a bit more history), I had already implemented the V8 / Java
integration. I did this because we needed a performant JavaScript engine on
Android, and Rhino just didn't cut it. Adding the Node integration was
(theoretically) pretty easy, although because of how Node.js is linked on
Windows, it gave me some headaches.

Part of why I did the Node / Java integration was to see if there are any use
cases. We'll see, I hope someone finds it useful, and if not, I learned a
tone.

------
edgarespina
I built an asset compiler
[http://jooby.org/doc/assets](http://jooby.org/doc/assets) on top of j2v8. It
runs jshint/ugligy/babel... without installing node.

The asset compiler has a maven plugin, so from Java developer perspective is
very very useful.

Now with node.js on the JVM will play and see if my asset compiler to use
grunt now.

Thanks Ian!

~~~
irbull
Thanks for letting me know what you are doing with J2V8. I can add jooby as a
link on the main J2V8 GitHub (under the Who is using J2V8) if you'd like.

Regarding Grunt / J2V8, I got this working. However, I had to play with my
working directory so Grunt could find it's dependencies. I will blog about
this.

