Kotlin/Native Tech Preview Announced

 

Kotlin is a JVM powered programming language created by JetBrains, the people behind popular developer IDEs such as IntelliJ, WebStorm, CLion and ReSharper.  Kotlin offers 100% interop with existing Java code, while offering better performance and more concise code.  The recently released Kotlin 1.1 enabled JavaScript support giving Kotlin the ability to run in the browser.  Today they went one step further with the announcement of Kotlin/Native.  Kotlin/Native is a compiler that creates a stand alone executable with no need for a Java Virtual Machine at all.  Built over the LLVM technology suite, Kotlin/Native is in early technology preview for Mac OS, Ubuntu Linux, iOS and Raspberry Pi meaning Windows based developers are currently out of luck, with the following being noted:

Due to significant difference in exception handling model on MS Windows and other LLVM targets, current Kotlin/Native may not produce executables working on MS Windows. This situation could be improved in upcoming releases.

Details of Kotlin/Native from the announcement blog:KotlinNative

Kotlin/Native is another step toward making Kotlin usable throughout a modern application. Eventually, it will be possible to use Kotlin to write every component, from the server back-end to the web or mobile clients. Sharing the skill set is one big motivation for this scenario. Another is sharing actual code.

Our vision for inter-platform code reuse is the following: one can write entire modules in Kotlin in a platform-independent way and compile them for any supported platform (currently these are Kotlin/JVM, Kotlin/JS and the upcoming Kotlin/Native). We call these common modules. Parts of a common module may require a platform-specific implementation, which can be developed individually for each platform. Common modules provide a common API for all clients, but other (platform-specific) modules can extend this API to provide some exclusive capabilities on their platform.

Note that we do not intend to make arbitrary Kotlin/JVM programs runnable on Kotlin/Native or Kotlin/JS. It would be equivalent to implementing another JVM, which is both a lot of work and a lot of limitations for the runtime. We are going another way: providing a common language for all platforms while enabling creation of common libraries through seamless interoperability with platform code.

In moving from the JVM to native code, that does lead to the question of how memory is managed.  This is also addressed in the blog post:

Kotlin/Native is designed to potentially enable different memory management solutions for different target platforms. For example, in the future it may make sense to have a tracing GC for server/desktop platforms, while ARC makes a lot more sense on iOS. Some platforms may only need manual memory management, and get an even smaller Kotlin/Native runtime in return.

This Technology Preview features automatic reference counting with a cycle collector on top, but what the final memory management solution(s) will look like is unknown at this point.

Kotlin/Native is open source and available on github under the Apache 2 open source license.

GameDev News


Scroll to Top