Paul Krill
Editor at Large

Kotlin unveils K2 compiler

news
Jun 13, 20222 mins

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

speed fast race car shutterstock 1168856884
Credit: Jamesboy Nuchaikong / Shutterstock

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 stabilizing 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:

  • Definitely non-nullable types have been promoted to stable. These provide better interoperability when extending generic Java classes and interfaces.
  • 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.
  • Opt-in requirements are now stable and do not require additional compiler configuration.
  • An underscore operator for type args can be used to automatically infer a type of argument when other types are specified.
  • 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.

A beta release of Kotlin 1.7.0 was published in May. Kotlin 1.6.20 arrived in April.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author