Hashorn ES6 in jArchi

Started by rchevallier, April 05, 2020, 14:38:33 PM

Previous topic - Next topic

rchevallier

Hello all,

I'm quite desesperate with the low support of ES6 standard in Nashorn: no class support, missing methods for standard collections (eg: <Array>.includes, <Object>.keys(), ...), const/let/var behaviour

I've seen in the jarchi jRuby and groovy branches
Are these langages accessibles in jArchi? (if yes, how? If not? when?)
Any limitations like for JS known ?

In the meantime, is there a way to have a jArchi JS interpreter window in Archi? It would help the debugging and tuning of .ajs scripts

Phil Beauvoir

Setting the jArchi JavaScript Engine Archi Preference to "Nashorn ES6" will enable a few ES6 features, but not much. Nashorn is what it is, and we have to make the best of it. I've not looked properly at GraalJS for a while, but maybe there are possibilities to be explored there as an alternative to Nashorn (perhaps someone could research this?).

I've added jArchi plug-ins for the Ruby and Groovy languages in GitHub but they are experimental and are not supported by me or JB. They work, but because the jArchi API is designed to reflect the JS language some of the language constructs are not optimal. I'm not going to officially distribute them because I don't want to have to answer Ruby and Groovy questions, as I don't know those languages, or deal with other issues. But people can get them from GitHub if they want them.

>  is there a way to have a jArchi JS interpreter window in Archi?

Do you mean to run a jArchi script in a text box in Archi? Or something else?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier

Thanks for your reply

I was expecting Groovy, being a true JVM language with a simpler Java syntaxe, a better and simpler integration with the Archi application and the SWT libraries. I understand the issue of support, and likely GraalVM will be the answer one day.

> Do you mean to run a jArchi script in a text box in Archi? Or something else?

I mean a REPL window, where you can interactively write JS statements, and get the result, with the jArchi api available. Like a Nashorn JJS window inside archi (will need a Stop/kill switch in case of endless loop/runaway code). In the absence of a debugger, the simplest /closest thing to be able to tune/debug a script as it avoids the need to put trace everywhere to understand what's happening(console.log)

Phil Beauvoir

It would be possible to have a simple text window in Archi where you could type JS/jArchi code and run it, rather than from a file, but things like debugging/breakpoints/syntax checking, etc would be a whole project in itself so that's not something easily done.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier

> It would be possible to have a simple text window in Archi where you could type JS/jArchi code and run it, rather than from a file,

Yes!  :D

> but things like debugging/breakpoints/syntax checking, etc would be a whole project in itself so that's not something easily done.

A full ide/debugging env is not necessary. The problem I have is that under another JS environment (ex: node.js, nashorn jjs), I don't have the jArchi objects/api so I cannot run the script to test/check. To just be able to see the result of some jarchi/swt api use, will speedup writing jarchi script IMHO

A kill switch if possible would be great so you don't have to kill the full Archi application in case of endless loop or the like. This apply also to the script run. Maybe tough to implement in the current architecture (?) :-\

Phil Beauvoir

I've already done a POC for a simple text window - https://github.com/archimatetool/archi-scripting-plugin/tree/run-local-script - all it does is run a script as a string rather than as a file. The same limitations apply. I tested it and it was useful for simple things like trying out a new method etc.

But...(and I know 100% this would happen) users will find it too simple and then ask for syntax highlighting, line numbers, debugging, breakpoints, a whole IDE...etc etc... ;-)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier

It's the ransom of success  ;D

-- When you do a god job, people wants more. That's doesn't happen when the job is shady