You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/whatsnew20.md
+36-36Lines changed: 36 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,23 +28,23 @@ All you need to do is to [change the Kotlin version](configure-build-for-eap.md)
28
28
29
29
## Kotlin K2 compiler
30
30
31
-
The road to the K2 compiler has been a long one, but now the JetBrains team is ready to announce its stabilization. In
32
-
Kotlin 2.0.0, the new Kotlin K2 compiler is used by default and it is [Stable](components-stability.md) for all target
31
+
The road to the K2 compiler has been a long one, but now the JetBrains team is finally ready to announce its stabilization.
32
+
In Kotlin 2.0.0, the new Kotlin K2 compiler is used by default and it is [Stable](components-stability.md) for all target
33
33
platforms: JVM, Native, Wasm, and JS. The new compiler brings major performance improvements, speeds up new language
34
34
feature development, unifies all platforms that Kotlin supports, and provides a better architecture for multiplatform
35
35
projects.
36
36
37
37
The JetBrains team has ensured the quality of the new compiler by successfully compiling 10 million lines of code from
38
-
selected user and internal projects. 18,000 developers and 80,000 projects were involved in the stabilization
39
-
process, trying the new K2 compiler in their projects and reporting any problems they found.
38
+
selected user and internal projects. 18,000 developers were involved in the stabilization process, testing the new K2
39
+
compiler across a total of 80,000 projects and reporting any problems they found.
40
40
41
41
To help make the migration process to the new compiler as smooth as possible, we've created a [K2 compiler migration guide](k2-compiler-migration-guide.md).
42
42
This guide explains the many benefits of the compiler, highlights any changes you might encounter, and describes how to
43
43
roll back to the previous version if necessary.
44
44
45
-
We explored the performance of the K2 compiler in different projects in a [blog post](https://blog.jetbrains.com/kotlin/2024/04/k2-compiler-performance-benchmarks-and-how-to-measure-them-on-your-projects/).
46
-
Check it out if you'd like to see real data on how the K2 compiler performs and find instructions on how to collect
47
-
performance benchmarks from your own projects.
45
+
In a [blog post](https://blog.jetbrains.com/kotlin/2024/04/k2-compiler-performance-benchmarks-and-how-to-measure-them-on-your-projects/),
46
+
we explored the performance of the K2 compiler in different projects. Check it out if you'd like to see real data on how
47
+
the K2 compiler performs and find instructions on how to collect performance benchmarks from your own projects.
48
48
49
49
### Current K2 compiler limitations
50
50
@@ -630,10 +630,10 @@ Kotlin Playground supports the 2.0.0 release. [Check it out!](https://pl.kotl.in
630
630
### Support in IDEs
631
631
632
632
By default, IntelliJ IDEA and Android Studio still use the previous compiler for code analysis, code completion,
633
-
highlighting, and other IDE-related features. To get the full Kotlin 2.0 experience in your IDE, enable the K2 Kotlin mode.
633
+
highlighting, and other IDE-related features. To get the full Kotlin 2.0 experience in your IDE, enable K2 Kotlin mode.
634
634
635
635
In your IDE, go to **Settings** | **Languages & Frameworks** | **Kotlin** and select the **Enable the K2-based Kotlin
636
-
plugin** option. The IDE will analyze your code with its K2 Kotlin mode.
636
+
plugin** option. The IDE will analyze your code using its K2 Kotlin mode.
637
637
638
638
> The K2 Kotlin mode is in Alpha and is available starting from 2024.1. The performance and stability of code
639
639
> highlighting and code completion have been significantly improved, but not all IDE features are supported yet.
@@ -644,7 +644,7 @@ After enabling K2 mode, you may notice differences in IDE analysis due to change
644
644
new K2 compiler differs from the previous one in our [migration guide](k2-compiler-migration-guide.md).
645
645
646
646
* Learn more about the K2 Kotlin mode in [our blog](https://blog.jetbrains.com/idea/2024/03/k2-kotlin-mode-alpha-in-intellij-idea/).
647
-
* We are actively collecting feedback about K2 Kotlin mode. Please share your thoughts in our [public Slack channel](https://kotlinlang.slack.com/archives/C0B8H786P).
647
+
* We are actively collecting feedback about K2 Kotlin mode, so please share your thoughts in our [public Slack channel](https://kotlinlang.slack.com/archives/C0B8H786P).
648
648
649
649
### Leave your feedback on the new K2 compiler
650
650
@@ -759,7 +759,7 @@ debugging information, including all compiler arguments.
759
759
760
760
### Explicitly added standard library and platform dependencies to Kotlin/Native
761
761
762
-
The Kotlin/Native compiler used to resolve standard library and platform dependencies implicitly, which caused
762
+
Previously, the Kotlin/Native compiler resolved standard library and platform dependencies implicitly, which caused
763
763
inconsistencies in the way the Kotlin Gradle plugin worked across Kotlin targets.
764
764
765
765
Now, each Kotlin/Native Gradle compilation explicitly includes standard library and platform dependencies in its
@@ -788,14 +788,14 @@ Kotlin 2.0.0 improves performance and interoperability with JavaScript:
788
788
*[Support for unsigned primitive types in functions with `@JsExport`](#support-for-unsigned-primitive-types-in-functions-with-jsexport)
789
789
*[Generation of TypeScript declaration files in Kotlin/Wasm](#generation-of-typescript-declaration-files-in-kotlin-wasm)
790
790
*[Support for catching JavaScript exceptions](#support-for-catching-javascript-exceptions)
791
-
*[New exception handling proposal is now supported under the option](#new-exception-handling-proposal-is-now-supported-under-the-option)
792
-
*[`withWasm()` function is split into JS and WASI variants](#withwasm-function-is-split-into-js-and-wasi-variants)
791
+
*[New exception handling proposal is now supported as an option](#new-exception-handling-proposal-is-now-supported-as-an-option)
792
+
*[The `withWasm()` function is split into JS and WASI variants](#the-withwasm-function-is-split-into-js-and-wasi-variants)
793
793
794
794
### Optimized production builds by default using Binaryen
795
795
796
796
The Kotlin/Wasm toolchain now applies the [Binaryen](https://github.com/WebAssembly/binaryen) tool during production
797
797
compilation to all projects, as opposed to the previous manual setup approach. By our estimations, it should
798
-
improve runtime performance and the binaries size for your project.
798
+
improve runtime performance and reduce the binary size for your project.
799
799
800
800
> This change only affects production compilation. The development compilation process stays the same.
801
801
>
@@ -875,22 +875,22 @@ from the JavaScript side of the program.
875
875
In Kotlin 2.0.0, we have implemented support for catching JavaScript exceptions within Kotlin/Wasm. This implementation
876
876
allows you to use `try-catch` blocks, with specific types like `Throwable` or `JsException`, to handle these errors properly.
877
877
878
-
Additionally, `finally` blocks, which help execute code regardless of exceptions, also work correctly. While we are
879
-
introducing support for catching JavaScript exceptions, no additional information is provided when a JavaScript exception
880
-
occurs, like a call stack. However, [we are working on these implementations](https://youtrack.jetbrains.com/issue/KT-68185/WasmJs-Attach-js-exception-object-to-JsException).
878
+
Additionally, `finally` blocks, which help execute code regardless of exceptions, also work correctly. While we're
879
+
introducing support for catching JavaScript exceptions, no additional information is provided when a JavaScript exception,
880
+
like a call stack, occurs. However, [we are working on these implementations](https://youtrack.jetbrains.com/issue/KT-68185/WasmJs-Attach-js-exception-object-to-JsException).
881
881
882
-
### New exception handling proposal is now supported under the option
882
+
### New exception handling proposal is now supported as an option
883
883
884
884
In this release, we introduce support for the new version of WebAssembly's [exception handling proposal](https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md)
885
885
within Kotlin/Wasm.
886
886
887
887
This update ensures the new proposal aligns with Kotlin requirements, enabling the use of Kotlin/Wasm on virtual
888
888
machines that only support the latest version of the proposal.
889
889
890
-
Activate the new exception handling proposal by using the `-Xwasm-use-new-exception-proposal` compiler option. It is
890
+
Activate the new exception handling proposal by using the `-Xwasm-use-new-exception-proposal` compiler option, which is
891
891
turned off by default.
892
892
893
-
### withWasm() function is split into JS and WASI variants
893
+
### The withWasm() function is split into JS and WASI variants
894
894
895
895
The `withWasm()` function, which used to provide Wasm targets for hierarchy templates, is deprecated in favor of
896
896
specialized `withWasmJs()` and `withWasmWasi()` functions.
@@ -980,7 +980,7 @@ kotlin {
980
980
### Per-file compilation for Kotlin/JS projects
981
981
982
982
Kotlin 2.0.0 introduces a new granularity option for the Kotlin/JS project output. You can now set up a per-file
983
-
compilation that generates one JavaScript file per each Kotlin file. It helps to significantly optimize the size of the
983
+
compilation that generates one JavaScript file for each Kotlin file. It helps to significantly optimize the size of the
984
984
final bundle and improve the loading time of the program.
985
985
986
986
Previously, there were only two output options. The Kotlin/JS compiler could generate a single `.js` file for the whole
Since Kotlin 2.0.0, you can use the [`createInstance()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect.full/create-instance.html)
1057
+
Starting with Kotlin 2.0.0, you can use the [`createInstance()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect.full/create-instance.html)
1058
1058
function from the Kotlin/JS target. Previously, it was only available on the JVM.
1059
1059
1060
1060
This function from the [KClass](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-class/) interface creates
@@ -1183,16 +1183,16 @@ Previously, the `webpack` and `distributeResources` compilation tasks both targe
1183
1183
the `distribution` task declared the `dist` as its output directory as well. This resulted in overlapping outputs and
1184
1184
produced a compilation warning.
1185
1185
1186
-
So, starting with Kotlin 2.0.0, we implement the following changes:
1186
+
So, starting with Kotlin 2.0.0, we've implemented the following changes:
1187
1187
1188
1188
* The `webpack` task now targets a separate folder.
1189
-
* The `distributeResources` task is removed completely.
1189
+
* The `distributeResources` task has been completely removed.
1190
1190
* The `distribution` task now has the `Copy` type and targets the `dist` folder.
1191
1191
1192
1192
### Discontinuing legacy Kotlin/JS JAR artifacts
1193
1193
1194
1194
Starting with Kotlin 2.0.0, the Kotlin distribution no longer contains legacy Kotlin/JS artifacts with the `.jar`
1195
-
extension. Legacy artifacts were used in the unsupported old Kotlin/JS compiler and unnecessary for the IR compiler that
1195
+
extension. Legacy artifacts were used in the unsupported old Kotlin/JS compiler and unnecessary for the IR compiler, which
1196
1196
uses the `klib` format.
1197
1197
1198
1198
## Gradle improvements
@@ -1213,7 +1213,7 @@ This version brings the following changes:
1213
1213
*[Kotlin/Native compiler downloaded when needed](#kotlin-native-compiler-downloaded-when-needed)
1214
1214
*[Deprecating old ways of defining compiler options](#deprecated-old-ways-of-defining-compiler-options)
*[New Gradle property to try latest language version](#new-gradle-property-to-try-latest-language-version)
1216
+
*[New Gradle property for trying the latest language version](#new-gradle-property-for-trying-the-latest-language-version)
1217
1217
*[New JSON output format for build reports](#new-json-output-format-for-build-reports)
1218
1218
*[kapt configurations inherit annotation processors from superconfigurations](#kapt-configurations-inherit-annotation-processors-from-superconfigurations)
1219
1219
*[Kotlin Gradle plugin no longer uses deprecated Gradle conventions](#kotlin-gradle-plugin-no-longer-uses-deprecated-gradle-conventions)
@@ -1487,11 +1487,11 @@ the following Gradle property to your `gradle.properties` file:
1487
1487
kotlin.native.toolchain.enabled=false
1488
1488
```
1489
1489
1490
-
Starting with the version 1.9.20-Beta, the Kotlin/Native distribution is published to [Maven Central](https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-native-prebuilt/)
1491
-
along with CDN.
1490
+
Starting with Kotlin 1.9.20-Beta, the Kotlin/Native distribution is published to [Maven Central](https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-native-prebuilt/)
1491
+
along with the CDN.
1492
1492
1493
-
This allowed us to change how Kotlin looks for and downloads the necessary artifacts. Instead of the CDN, it now uses by
1494
-
default Maven repositories that you specified in the `repositories {}` block of your project.
1493
+
This allowed us to change how Kotlin looks for and downloads the necessary artifacts. Instead of the CDN, by default,
1494
+
it now uses the Maven repositories that you specified in the `repositories {}` block of your project.
1495
1495
1496
1496
You can temporarily switch this behavior back by setting the following Gradle property in your `gradle.properties` file:
1497
1497
@@ -1549,7 +1549,7 @@ For more information on how to specify compiler options in the Kotlin Gradle plu
1549
1549
1550
1550
Starting with Kotlin 2.0.0, the minimum supported Android Gradle plugin version is 7.1.3.
1551
1551
1552
-
### New Gradle property to try latest language version
1552
+
### New Gradle property for trying the latest language version
1553
1553
1554
1554
Prior to Kotlin 2.0.0, we had the following Gradle property to try out the new K2 compiler: `kotlin.experimental.tryK2`.
1555
1555
Now that the K2 compiler is enabled by default in Kotlin 2.0.0, we decided to evolve this property into a new form that
@@ -1656,11 +1656,11 @@ dependencies {
1656
1656
}
1657
1657
```
1658
1658
1659
-
In this example, the `commonAnnotationProcessors` Gradle configuration is your "common" configuration for annotation
1659
+
In this example, the `commonAnnotationProcessors` Gradle configuration is your common configuration for annotation
1660
1660
processing that you want to be used for all your projects. You use the [`extendsFrom()`](https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom)
1661
-
method to add "commonAnnotationProcessors" as a superconfiguration. kapt sees that the `commonAnnotationProcessors`
1662
-
Gradle configuration has a dependency on the Dagger annotation processor and successfully includes it in its
1663
-
configuration for annotation processing.
1661
+
method to add "commonAnnotationProcessors" as a superconfiguration. kapt sees that the `commonAnnotationProcessors`
1662
+
Gradle configuration has a dependency on the Dagger annotation processor. Therefore, kapt includes the Dagger annotation
1663
+
processor in its configuration for annotation processing.
1664
1664
1665
1665
Thanks to Christoph Loy for the [implementation](https://github.com/JetBrains/kotlin/pull/5198)!
1666
1666
@@ -1690,7 +1690,7 @@ and also stabilized to replace the synthetic `values()` function. For more infor
1690
1690
see [What's new in Kotlin 1.8.20](whatsnew1820.md#a-modern-and-performant-replacement-of-the-enum-class-values-function).
1691
1691
1692
1692
> The `enumValues<T>()` function is still supported, but we recommend that you use the `enumEntries<T>()` function
1693
-
> instead because it has less performance impact. Every time you call `enumValues<T>()`, a new array is created, whereas
1693
+
> instead because it has less of a performance impact. Every time you call `enumValues<T>()`, a new array is created, whereas
1694
1694
> whenever you call `enumEntries<T>()`, the same list is returned each time, which is far more efficient.
0 commit comments