What about Kotlin as a scripting language?

What do u think about it? Kotlin is kompiling to java byte-code, so i think it will have no problem to use it. Did developers of jME3 say smth about it?

From my experience Kotlin in way more than a scripting language. It’s totally interoperable with Java, meaning you can probably make your whole game in Kotlin using JME jars already, without too much effort.

I tried it a bit and it’s very nice. A lot of nice “modern” language patterns like lambdas, optionals and so on, but completely integrated to the language with plenty sugar. Also it has a more functional orientation than Java, the programmatic unit is the function, and not the object.

Another interesting stuff is that it can be compiled to native effortlessly. I didn’t dig too much into it, and I don’t know how it would work if you use java libs, but you can compile targeting a platform, and you won’t need java to be installed on the target os. So it can open doors to ios and webasm for example.
I know this is kind of an anti pattern for to Java… but to me the cross platform part of java never really worked seamlessly.

For what it’s worth, if I had to pick another language than Java, I’d probably go to Kotlin.

4 Likes

So i need to use it in another ide with libs of jme to create game on kotlin, right? But i cant do it in jme ide?

Maybe there is a Kotlin plugin for netbeans, that you could use in JME SDK.
Else intellij has Kotlin support in its free version.

4 Likes

Kotlin also compiles to JS for web development. The issue with targeting non-JVM deployment with Kotlin is that you can’t use Java libs anymore - any libs written in Kotlin are fine because the compiler can produce native/JS/whatever from the source, but pre-compiled code is out. You can use libraries for the target platform (for JS it relies on TypeScript type definitions for JS), but not sure how it handles native libs.

Another interesting feature of Kotlin are type-safe builders. They allow you to build simple DSLs. This could have plenty use-cases in game development. You could build for example a “story-DSL” which enables users to write their own story lines without the knowledge oft a complicated programming language.

And in my opinion it is very easy to integrate Kotlin in your project if you use gradle.

Scala is another example of a language that compiles to Java Bytecode.

-This comment is not endorsed by its author -

1 Like

As is Groovy… and it also has builders, first-class lambdas, etc., etc…

GraalVM can make a native image of any java application.

I meant you can do it natively with the language.
GraalVM looks nice, but the fact that it doesn’t work on windows make it a bit moot to me.

The last version works on Windows as well

2 Likes

That’s cool

It’s not clear from your question what actually do you want to do: compile it to the bytecode or use as a dynamic scripting language. Either way, here’s my two cents on it:

  • As a replacement for the Java language: it works wonderfully. I am currently developing my project in Kotlin and it compiles to desktop and Android without any problems. The language itself is much better than Java. I have tried other JVM languages too, like Scala, Clojure and Groovy, but Kotlin would be my number one replacement for Java today.

    I must say that this is not so much due to the language itself, which is of course great, as to the seamless tooling and excellent application build process and deployment support, all available from the AndroidStudio or IDEA. I found deployment and Android compatability issues to be much of a problem for Clojure and Groovy.

  • As a scripting language: yes, it is possible too, though I did not try it out yet because scripting in my current project is done in JLua. I might be looking into experimenting with the Kotlin scripting support in the future. Here are some links that highlight this feature and can take you straight to testing it out: Run Kotlin Scripts from Kotlin Programs - Kotlin Expertise Blog , maven - Kotlin JSR-223 ScriptEngineFactory within the fat jar - Cannot find kotlin compiler jar - Stack Overflow