Menu
Kotlin unveils K2 compiler

Kotlin unveils K2 compiler

Kotlin 1.7.0 introduces an alpha version of new K2 compiler and new approach to incremental compilation in Gradle.

Credit: Dreamstime

JetBrains has released Kotlin 1.7.0, an upgrade to the language for JVM, web, and mobile development that features an alpha version of the game-changing K2 compiler.

In addition to improving performance, K2 is intended to speed up development of new language features, unify platforms Kotlin supports, and provide an API for compiler extensions. The alpha version, however, only works with JVM projects. And no compiler plugins except the kapt plugin for annotation processors work with it yet.

Kotlin 1.7.0, introduced June 8, also offers a new approach to incremental compilation in the Gradle build automation tool, with compilation now supported for changes made inside dependent modules. Support for compilation avoidance also has been improved. 

Gradle, like Kotlin, is leveraged in the development of Android mobile applications. Plans call for stabilising the compilation technology and adding support for other back ends, such as JavaScript.

Instructions for getting started with Kotlin can be found on the Kotlin Kotlin language website. Other capabilities highlighted in Kotlin 1.7.0 include news that definitely non-nullable types have been promoted to stable. These provide better interoperability when extending generic Java classes and interfaces.

Meanwhile, builder inference, a type inference that is useful when calling generic builder functions, is automatically activated if a regular type inference cannot get enough information about a type without specifying the -Xenable-builder-inference compiler option introduced in Kotlin 1.6.0 last November.

In addition, opt-in requirements are now stable and do not require additional compiler configuration while an underscore operator for type args can be used to automatically infer a type of argument when other types are specified.

Furthermore, implementation by delegation to an inlined value of an inline class is enabled. Developers now can create lightweight wrappers that do not allocate memory in most cases. Also, a beta release of Kotlin 1.7.0 was published in May. Kotlin 1.6.20 arrived in April.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags JetBrainsKotlin

Events

ARN Innovation Awards 2022

Innovation Awards is the market-leading awards program for celebrating ecosystem innovation and excellence across the technology sector in Australia.

EDGE 2022

EDGE is the leading technology conference for business leaders in Australia and New Zealand, built on the foundations of collaboration, education and advancement.

Show Comments