I think Sponge needs a scripting language

This is simple, all this has to do is be a plugin:

  1. It wouldn’t bloat the API
  2. It wouldn’t be reliant on sponge devs for an update
  3. It would allow for server owners to choose out of multiple script plugins the language they want
2 Likes

We might add some official scripting languages very much later on, but it’s not on the table at the moment.

Also, Java has excellent debugging facilities where you can set breakpoints, inspect the state of variables, etc. Heck, if you are/were developing Bukkit plugins in your IDE, you never even had to compile your plugin or build a plugin .jar. Just hit run and you’re in business.

Even reload your Java code changes without having to restart the server or your plugin.

IDEA

2 Likes

@sk89q sorry to say but none of those things are special. JS, Python, and Ruby all have those features.

1 Like

Hi,
There’s a couple of differences between Rhino and Nashorn (too many to list here). I maintain ScriptCraft which is a JS layer on top of Bukkit - it provides an in-game JS REPL, a fluent building API and easier event-handling. I posted an open letter to Mojang asking them to consider scriptability in the (then) forthcoming API. http://walterhiggins.net/blog/Open-Letter-Mojang . Obviously things have changed now.

There are a couple of things the Sponge developers should consider to make the API scripting-friendly. Where possible they should provide API calls which don’t rely on Java Annotations. You can see an example of this in Canary Mod’s Event handling code here…

https://ci.visualillusionsent.net/job/CanaryLib/javadoc/src-html/net/canarymod/hook/HookExecutor.html#line.71

… Where the developers have gone the extra mile to provide an API call for non-Java languages. Annotations are great if your plugins are Java but other languages don’t have them. To make SpongePowered’s API scriptable don’t provide API calls which rely solely on Java Annotations.

Walter

You’re right. Scriptablity requires some thought about the kind of back-end API calls to provide. Specifically, the API calls should not assume that Annotations will be present. It’s fine to provide API calls which require them, but the API designers need to also provide equivalent API calls which don’t require Annotated java objects.

Sponge doesn’t need a Scripting Language - it just needs to support Scripting Plugins. What does support Scripting mean? Simple: Provide APIs which don’t assume or rely on Java Annotations. Bukkit’s API was Annotation-agnostic (it had API calls which relied on them but also equivalent methods which did not need them) and (from what I’ve seen so far) so too is Canary Mod’s . The following links are to code - the first link is to a method which does rely on java Annotations, the 2nd link is to an equivalent method which doesn’t. As the comments in the code say, the 2nd method can be called from Scala, Javascript (Rhino/Nashorn) or any other scripting language supported by the JVM.

Java-only API:
https://ci.visualillusionsent.net/job/CanaryLib/javadoc/src-html/net/canarymod/hook/HookExecutor.html#line.28

Equivalent Language-agnostic API:
https://ci.visualillusionsent.net/job/CanaryLib/javadoc/src-html/net/canarymod/hook/HookExecutor.html#line.71

The core sponge devs don’t need to provide a scripting language, they just need to provide APIs which don’t rely on Java Annotations.

7 Likes

JS, Python and Ruby do not have all of that to the extent Java has. They dont easily allow for state inspections, thread snapshots, breakpoints etc.

Very well written, and an excellent example of abstracting whats necessary for a feature to be added, and what can be a seperate project/plugin. Thank you.

I wasn’t implying that other languages did not have those features.

However, discussion above seemed to imply that Java did not support variable inspection.

Not true. Ruby and Python have that.

Also js in chrome

Amazing. In chrome. You do realize we are talking about debugging them on a server? In the console, or, even worse, ingame? None of those features will be available to you there. Also, languages like Ruby and Python pretty much drop out anyway, because they are module-based. I personally am all for having scripting languages. But not in Sponge. If you wan’t it, make a plugin that adds it. This is just not something that belongs into an API.

1 Like

What do you mean module based? How does that cause a problem?

I plan on writing a plugin for sponge kind of like Skript for bukkit - it will allow basic scripting, but it would be designed for users who just want to make a few quick custom commands, or perform custom actions when an event happens. Nothing too major

The language itsself is very limited without modules. (What you import)

How does that matter? You import stuff all the time in Java.

But it’s in the Java Standard Libraries or Minecraft, Forge, FML. The language Minecraft is written in is Java. You would have to provide all the python modules with the scripting engine. It’s interpreter is way more complex than LUA or JavaScript interrpreters. It uses native libraries. Python modules are often OS-dependant.

You need to write an article on your website to tell others how to set this up.

Sponge use the BukkitAPI

  1. No
  2. No
  3. No

I don’t want to be an asshole. But did you actually understand the point of Sponge?

1 Like

I speak with an developer