A first look at Kotlin 1.1
Kotlin 1.0.X releases are in the pipeline, but the JetBrains team is also working on the new language features in Kotlin 1.1. Here is the first preview version of 1.1.
Andrey Breslav, the lead language designer of Kotlin at JetBrains, offered a first glimpse of Kotlin 1.1 although he warned that it is “far from Beta.” Because it is not a stable version, Breslav gives no compatibility guarantees. However, he claims that syntax, APIs, command-line switches and anything else may be changed in the future previews of 1.1.
What’s under the hood of Kotlin 1.1?
“Many languages support asynchronous programming through dedicated language constructs such as
await keywords,” Breslav wrote in the blog post. The JetBrains team generalized this concept so that libraries can define their own versions of such constructs. Plus,
async is just a function, not a keyword. This design allows different asynchronous APIs to be integrated: futures/promises, callback-passing, etc.
Coroutines represent one of the biggest features of Kotlin 1.1.
According to Breslav, one of the greatest parts about coroutines is that they can suspend without blocking a thread, and still look like normal sequential code. Here is the detailed description. Coroutine-based libraries will be included with the Standard Library at a later time. This includes JDK’s
CompletableFuture, asynchronous IO (NIO), RxJava, and off-loading tasks from the UI thread in Swing.
The team is actively working on the improved support for Java 8 and is adding new functions to the Standard Library. As they rely on Java API version newer than 1.6, they also introduced new artifacts such as
kotlin-stdlib-jre8 that carry extra functionality such as
AutoCloseable.use(), Regex named groups support and stream-related functions.
Find the full changelog for 1.1 M01 here.
How to give Kotlin 1.1 a try
For those who are already running Kotlin 1.0.3, 1.1 can be installed as follows:
Tools → Kotlin → Configure Kotlin Plugin Updates. Select “Early Access Preview 1.1” in the Update channel drop-down list.
Press Check for updates in the same dialog, then Install when you see the new version.
All you need to do is add https://bintray.com/kotlin/kotlin-eap-1.1 as a repository to your project and make sure to use version 1.1-M01 for your Kotlin artifacts.
Use the drop-down list at the bottom-right corner to change the compiler version.