IntelliJ IDEA Kotlin News

Kotlin K2 모드가 안정화에 돌입

IntelliJ IDEA 2024.3에서는 K2 모드가 베타 버전을 벗어나 안정화되어 일반적으로 사용할 수 있게 되었습니다. K2 모드는 Kotlin 코드 분석 안정성, 메모리 소비 효율성 및 IDE의 전반적인 성능을 크게 향상하며, Kotlin 2.1 언어 기능을 지원합니다.

배경

IntelliJ IDEA의 K2 모드는 다양한 성능 및 안정성 문제를 포함하여 이전 Kotlin 플러그인 버전에 있던 제약을 해결하기 위해 설계되었습니다. K2 모드는 코드 분석 안정성과 성능을 개선하고 UI가 멈추는 문제를 줄여 IntelliJ IDEA용 Kotlin 플러그인의 효율성을 개선하는 것을 목표로 합니다. 추가적으로 K2 모드는 Kotlin 2.1 이후 버전에서 추가될 새로운 언어 기능도 지원합니다.

호환성

IntelliJ IDEA의 K2 모드는 프로젝트의 빌드 설정에 지정된 Kotlin 컴파일러 버전에 의존하지 않습니다. K2 모드는 IDE의 Kotlin 지원이 거의 새로 재작성된 것입니다. ‘K2’라는 이름도 Kotlin 플러그인이 코드 분석에 사용하는 K2 Kotlin 컴파일러의 내부 버전을 포함한다는 점을 반영합니다( K1 모드는 K1 컴파일러를 사용). IntelliJ IDEA에 번들로 포함되는 Kotlin 컴파일러의 버전은 프로젝트 빌드 파일에 지정된 버전과는 완전히 독립적입니다. 단, 프로젝트에서 지원되는 Kotlin 버전에는 영향을 줄 수 있습니다.

K2 모드 활성화 방법

K2 모드를 활성화하려면 Preferences(환경 설정)/Settings(설정) | Languages & Frameworks(언어 및 프레임워크) | Kotlin으로 이동하고 Enable K2 Mode(K2 모드 활성화) 체크박스를 선택하세요.

결과

채택률

2024.2 릴리스부터 K2 모드(베타)의 채택률은 15%를 기록했으며, 이 수치는 매주 오르는 중입니다. K2 모드는 2024.3 EAP 1부터 기본적으로 활성화되었으며, 사용해 본 개발자의 86%가 지금도 사용하고 있습니다.

성능

새로운 아키텍처 덕분에 K2 모드는 추후에도 개선할 여지가 무궁무진하며 이미 Kotlin 코드 분석, 완성, 탐색 속도가 개선되었습니다.

인기 있는 IntelliJ IDEA 기능의 성능을 측정하기 위해 사용한 벤치마크가 있습니다. 이러한 벤치마크는 오픈 소스 프로젝트나 내부 프로젝트를 포함한 실제 코드베이스에서 작동합니다. 아래는 성능을 측정한 프로젝트의 예시입니다.

아래는 결과입니다. 낮을수록 좋습니다.

지원되지 않는 기능

Kotlin 플러그인에 의존하는 일부 타사 IntelliJ IDEA 플러그인은 Kotlin 플러그인 API의 최근 변경 사항으로 인해 현재 사용이 불가능할 수 있습니다. JetBrains는 해당 플러그인이 최대한 빠르게 K2 모드를 지원할 수 있도록 적극적으로 플러그인 제작자들을 지원하고 있습니다. 자세한 정보는 상세한 마이그레이션 가이드를 참조하세요.

Kotlin 스크래치 파일 지원 같은 기능과 일부 사소한 검사, 인텐션 액션 및 빠른 수정은 아직 작업 중이며 다음 버전에서 지원될 예정입니다.

향후 계획

2025.1 버전까지 K2 모드를 기본 옵션으로 만들 계획입니다.
새로운 아키텍처를 활용하여 기존의 제약을 없애, 향후 Kotlin 플러그인의 성능을 여러 가지 새로운 방법으로 개선할 수 있게 되었습니다. 계속해서 성능과 메모리 효율성을 높이고 안정화하여 사용자의 경험을 더욱 원활하게 만들겠습니다. K2 모드가 강력한 도구이기는 해도 모든 문제를 한 번에 해결해 주지는 않지만 추후 개선을 위한 중요한 토대가 마련된 것은 확실합니다.

Kotlin의 미래를 기대하세요!

 

게시물 원문 작성자

Teodor Irkhin

Teodor Irkhin

Discover more

IntelliJ IDEA Kotlin News

Kotlin K2 模式进入稳定状态

在 IntelliJ IDEA 2024.3 中,K2 模式脱离 Beta,现已处于稳定状态并可供大范围使用。 K2 模式可以显著提高 Kotlin 代码分析的稳定性、内存消耗效率和 IDE 的整体性能,并且支持 Kotlin 2.1 语言功能。

背景

开发 IntelliJ IDEA 中的 K2 模式是为了解决上一版 Kotlin 插件的局限性,包括各种性能和稳定性问题。 目标是通过提高代码分析的稳定性和性能,同时减少 UI 冻结,来增强 IntelliJ IDEA 的 Kotlin 插件的效率。 此外,K2 模式还启用了对 Kotlin 2.1 及更高版本中引入的新语言功能的支持。

兼容性

