Kotlin logo

Kotlin

A concise multiplatform language developed by JetBrains

Releases

Kotlin/Native v0.2 is out

We’re happy to announce the release of Kotlin/Native v0.2, a feature and bugfix update to Kotlin/Native Technology Preview. This update adds support for coroutines and cross-module inline functions support, along with bugfixes and improvements all over the place.

This release includes samples showing how to use coroutines for concurrent non-blocking IO, a GUI application using GTK, as well as a TensorFlow machine learning framework client contributed by Julius Kunze.

For example, code as easy as

var connectionId = 0
acceptClientsAndRun(listenFd) {
  memScoped {
    val bufferLength = 100L
    val buffer = allocArray<ByteVar>(bufferLength)
    val connectionIdString = "#${++connectionId}: ".cstr
    val connectionIdBytes = connectionIdString.getPointer(this)
    try {
      while (true) {
        val length = read(buffer, bufferLength)
        if (length == 0L) break
        write(connectionIdBytes, connectionIdString.size.toLong())
        write(buffer, length)
      }
    } catch (e: IOException) {
      println("I/O error occurred: ${e.message}")
    }
  }
}

can be used to process multiple concurrent socket IO with coroutines and serve each client individually and concurrently.

And to create a GTK button with an event listener, just do:

 val button = gtk_button_new_with_label("Click me!")!!
 g_signal_connect(button, "clicked",
   staticCFunction { _: CPointer<GtkWidget>?, _: gpointer? -> println("Hi from Kotlin") }
)

So v0.2 release allows  to create fully functional small-footprint native applications written in Kotlin.

Both compilation and runtime performance were significantly improved, size of redistributable decreased.

The complete list of changes in this release can be found in the changelog.

Pre-built binaries for Linux and MacOS hosts are available.

image description