Nashorn will be removed from Java 15 - need to migrate to GraalVM
walterhiggins opened this issue · 6 comments
https://golb.hplar.ch/2020/04/java-javascript-engine.html
I don't have time to investigate or work on this myself.
I'd like to throw an option into the ring.
It's not for everyone, and it's not a replacement for ScriptCraft by any means, but I've developed a "ScriptCraft compatibility module" for those who are used to the ScriptCraft environment. Except it works in GraalVM. I will be paying special attention to this compatibility module for the next few weeks, as I think it's important that people find it easy to transition to GraalVM and Grakkit.
You can find it here: https://github.com/grakkit/scriptcraft
While I appreciate Grakkit for what it is, there is no need for anyone using ScriptCraft to migrate to a new plugin. ScriptCraft documentation can be enhanced with links and other assistance to install GraalVM, and a new version of ScriptCraft for JRE 15 can include:
ScriptEngine graalEngine = new ScriptEngineManager().getEngineByName("graal.js");
While this is of course a big deal, this is not at all "life threatening" to ScriptCraftJS.
I understand that @walterhiggins doesn't have the time for this. I'm just trying to help direct the course of this ticket - and avoid the idea that migration away is required.
Let's be clear about what Grakkit is and is not, and I hope @hb432 will get onboard with this.
- Grakkit is a different way of approaching JS for Minecraft. It is/will be a plugin-development option for anyone who already knows JavaScript.
- ScriptCraft has always been a vehicle for helping newcomers to programming to learn JavaScript through their game of choice. It serves as a vehicle for education as well as a tool for plugin development. ScriptCraft has unique value that will never be a part of Grakkit, because Grakkit was created by programmers for programmers, and the people working on Grakkit are not inclined to be a part of the ecosystem of new programmers, educational code camps, and other aspects attributed to ScriptCraft.
So these are two different tools for different purposes. They do not compete. There is no "overtake" scenario. Let's ensure that people are aware of the value of each tool so that they can make informed choices. That starts with a clear recognition of the distinctions of these tools here.
This also implies that effort doesn't need to be added to allow Grakkit to support ScriptCraft. Anyone who is capable of creating a ScriptCraft plugin will have the understanding later to choose one or the other. Given the state of ScriptCraftJS right now, it's extremely unlikely that there are more than just a few plugins where the author might consider preserving the functionality and migration to a new plugin core. SC just isn't that big. If you picture a union (a Venn diagram) of SC plugins with Grakkit (as it develops), the intersect point will be so tiny that compatibility features aren't warranted. Since ScriptCraft is FOSS, there's no harm in copying and incorporating similar features - why recreate code that's already there? But this shouldn't be done with the intent to provide a convenience for migrations ... the SCJS world doesn't have a wealth of established plugins to justify that.
In fact, I would suggest that compatibility features should be left to other developers later, to be created as they require, for PR to Grakkit. This frees @hb432 and team to focus on strengthening the core of Grakkit to ensure it avoids some of the shortcomings that have caused SC to flounder. In other words, help the Grakkit community to grow by leaving secondary addons for others, while you focus on things that they probably cannot or will not do.
And ... appreciating ScriptCraft for what it is, if Grakkit does include internal features that would help ScriptCraft, please consider PRs back here.
@TonyGravagno I have considered your statement, and would have to agree. You make a good point about ScriptCraft being for newcomers, a point which i can understand since I myself started with ScriptCraft. I DO NOT want to compete or "take over" the operation, and to be honest, my suggestions was more of a last resort option, and I should've made that clearer.
ScriptCraft has and will remain to be a very important part of the JS-in-minecraft community. In fact, I'd go as far as to say that it's the most important part. To put it another way, ScriptCraft is like Movie Maker while Grakkit is like Adobe Premiere. Just because Grakkit has more advanced components doesn't make it "better." It just makes ScriptCraft the more accessible option for new players, like you said.
As for the effort required to support scriptcraft, to be fair, it's not that much. The two systems are very compatible with one another. The people that the compat module is for is those who are used to the ScriptCraft environment, but perhaps want to take advantage of grakkit modules as well, without having to move their code and adapt it to Grakkit entirely.
Also, when it comes to PR's, there are a few features which come to mind that might help SC improve. I will get back to you on that sometime later.
So to keep this ticket on-track, ScriptCraft does need to port to GraalVM. Changing to GraalVM from Nashorn isn't tough. But it needs to be done with documentation in a way that makes it easy for others to do. It's not a big technical challenge but more of a challenge in community leadership, social skills, and writing clearly. I recommend doing the change, testing, then explaining it to people in the Google Group and Discord, and if that all works, put the details into a PR here.
I'm spending more time in game these days but that's to get away from all of the time I need to spend in code IRL. If I can create some time I'll see if I can put some effort into this. But at this moment I'm too embarrassed by failed commitments in the past to make new commitments now. Anyone else want to pick up the challenge?
In the compat module repo, there is a copy of the 3 main ScriptCraft folders lib
, modules
, and plugins
(and their contents), all of which have been modified to support GraalVM with nashorn compatibility mode enabled. Check the repository and you will see those 3 folders. Check the diffs to see what I had to change to get it to work. You could mirror these changes or use my files as a starting point -- whatever works.
In addition, grakkit's main.java
also has some code for executing a source file. not sure if you need that but it's worth putting out there in case.
Main java file:
https://github.com/grakkit/grakkit/blob/master/src/main/java/grakkit/main.java