Cross-Language Mod Development

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Hlaaftana

New Member
Jul 29, 2019
304
0
0
This thread isn't really useful unless you're really passionate about a language.

Some programming languages in here may not be easy. If they do not compile directly into bytecode, you can't use them 100% in your mod and you still need to learn Java, lowering the usefulness of the "compatible" programming language.

If they do compile directly into bytecode, they're going to involve compiling (when manual, running the compiler command everywhere) which might get tedious. Some of them have support for Gradle, making it easier when someone's worked on it.

Forge already adds support, you don't need to do much. I'd recommend the Eclipse Scala IDE plugin, really awesome. This one is an outdated but still somewhat valid tutorial. I recommend the Project Red Git repository or another overlooked mod called Project XY.

@ljfa would be credited for this one.

Here's a proof of concept project written in Clojure, which adds commands ingame for Clojure code. Clojure can compile into bytecode.

You need to have the Jython standalone jar, and the user needs to have it in the mods folder (in which it would be injected into the classpath).

Following this tutorial, you should be able to do a lot. Jython does not compile into bytecode, and its developers don't really update the project anymore, leading to further incompatibilities.

I would recommend PyDev, but I don't really think there's any good Jython IDE. Still, use PyDev.

Pretty much like Jython, except JRuby has a compiler (how to use it) that compiles into bytecode. You can find tutorials on how to call Java from JRuby here. Even more information about JRuby can be found here. The JRuby jar needs to be in the classpath like the Jython jar too.

@trajing has experimented with this before, and his work can be found here. I have taken some inspiration from him, since I don't know much about how JRuby works. I haven't tested it myself.

This one is probably the easiest after Scala. It compiles directly into bytecode.

I 100% recommend (and would kind of require) searching for "Groovy" on the Eclipse marketplace and installing the first result. It has a built-in compiler which gets rid of the manual compiling. Do note that this plugin needs Eclipse Mars instead of Eclipse Luna. Forge GradleStart works with it :D

This has been tested and it does work. Proof
and git repo

I love Groovy at this point, and if you love it too, I'll create a GitHub repo to demonstrate how it works. Well, most Java code can basically be used as Groovy code, so I don't think you should have any problems.

If you have any trouble or need help, feel free to ask. I won't ignore any questions.
 
Last edited:

FyberOptic

New Member
Jul 29, 2019
524
0
0
I'm not really the most experienced with Python to begin with so this is getting into black magic territory even for me.
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
update: screwed something up with installation of jython, eclipse completely hates jython
 

Hea3veN

New Member
Jul 29, 2019
12
0
0
Python's decorators are a different concept from java's annotations. I'm not sure how Jython implements java annotations, but you might need to wrap them some how to get to the same result. I've considered before trying to use Jython to create mods, but never actually tried it.
 

Tejti

New Member
Jul 29, 2019
6
0
0
I've had some free time recently and I think I can help you with this. Would you like a tester?
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
I've had some free time recently and I think I can help you with this. Would you like a tester?
Do you really think it's worth it? I don't really like this because it's something no one will use. I can still give you several instructions via PM in order to make this work.
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
I knew about that thread, hence this thread was at first a carbon copy of it.
JRuby isn't much different from Jython. You still can't write main classes easily (somewhat due to the fact that it hates defining variables using types). Eclipse isn't compatible with Ruby I believe, and I couldn't find any plugins that are compatible. However, JRuby is much faster and supported, making it more useful.

EDIT: Forgot JRuby had a compiler. This changes a lot.
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
OK, JRuby's (untestedly and completely by theory, perhaps improved tomorrow) somewhat done. The reason @trajing's version didn't work (after your changes) was because the source jars weren't in the JRuby classpath. A few ways to do that are in one of the tutorials I put in.

Hopefully I won't disappoint with Groovy, since it's incredibly easier and I'd seriously love to work with it. It's basically a Python-Scala hybrid as an entirely different programming language. I'm keeping this here for tomorrow, I'll start then.
 

Hlaaftana

New Member
Jul 29, 2019
304
0
0
I'm aware Scala is supported. I wasn't gonna add it, but perhaps I can provide some utilities and tutorials in the OP.