Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Latest commit

 

History

History
72 lines (63 loc) · 2.76 KB

Kotlin_Native v0.2 is out.md

File metadata and controls

72 lines (63 loc) · 2.76 KB
title date author tags keywords categories reward reward_title reward_wechat reward_alipay translator translator_url source_url
Kotlin/Native v0.2 is out
2017-05-12 04:08:00 -0700
Nikolay Igotti
官方动态
false
Have a nice Kotlin!

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

{% raw %}

{% endraw %}
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}")
    }
  }
}

{% raw %}

{% endraw %}

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:

{% raw %}

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

{% raw %}

{% endraw %}

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.