Cross-Language Mod Development

Discussion in 'Mod Development' started by Hlaaftana, Sep 5, 2015.

  1. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    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: Sep 14, 2015
  2. FyberOptic

    FyberOptic Over-Achiever Mod Developer

    I'm not really the most experienced with Python to begin with so this is getting into black magic territory even for me.
  3. sgbros1

    sgbros1 Popular Member

    What syntax style is Jython following? Java or Python?
  4. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    It's Python written in Java, and compiles into bytecode, so Python.
  5. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    still love you
  6. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    update: screwed something up with installation of jython, eclipse completely hates jython
  7. Hea3veN

    Hea3veN Active Member Mod Developer

    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.
  8. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    From what I recall, Jython uses Java annotations directly. Perhaps I'm wrong...
  9. Tejti

    Tejti New Member

    How do you people even come up with this stuff o_O
  10. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    you don't

    they come up with you
  11. Tejti

    Tejti New Member

    I've had some free time recently and I think I can help you with this. Would you like a tester?
  12. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    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.
  13. ljfa

    ljfa Too Much Free Time FTB Mod Dev

    Heh, rather than Python I tried it with Clojure:
    Kinda painful to interface with Minecraft or other Java code from there, but at least the annotations work. And it is okay with Eclipse ^^

    Let's make an "esoteric languages for mods" thread :p
    SatanicSanta likes this.
  14. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    Or "esoteric ways to develop mods". I'm going to test JRuby and Groovy later (well JRuby because a lot of people like Ruby here), and just look at the remaining possibilities.
  15. ljfa

    ljfa Too Much Free Time FTB Mod Dev

  16. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    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.
  17. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    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.
  18. Strikingwolf

    Strikingwolf Philosopher and Programmer FTB Mod Dev

    Scala is officially supported iirc, but you could still add it
    SatanicSanta likes this.
  19. SatanicSanta

    SatanicSanta Wiki Steam Witch Wiki Staff FTB Mod Dev ModMyMC Editor

  20. Hlaaftana

    Hlaaftana Well-Known Member Mod Developer

    I'm aware Scala is supported. I wasn't gonna add it, but perhaps I can provide some utilities and tutorials in the OP.

Share This Page