Kotlin 1.4 will debut a faster compiler

Upgrade to the JVM language due in 2020 will focus on quality and performance rather than adding big features

Kotlin 1.4 will debut a faster compiler
Thinkstock

Plans for Kotlin 1.4, an upgrade to the language due in 2020, include reimplementing the compiler to improve execution speed. 

The developers of Kotlin at JetBrains believe that the focus of Kotlin 1.4 should be on “quality and performance” rather than adding “big” features. JetBrains promises the new compiler implementation will “be really fast, unify all the platforms Kotlin supports, and provide an API for compiler extensions.”

The new compiler implementation will be a multi-year effort, with only some parts of the new technology due to arrive in Kotlin 1.4. Specific plans for the compiler involve:

  • Improved performance, which will mostly be derived from a new front-end implementation. It is expected to be about 4.5 times faster than the existing one.
  • Unified back-ends for generating executables, with internal representations (IRs) of Kotlin/JVM and Kotlin/JS being migrated to the same representation as Kotlin/Native. This will result in sharing a lot of back-end logic and a unified pipeline, to allow most features, optimizations, and bug fixes to be done just once for all targets. New back-ends are not likely to be enabled by default in Kotlin 1.4. A common back-end infrastructure opens the possibility of multiplatform compiler extensions. Custom processing and transformations will work on all targets. There is no public API yet for these extensions in version 1.4 but JetBrains is working with partners, including JetPack Compose, who are building plug-ins.
  • Kotlin Library Format (KLib) is being introduced as a library format for Kotlin multiplatform. Serialized IR is contained in a KLib file. Code can add it as a dependency and the compiler back-end will pick it up and generate executable code for a given platform.

With the compiler, JetBrains plans to make new versions of capabilities available while still allowing developers to use older versions for some time. New capabilities will be available in an experimental mode until stable, at which point they will become the default. 

In addition to the new compiler, Kotlin 1.4 also is set to offer the following new language features:

  • SAM (single abstract method) conversions for Kotlin classes. SAM conversion applies if a lambda is passed as an argument when an interface or a class with only one abstract method is expected as a parameter. The compiler converts the lambda to an instance of the class implementing the abstract member function.
  • Optimized delegated properties, an improvement to the way in which the lazy property and other delegated properties are compiled.
  • Trailing commas, a minor syntactic change in which an additional comma can be placed after the last parameter in a parameter list.

Copyright © 2019 IDG Communications, Inc.