The Complete Magazine on Open Source

Kotlin 1.2 beta brings support for Java 9

1.63K 0

Kotlin 1.2 beta

Kotlin 1.2 beta has arrived with the ability to reuse the code across platforms along with a native compatibility for Java 9 module system. With the new release, developers can finally reuse the code between JVM and JS and build some interesting modern multiplatform applications.

The experimental multiplatform projects option to let developers reuse code between JVM and JavaScript is initially available in beta. Nevertheless, the open source project has plans to expand the support in the coming versions. The code to be reused needs to be placed in a common module.

In addition to the option to reuse code, Kotlin 1.2 beta produces the code for both common and platform-specific parts during the compilation of the project. There is also a way for developers to express dependencies of common code on platform-specific parts via expected and actual declarations. If the declaration specifies an API, you need to type the alias that refers to an existing implementation of the API in an external library.

The standard library of Kotlin 1.2 features a kotlin.math package for mathematical operations in cross-platform code. The math package also offers better precision for math polyfills for JavaScript.

It is worth noting that the compatibility with Java 9 module forest split packages in the new version. The new version also removes the deprecated declarations in the kotlin.reflect package from the kotlin-reflect library.

Kotlin 1.2 also supports an array of literals in annotations and simplifying coding. Additionally, the new version uses a more consistent syntax. Developers can check whether a lateinit variable has been initialised.