

Ask HN: Can Node.js Replace Mozilla Rhino? - euroclydon

I was reading through John Resig's blogs about testing out different data structures for storing and searching an english dictionary using Javascript. It struck me that he uses Node.js instead of Mozilla Rhino to test and analyze these structures and algorithms, despite the fact that he works for Mozilla. Now I know that Mozilla and John are enlightened enough not to let project sponsorship or ownership get in the way of using the best tool, but I'm curious? How does Node compare to Rhino?<p>Is Rhino dying? Steve Yegge never released Rhino on Rails. Now, also, I know that Node is vastly different, as a platform from Rhino because, in Node, you write entire web applications using chains of callbacks, and Rhino is just a JS interpreter written in Java. But, what are the applications where Node can replace Rhino, either because third party libraries aren't necessary or because the libraries are implemented for Node?<p>I'd like to hear from HN users who've started using Node where they were using Rhino before and also from users who have JS code which will only run on Rhino.<p>I'll start off with a SVG/PDF print server I have written in Rhino which uses Apache FOP and Velocity. I can't imagine Node has libraries to let me do the same thing.
======
vladd
Comparing Rhino with NodeJS is not exactly fair since NodeJS is a server-side
JavaScript engine while Rhino is just a JS engine.

You should compare V8 with Rhino, or NodeJS with RingoJS (one example for the
later: <http://www.erbix.com/documentation/overview/nodejs/> ).

------
olegp
As vladd pointed out, one should be comparing Rhino with V8, especially since
there are other server side JavaScript platforms running on V8 like
<http://www.akshell.com>

Apparently the new Dynamic Invoke feature in Java 7 has resulted in
significant performance improvements in the latest patches of Rhino, but it
still lags behind V8: <http://twitter.com/hannesw/status/39677300169515008>

That being said, performance isn't the only factor, since Rhino offers the
ability to utilize the wealth of well designed and production ready Java
libraries, a much better garbage collector and ability to use more than 2GB of
heap. However, these advantages that Rhino has over V8 will be eroded with
time as more and more of these libraries are reimplemented in pure JavaScript.

A much more interesting question is whether asynchronous I/O will trump
synchronous I/O for web app development. At Akshell we believe that the
concrete advantages that synchronous I/O offers in terms of ease of
development outweigh the potential benefits of increased performance offered
by asynchronous I/O.

------
thedjinn
I have written command line data preprocessing scripts using Rhino and later
ported them to Node. They became significantly faster. Haven't touched Rhino
since that day.

~~~
euroclydon
My print server, written in Rhino, ramps from 65MB up to 130+MB of memory
after a few jobs, which isn't surprising, since it's Java and using a some
heavy libraries.

How much memory does Node use by itself?

~~~
edw
The RSIZ for an instance of `node' running on OS X 10.6 after banging at the
keyboard for a while, but doing nothing of note, is about 12M. The RSHRD is
about 4M.

The numbers are nearly identical for a small-but-not-trivial Node.js-based web
server I wrote that accepts requests and talks talks with Redis.

------
jm4
Rhino is fine if you have to use the JVM. If you have a choice then I would
avoid it. It performs like a pig. The re-throws everything as a
RuntimeException. It uses statics all over the place so having more than one
instance can cause all sorts of weird problems. The documentation is a little
out of date and there are some gotchas that you are left to figure out on your
own. Still, it's the only thing available on the JVM and it actually works so
it's not all bad. I would love to have alternatives to look at, but it's not
to the point where I want to start writing my own. FYI, I'm using it for DOM
scripting in a custom spider.

Also, like someone else said, Rhino is an analog for V8 while RingoJS is an
analog for NodeJS.

------
samuel
I don't think they overlap too much. Rhino's primary use case is Java
scripting, and it's (alleged) low performance probably doesn't matter a lot
since it's just the glue that binds together heavier Java libraries. I know a
handful of apps that use rhino that way: Mirth, Orion Rhapsody, Pentaho's
Kettle...

------
onassar
I heard of Rhino a few years ago, but never got too into it. Node caught my
attention recently because of the copious amounts of plugins that have come
around. Kind of like JQuery; the community is so good that it makes sense that
it's getting much more visibility than rhino. imo.

