Kotlin logo

Kotlin

A concise multiplatform language developed by JetBrains

News

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 algorithmStable in 1.4.0
New JVM IR backendStable in 1.5.0
New JS IR backendStable in 1.6.*
New frontendIn 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:

Discover more

News

K2 编译器之路

我们在新 K2 Kotlin 编译器上的工作已经持续了很长一段时间。 新编译器旨在加快新语言功能的开发、统一 Kotlin 支持的所有平台、提升性能,并为编译器扩展提供 API。

Kotlin 编译器的开发工作开始于多年前,自那时以来,许多事情都发生了变化。 例如,在 Kotlin 1.0 中,没有 Kotlin/Native 后端,也没有协同程序,所以 Kotlin 编译器代码根本无法使用它们。

我们正在逐步引入新组件,使其能够尽快到达您的手中。 许多部分已经用于最新的 Kotlin 版本,还有一些即将推出:

新类型推理算法在 1.4.0 中达到稳定版
新 JVM IR 后端在 1.5.0 中达到稳定版
新 JS IR 后端在 1.6 中达到稳定版*
新前端积极开发中
在 1.6.20 或 1.7 中推出预览

在以下有关重写 Kotlin 编译器的视频中,我们将:

  • 提供关于编译器不同部分的更多详细信息,包括编译器理论的基础。
  • 解释编译器前端与后端之间的区别。
  • 解释旧后端与 IR 后端之间的区别。
  • 重点介绍新前端的变化。
  • 解释我们为什么选择将新编译器命名为 K2。

如果您想了解新前端的更多技术细节,请收看新前端的开发负责人 Simon Ogorodnik 和 Mikhail Glukhikh 在 Kotlin 2021 Premier 在线活动的现场演讲“K2 编译器:整体介绍”。 两位主讲重点介绍了使用 FIR(前端中间表示)重写 Kotlin 编译器的过程,并回答大家的问题。

相关链接:

英文博文原作者:

Discover more