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.
Guangyu says:
April 12, 2012Good news! I have downloaded the newest version, It’s awesome.
Thanks for the great work!
Neil says:
April 12, 2012Great! I’m anxious to try it out. Could you fix the code snippet formatting in the online documention? Newlines in the text are not included (or something) and the code appears mostly on one line which obviously makes it very hard to read. I am using IE7. For example, the code example on this page is displayed as 8 lines.
Andrey Breslav says:
April 12, 2012IE support is on the way (for now, you can use Chrome or FireFox)
Sergii Rudchenko says:
April 12, 2012Thanks! I’m eager to get started with Kotlin as a main language 🙂
Andrey, are there any plans on Android support?
Andrey Breslav says:
April 12, 2012Yes, there’re are. Some users report that basic Kotlin code runs fine on Android now.
Jan Kotek says:
April 12, 2012Great, this is best news of this month for me. Thanks guys.
Bikal Gurung says:
April 13, 2012What is the status of the javascript backend for this release? And also do you have any release date for the final product, i.e. version 1.0? Is this happening this year or in the next few months?
Andrey Breslav says:
April 13, 2012The JavaScript back-end is working, but the IDE UI and other tools do not provide access to it yet. This will be fixed pretty soon.
On the release date: no, we don’t have a date for 1.0, because we think that a language is ready for a release after massive validation, i.e. production use. So, JetBrains is going to use Kotlin in production for a while, and only then release a 1.0. Of course, a stable beta will be available earlier.
Tommy says:
April 13, 2012I think you have a great opportunity here if you can make the Javascript backend supported fully.
With it working I see no use for Google Closure, Coffeescript and lots of other projects.
Please grab that opportunity.
Andrey Breslav says:
April 13, 2012We will. Thanks
Mirco says:
April 21, 2012Yes! Full Javascript support would be great. The world is craving for a modern statically typed language compiling to javascript with an great mature IDE.
Vadim says:
April 16, 2012What about compilation speed? Have you measured it (comparing to Java and Scala)?
Andrey Breslav says:
April 16, 2012To measure compilation speed properly we’d need a big Kotlin codebase that does not exist yet. Some micro-measurements show that there’s quite some space for improvement in compilation speed, and we are working on it constantly. To date, no language feature seems to be a performance blocker in Kotlin, though many optimizations and a lot of profiling work is to be done.
Roadmap de #kotlin | Kotlin.es says:
August 22, 2015[…] oficial en inglés, […]
Pavel says:
May 12, 2017Congrats!
Could you provide a tutorial to build simple kotlin-native app with IntelliJ Idea?
Kotlin/Native v0.2 is out (Official announcement from Jetbrains) | Ace Infoway says:
May 12, 2017[…] is out (Official announcement from Jetbrains) {$excerpt:n} submitted by /u/michalg82 [link] [comments] Source: […]
Nikolay Igotti says:
May 12, 2017IDE support for Kotlin/Native is in progress, you may try to use Gradle support in IDEA along with Kotlin/Native Gradle plugin (see https://github.com/JetBrains/kotlin-native/blob/master/GRADLE_PLUGIN.md)
Kotlin/Native v0.2 发布,将 Kotlin 编译成机器码 | News Pod says:
May 13, 2017[…] 发布主页 […]
Clóvis Valadares says:
May 14, 2017When a windows version?
Nikolay Igotti says:
May 14, 2017Windows version is being worked on, but we cannot provide ETA yet.
Al says:
May 14, 2017Does the existence of Kotlin Native mean there will be proper tail call elimination even without the JVM supporting it? I’ve always felt that lacking this is annoying considering it’s entirely technically possible even on the JVM if resources were invested to make it a reality (it’s just not important to Oracle’s customers for Java). Even Microsoft’s F# supports these optimizations despite running on the CLR.
Nikolay Igotti says:
May 14, 2017For tail recursion case there’s ‘tailrec’ keyword, which is being supported in Native as well. For other cases, tail call elimination could be done by LLVM backend for some cases.
Marcel Bradea says:
May 19, 2017Guys where are Kotlin feature requests tracked? Can’t find anywhere to post this.
Anyways our feedback from maintaining a full dual-platform Swift/Kotlin codebase (same engineer implements features natively in both platforms) is that there are still several features that Kotlin as a language still lacks in order to be on par with Swift and thus iOS.
One in particular that comes up constantly is the lack of lateinit in delegated properties.
ie: There is essentially no way to convert the following Swift code in Kotlin:
The closest Kotlin equivalent forces the variable to be optional, which loses the semantic and is against the whole Kotlin/Swift optionals movement (ie: forces you to use a nullable field for something that is semantically non-null):
Of course the real solution is to allow ‘lateinit’ to be used in conjunction with delegated properties:
Nikolay Igotti says:
May 19, 2017Please use Kotlin issue tracker here: https://youtrack.jetbrains.com/issues/KT
Alexander Udalov says:
May 19, 2017Wouldn’t declaring a custom delegate help here?
Marcel Bradea says:
May 19, 2017Thanks for that example Alexander.
I bring this up in particular because if you are to support iOS native, this is an extremely common scenario in literally every Swift codebase I have seen – and has no current out-of-box Kotlin equivalent.
I don’t think requiring teams to make their own custom delegated properties is the way. This needs to be standardized and provided either at the language level or in the base Kotlin libraries (ie: delegates.observable).
I’ve filed an issue for it here: https://youtrack.jetbrains.com/issue/KT-17979
Congrats again to the huge Android/Google news guys.
Roman says:
May 20, 2017Have you done any benchmarking of Kotlin Native vs Kotlin JVM ? Which one is expected to have better performance?
Nikolay Igotti says:
May 20, 2017Performance is multidimensional notion, so it really depends on what is measured. Startup performance, memory management pauses and pure computations are likely better with Kotlin/Native, while massive object manipulations shall be better with Kotlin/JVM. Also note that current Kotlin/Native runtime wasn’t optimized, unlike modern JVMs, where thousands engineer/years spent on optimizations.
Roman says:
May 20, 2017I see, so it depends on particular application. Is it possible to use two runtimes simulatneousy and how interop will look like? Can I for example call K/N funciton from K/JVM and pass reference to JVM managed object as a parameter?
Nikolay Igotti says:
May 20, 2017Kotlin/JVM -> Kotlin/Native interop is not currently supported, beyond generic Kotlin/JVM -> C interop. Arbitrary object interoperability is unlikely to be supported soon.