IntelliJ IDEA 的 K2 模式不依赖于项目构建设置中指定的 Kotlin 编译器版本。 K2 模式几乎完全重写了 IDE 中对 Kotlin 的支持。 “K2”这个名称表示 Kotlin 插件包含内部版本的 K2 Kotlin 编译器,用于代码分析,K1 模式则使用 K1 编译器。 IntelliJ IDEA 中捆绑的 Kotlin 编译器的版本完全独立于项目构建文件中指定的版本,但可能会影响项目中支持的 Kotlin 版本的范围。

如何启用 K2 模式

要启用 K2 模式,请转到 Preferences/Settings | Languages & Frameworks | Kotlin(偏好设置/设置 | 语言和框架 | Kotlin)并选择 Enable K2 mode(启用 K2 模式)复选框。

结果

采用率

自 2024.2 版本以来,K2 模式 (Beta) 的采用率已达到 15%,而且这一数字每周都在增长。 K2 模式从 2024.3 EAP 1 开始默认启用,86% 试用过的开发者仍在使用。

性能

借助新架构,K2 模式的未来增强潜力巨大,我们已经在 Kotlin 代码分析、补全和导航速度方面取得进步。 

我们使用一些基准来衡量 IntelliJ IDEA 最常用功能的性能。 这些基准适用于真实代码库,包括开源和内部项目。 以下是我们衡量性能时使用的一些项目:

以下是结果。结果越低越好。

不支持的功能 

由于 Kotlin 插件 API 的最新更改,某些依赖于 Kotlin 插件的第三方 IntelliJ IDEA 插件目前可能不可用。 我们正在积极为插件作者提供支持,使他们的插件尽快兼容 K2 模式。 有关详情,请参阅我们详细的迁移指南

一些功能,例如 Kotlin 临时文件支持,以及一些小检查、意图操作和快速修复仍未完成,将在下一版本中得到支持。

未来计划

到 2025.1 版本,我们计划将 K2 模式设为默认选项。
借助新架构,我们打破了以前的限制,现在我们可以通过许多新方式提高 Kotlin 插件未来的性能。 我们将继续提高其性能、内存效率和稳定性,让您的体验更加流畅。 虽然 K2 模式是一个强大的工具,但它不会立即解决所有挑战。不过,它确实为我们的后续改进奠定了坚实基础! 

敬请期待 Kotlin 的未来!

本博文英文原作者:

Teodor Irkhin

Teodor Irkhin

Discover more

IntelliJ IDEA Kotlin News

Kotlin K2 Mode Becomes Stable

In IntelliJ IDEA 2024.3, K2 mode is out of Beta and is now Stable and ready for general use. K2 mode significantly improves Kotlin code analysis stability, memory consumption efficiency, and the IDE’s overall performance, and it supports Kotlin 2.1 language features.

Background

K2 mode in IntelliJ IDEA was developed to address limitations in the previous version of the Kotlin plugin, including various performance and stability issues. It aims to enhance the efficiency of the Kotlin plugin for IntelliJ IDEA by improving code analysis stability and performance while reducing UI freezes. Additionally, K2 mode enables support for new language features that will be introduced in Kotlin 2.1 and later versions.

Compatibility

IntelliJ IDEA’s K2 mode doesn’t depend on the Kotlin compiler version specified in the project’s build settings. K2 mode represents an almost complete rewrite of Kotlin support within the IDE. The name “K2” reflects that the Kotlin plugin includes an internal version of the K2 Kotlin compiler, which it uses for code analysis, while K1 mode uses the K1 compiler. The version of the Kotlin compiler bundled in IntelliJ IDEA is entirely independent of the version specified in the project’s build file, though it may affect the range of supported Kotlin versions in projects.

How to enable K2 mode

To enable K2 mode, go to Preferences/Settings | Languages & Frameworks | Kotlin and select the Enable K2 mode checkbox.

Results

Adoption

Since the 2024.2 release, K2 mode (Beta) has shown adoption rates of 15% – and this number is growing weekly. K2 mode was enabled by default starting with 2024.3 EAP 1, and 86% of developers who tried it are still using it.

Performance

With the new architecture, K2 mode has vast potential for future enhancements, and we already have improvements in Kotlin code analysis, completion, and navigation speed. 

There are benchmarks that we use to measure the performance of the most popular IntelliJ IDEA features. These benchmarks work on real codebases, including open-source and internal projects. Here are some of the projects we measured the performance on:

Below are the results. Lower is better.

Unsupported functionality 

Some third-party IntelliJ IDEA plugins that depend on the Kotlin plugin may be currently unavailable because of recent changes to the Kotlin plugin API. We’re actively working on supporting plugin authors to make their plugins compatible with K2 mode as quickly as possible. For more information, please refer to our detailed migration guide.

Some functionality like Kotlin scratch file support, as well as some minor inspections, intention actions, and quick-fixes are still in progress and will be supported in the next version.

Plans for the future

By the 2025.1 version, we plan to make K2 mode the default option.
With the new architecture, we’ve broken the ceiling of previous limitations, and we now have many new ways to improve the future performance of the Kotlin plugin. We’ll continue to make it more performant, memory-efficient, and stable to make your experience smoother. While K2 mode is a powerful tool, it’s important to note that it won’t address all challenges immediately, but it does provide a great foundation from which we can make further improvements! 

The future of Kotlin awaits!

Discover more