Live data from Hacker News

Standalone Nashorn 15.0 is out

mail.openjdk.java.net

21–30 of 35 posts

Re: Standalone Nashorn 15.0 is out

#21
post #20

Hasn't Nashorn been superseded by GraalJS? Is this just for those who are stuck with Nashorn, or will there be new development? GraalJS is ECMASCript 2020 compatible and is said to rival V8 on performance, so I would've thought it the obvious choice for new projects going forward. https://github.com/graalvm/graaljs Edit: found more info about this release in the initial announcement: https://mail.openjdk.java.net/pip…

Isn't GraalJS restricted in usage though? Like it can only be used as part of Oracle GraalVM, not any other JVM distribution?

From the readme:

> The preferred way to run GraalVM JavaScript is from a GraalVM. If you prefer running it on a stock JVM, please have a look at the documentation in RunOnJDK.md.

I'm running it on a stock OpenJDK JVM without any issue, just by including a Maven dependency. For best performance you should run it on GraalVM (where the Community Edition is based on OpenJDK).

Re: Standalone Nashorn 15.0 is out

#22
post #20

Hasn't Nashorn been superseded by GraalJS? Is this just for those who are stuck with Nashorn, or will there be new development? GraalJS is ECMASCript 2020 compatible and is said to rival V8 on performance, so I would've thought it the obvious choice for new projects going forward. https://github.com/graalvm/graaljs Edit: found more info about this release in the initial announcement: https://mail.openjdk.java.net/pip…

Isn't GraalJS restricted in usage though? Like it can only be used as part of Oracle GraalVM, not any other JVM distribution?

The GraalJS license is apparently similar to MIT:

https://github.com/graalvm/graaljs/blob/master/LICENSE

"The Universal Permissive License (UPL), Version 1.0"

And about the UPL:

https://tldrlegal.com/license/universal-permissive-license-1...

"... including an explicit patent grant, clear ability to relicense ..."

Re: Standalone Nashorn 15.0 is out

#23
post #20

Hasn't Nashorn been superseded by GraalJS? Is this just for those who are stuck with Nashorn, or will there be new development? GraalJS is ECMASCript 2020 compatible and is said to rival V8 on performance, so I would've thought it the obvious choice for new projects going forward. https://github.com/graalvm/graaljs Edit: found more info about this release in the initial announcement: https://mail.openjdk.java.net/pip…

Isn't GraalJS restricted in usage though? Like it can only be used as part of Oracle GraalVM, not any other JVM distribution?

JVMCI (the interface GraalJS uses to talk to the compiler, rather than going through bytecode, as Nashorn does) is now a standard part of OpenJDK.

Re: Standalone Nashorn 15.0 is out

#24
In case anyone wants to see a Java (well, Scala) app that uses Nashorn:

https://insightful.demo.talkyard.io/-17/i-can-no-longer-work...

Is uses Nashorn for server side rendering a React.js Single Page App, calling from Scala to Nashorn running React.js code in the same JVM. (I'm developing it. Hmm I should clean up that demo forum.)

Re: Standalone Nashorn 15.0 is out

#25
post #2

For anyone else wondering what Nashorn is: It is Javascript running in the JVM https://en.wikipedia.org/wiki/Nashorn_(JavaScript_engine)

I used it back in the day to provide server side rendering for a Clojure/ClojureScript/Reagent web app. I remember it being a bit of a pig, both in memory consumption and CPU use, but I'm sure that was just relative to the black magic behind V8.

I use it for server side rendering, in a Scala web app. It takes a bit to warm up and JIT compile the Typescript code (transpiled to js), but after that, it's okay fast.

I did a bit comparison with V8 maybe 5+ years ago and at the time, it was about the same speed as V8, from what I could see in a few quick tests — after warmup a lot.

Re: Standalone Nashorn 15.0 is out

#26

Earlier quoted context omitted.

You are using java but want access to Javascript for various reasons. (Maybe you want to add scripting? Maybe you want to use a JS lib? Really sort of depends on the circumstance). Using node/v8 requires another distributable and starting up a new process.

> (Maybe you want to add scripting? Maybe you want to use a JS lib? Really sort of depends on the circumstance) I used it to add Markdown to a Java app, because JS-based Markdown libraries were better than Java-based ones.

I use it to add React.js server side rendering to a Scala app

(more details in this comment: https://news.ycombinator.com/item?id=25248748 )

@cogman10

> > Using node/v8 requires another distributable and starting up a new process

Precisely

Re: Standalone Nashorn 15.0 is out

#27
post #20

Earlier quoted context omitted.

Isn't GraalJS restricted in usage though? Like it can only be used as part of Oracle GraalVM, not any other JVM distribution?

From the readme: > The preferred way to run GraalVM JavaScript is from a GraalVM. If you prefer running it on a stock JVM, please have a look at the documentation in RunOnJDK.md. I'm running it on a stock OpenJDK JVM without any issue, just by including a Maven dependency. For best performance you should run it on GraalVM (where the Community Edition is based on OpenJDK).

Oh that's awesome, thanks for letting me know.

Re: Standalone Nashorn 15.0 is out

#28

Earlier quoted context omitted.

I used it back in the day to provide server side rendering for a Clojure/ClojureScript/Reagent web app. I remember it being a bit of a pig, both in memory consumption and CPU use, but I'm sure that was just relative to the black magic behind V8.

I use it for server side rendering, in a Scala web app. It takes a bit to warm up and JIT compile the Typescript code (transpiled to js), but after that, it's okay fast. I did a bit comparison with V8 maybe 5+ years ago and at the time, it was about the same speed as V8, from what I could see in a few quick tests — after warmup a lot.

That's very interesting. I am guessing ClojureScript generates a lot more code that runs through interfaces that sophisticated JITs can partially evaluate away.

For us, the performance difference was an order of magnitude, to the point that we were too slow in cases for search engines. We were investigating building an external Node proxy instance to prerender pages.

I sincerely hope there's no flag or simple tweak we were missing. It's possible the instances were starved for memory, for instance.

Re: Standalone Nashorn 15.0 is out

#30
post #2

For anyone else wondering what Nashorn is: It is Javascript running in the JVM https://en.wikipedia.org/wiki/Nashorn_(JavaScript_engine)

any good reason to use this over v8/Node?

NodeJS has gone woke and supports Black Lives Matters. They also seem to have a history of social justice battles (as does the company behind V8 that NodeJS is based on, Google). I'm glad for alternatives.
Post reply on HN