The power of script languages on Gaming Development

Hello monkeys!!

Today I was reading Lemur source and saw some Groovy code, which made me think about the use of scripting languages like those Groovy, Scala and Kotlin for example.

Kowning that those languages has some overhead, because they run on top of JVM but they will be translated to bytecode like Java, and it’s almost impossible to have better performance then Java, since the focus of JVM is Java, I still think it’s useful in many cases, like AI, UI and such.

So my question is: What do you guys use to develop games in terms of scripting language. How to handle the trade-off between performance and quick’n’readable code?. There are some built-in script language on jME3?

Thanks for your time!

Few wrong assumptions:

  • Scala and Kotlin aren’t scripting language, they don’t interprete code at runtime (Groovy includes a compile static mode, off by default)
  • I don’t know about Kotlin but performance of scala are similar to perf of java (sometime better, sometime worst)

for my jME game/lib I don’t use scripting, but I use java8 or xtend (that is translated into .java at compile time). I like static check, and dislike runtime error (=> I don’t like groovy). Xtend is sugar enough so I don’t need scripting.

PS: I’m a daily scala developper who integrate “groovy” to allow users to plug “custom code” in our platform (IoT).

1 Like

When you say it, you mean if you have Java8 Lamda, you don’t use Xtend? I didn’t notice Xtend until now, it seems like an anarchy way of developing Java code :joy:. But it fits on what I was trying to ask on this topic, because there are some times when you have to write a lot of code, like UI and AI, and when using Java you can really spend some time on it’s syntax. So by using languages like Xtend, you can be faster and still have the good and old one .java file.

But now talking about Xtend, this means you don’t use jME3 SDK for coding, right? Also, can you give an example of what kind of logic you used Xtend (UI, AI, Quest System, etc)?

Right, I don’t use the SDK (sometimes to check asset). I use eclipse + atom (I code Xtend with into eclipse, and also compile with gradle).
historicaly, I used java8 for my jME dev because I only target desktop, and I guessed sharing my code in the forum would be simpler in java8 than with scala. Few month ago I re-evaluate Xtend, and it seems mature enough and allow me to generate java 7 code + some dependencies + syntax sugar so it became My language for jME lib, I migrate few lib (eg xbuf stuff).

I don’t have lot of code to share.

For the UI I use jME-JFX

2 Likes

Groovy is very easy to implement in a jME game. Generally you might want to do stuff that should be “moddable” in a scripting language if you go down that route and stick with java for the core code. Speed shouldn’t be an issue at all here.

1 Like

Well, I use Clojure, but not only for scripting. My typical main application and architecture is in Clojure with some spots written in Java. So, Clojure does as the base language and as the scripting language at the same time. It is easy to write plugins with it and it can be interpreted on the fly as well as compiled to bytecode. As for performance… it depends, but with some knowledge you get the same performance as raw Java in most cases, and where not - simply use Java.

1 Like

In my game a lot of logic is done via lua on the shipcomputer side. It allows a way better guarding for unsave code that is user provided.
Performance is fast enough, only bottlenecks i have are gpu and physics, the rest is irrelevant in my game.

Javascript is in every current jvm supported by default, if you want it to programm game’s I dont think so.

1 Like

Just a note: groovy IS Java. It’s not “running on top of Java”. It can be interpretted (sort of) but even still, a groovy class is a Java class. It’s runtime compiling in basically.

For example, you can have some groovy script with:
class MyGroovyClass {
String name;
}

In the script create an instance of that and pass it to Java code… and it’s a real Java object with setName(), getName() and anything else you put on it. It’s not “interpetted”… it’s a Java class.

You will see this phrase often: “Groovy is Java”… because it’s not like other scripting languages in that respect.

1 Like

We’re trying out Javascript using Java 8 and Nashorn.