Kotlin 1.3 has arrived

The next major release for the promising JVM language Kotlin by JetBrains has now been published (read the release notes here). The most prominent features of this version are the finalization of coroutines and a beta release for Kotlin/Native. Version 1.3 is an important step forward for Kotlin. With coroutines, the release brings a stable mechanism to the language for writing concurrent applications in a concise and easy to maintain way. Kotlin/Native allows the compilation of Kotlin code into native code for a decent number of target platform. You can, for instance, compile Kotlin code into native executables or libraries for iOS, Windows, MacOS, the web (WebAssembly), and more. Together with Kotlin’s aim to facilitate multiplatform projects, it will be possible to share code between these platforms so that only a single Kotlin code base needs to be maintained.

Coroutines

According to Wikipedia,

Coroutines are computer-program components that generalize subroutines for non-preemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes.

Using this principle, Kotlin allows you to add concurrency to your programs whithout having to explicitly manage and synchronize threads. While conceptually not the same, a concept very much akin to coroutines are reactive streams. Kotlin coroutines allow to interoperate with reactive streams and can be used together with these. This opens a wide range of possibilities for implementing asynchronous and non-blocking applications.

The differences between coroutines and reactive streams are described in this guide.

Kotlin/Native

Kotlin has been offering the option to cross-compile into JavaScript code for some time now. This feature is very handy when developing a web application with a Kotlin backend, since it allows to share the same code between back end and front end. The need to implement specific data transfer objects (DTOs) with the according data mapping and the code duplication for domain objects can be tremendously reduced by that.

This cross-compiling option is taken one step further with Kotlin/Native and multiplatform projects. Kotlin uses LLVM for compiling to native binaries. By that, Kotlin code can run in environments where a virtual machine is not available or not desirable, such as embedded systems or on iOS. Furthermore, it is possible to use existing native libraries, written in C, C++, Swift, Objective-C, and others, and to reuse Kotlin libraries in applications written in these languages.

With WebAssembly being one of the targeted native platforms, you have now a JVM-based alternative to C, C++, or Rust to build web applications without JavaScript that can be executed in a browser like native binaries. This makes Kotlin a very interesting player for the web as a platform, which is especially interesting for developers with a strong Java background.

What’s more

Besides these two important steps forward, Kotlin 1.3 brings some more smaller changes:

  • A beta release for the connected applications framework Ktor which makes use of coroutines. This framework aims at helping to build asynchronous servers and clients in connected systems, e. g. microservices.
  • Experimental support for inline classes which allow to define a kind of a typesafe alias for primitive data types.
  • Contracts to improve static analysis for library calls.
  • … and more.

Full support for the new features will be bundled in IntelliJ IDEA 2018.3 and can be installed into earlier versions by updating the Kotlin plugin.

Short URL for this post: https://wp.me/p4nxik-3c8
Roland Krüger

About Roland Krüger

Software Engineer at Orientation in Objects GmbH. Find me on Google+, follow me on Twitter.
This entry was posted in Other languages for the Java VM and tagged , , , , . Bookmark the permalink.

Leave a Reply