One of the reasons why Kotlin community is growing is that (starting from version 1.2) includes support for multiplatform projects. A Kotlin multiplatform project allows to compile the same code to multiple target platforms:
We can target 3 OS for Desktop, the 2 most popular OS for mobile, and Raspberry Pi!
That’s the theory. Let’s check how it looks in practice.
Starting with Kotlin/Native is not easy. Unfortunately there is no dedicated IDE for Kotlin/Native development. The only one in JetBrains family which supports it at this time is CLion, which is problematic for projects looking to be multiplatform with JVM, JS or iOS. And the biggest problem, in my opinion, is that CLion doesn’t support Gradle...
Let’s start our adventure with installing CLion. In order to use Kotlin in our projects, we have to install a couple of plugins, namely the Kotlin plugin which provides core support for the language, and the Kotlin/Native plugin which adds functionality for native support. Moreover, the second plugin give us a couple of existing projects templates. I would recommend you to use the CLion Early Access Program builds, because it contains support for most recent Kotlin/Native plugins.
One more important thing - In order to be able to use CLion, we need to have our project defined using CMake. The Gradle plugins provides us a convenient way to do this using the command: generateCMake. The result is a new file named CMakeLists.txt which allows us to open the project in CLion.
To sum up, we gained some basic knowledge about Kotlin/Native and sample project setup. As you could read there are some pros of using it in our applications, but there are many cons that makes Kotlin/Native really hard to use:
CLion is the only IDE which supports Kotlin/Native, which is problematic for multiplatform projects
CLion doesn’t support Gradle
Lack of API documentation
Lack of support for Kotlin/Native in multiplatform project
Still no stable version
Kotlin Native is still under development, but in my opinion it looks like it can be a great tool in the nearest future.
Despite all the cons I’ve mentioned above I would like to encourage you to give Kotlin/Native a try!