Kotlin
A concise multiplatform language developed by JetBrains
The Road to the K2 Compiler
We’ve been working on a new K2 Kotlin compiler for quite some time. The new compiler aims to speed up the development of new language features, unify all the platforms Kotlin supports, bring performance improvements, and provide an API for compiler extensions.
The development of the Kotlin compiler started many years ago, and many things have changed since that time. For example, in Kotlin 1.0, there was no Kotlin/Native backend and no coroutines, so Kotlin compiler code simply couldn’t use them.
We’re introducing new components step-by-step so that they reach you as soon as possible. Many parts are already used in the latest Kotlin versions, and others are on their way:
New Type Inference algorithm | Stable in 1.4.0 |
New JVM IR backend | Stable in 1.5.0 |
New JS IR backend | Stable in 1.6.* |
New frontend | In active development Preview in 1.6.20 or 1.7 |
In the following video about our adventure of rewriting the Kotlin compiler, we will:
- Provide more details about different parts of the compiler, including the basics of the compiler theory.
- Explain the differences between the compiler frontend and backend.
- Explain the differences between the old backends and the IR backends.
- Highlight what is changing in the new frontend.
- Explain why we’ve chosen to name the new compiler K2.
If you want to learn more technical details about the new frontend, please join the live talk “K2 Compiler: a top-down view” at the Kotlin 2021 Premier Online Event by the lead developers of the new frontend, Simon Ogorodnik, and Mikhail Glukhikh. They are going to highlight the process of rewriting the Kotlin compiler using FIR (frontend intermediate representation) and will answer your questions.
Register for the K2 Compiler live talk
Related links:
- New more powerful type inference algorithm in Kotlin 1.4.0
- Stable JVM IR backend in Kotlin 1.5.0
- Kotlin/JS IR compiler