openHAB JavaScript support after Nashorn JavaScript is discontiued

javascript
Tags: #<Tag:0x00007f51df120358>

(Henning F. Mettge) #1

Hi,

I changed nearly all my rules to JavaScript via JSR223 and the great work of @lewie.

Now I read that Nashorn is discontinued (German: https://jaxenter.de/nashorn-javascript-engine-rhino-interview-73088). As I understood openHAB uses Nashorn as implementation of JavaScript. Now my question: What will happen with JavaScript support in the future? Is it discontinued as well???

Thanks in advance!
HFM


(Kai Kreuzer) #2

Not anytime soon. Nashorn is still available, also on recent Java versions - and on future ones, it should be possible to be separately installed. So I don’t think that anyone wants to drop support from openHAB (although the majority of JSR223 users seem to prefer Python over JS…).


(Hilbrand Bouwkamp) #3

I suspect it will be replaced with GraalVM some day as that seems to be the future after Nashorn. Which would mean JavaScript would be fine. It will probably be more relevant for jython users in that case as Graal support python 3 and jsr223 is based on python 2.


(Henning F. Mettge) #4

Thank you both, @Kai and @hilbrand for your fast reply.

So, I am future proof with my JavaScript implementation. That’s good. :slight_smile:
And I don’t know why they prefer Python over JS as JS is the glue of the web.

Bye
HFM


(Helmut Lehmeyer) #5

They are already working hard to replace the outdated Nashorn engine: Oracle GraalVM announces support for Nashorn migration


(Henning F. Mettge) #6

So no fear. :slight_smile:
Thank you, @lewie!


(Eyal Cohen) #7

@HFM

I had the same concern, see here


(Rich Koshak) #8

Nothing is future proof, but you should be mostly OK for quite some time. The GraalVM page Helmut posted does indicate there are some incompatibilities which may cause some work on your part.

Because home automation is as much about glue of the web as it is glue of hardware and thanks to RPi, there is far more “hardware glue” written in Python than JS. Having learned both, in my opinion Python is also easier to learn and there are more libraries available. And on OH, the Jython users are by far the most active on this forum. I’m not saying that any language is better than others and I myself will be migrating my own Rules to JS using the NGRE in the near future. But it is perfectly understandable why Jython is more popular in this instance.


(Helmut Lehmeyer) #9

I also see an enormous advantage in the variety of languages that can be used. The abstraction of the scripting interface opens a lot of possibilities which are not foreseeable at the moment.

An advantage for the entrance into openHAB is surely, everyone can use scripts in the language he knows or which is particularly suitable for a certain purpose. Connections to foreign API in a certain language are even easier to realize.

Javascript, Jython and Groovy are only three of theoretically over thirty usable languages and dialects, some of which are very specifically designed for certain requirements: https://stackoverflow.com/questions/20013310/java-scriptengine-supported-languages

As an ingenious tool, the scripting interface of openHAB is enormously well equipped for the future. It is an ingenious part of the openHAB architecture.

Provided, of course, that the java support for the ScriptEngine is further developed and not terminated.


(Rich Koshak) #10

It should be mentioned though that there was some effort to use JRuby but there was some problem with how it worked out how the OH classes worked that made it unusable. Perhaps that is no longer the case.

I’d like to take a shot at a functional language some day. I always did love coding in Scheme. :wink:

I completely agree, more choices is better.