Paul Krill
Editor at Large

Kotlin improves compile-time constants

news
Jun 30, 20262 mins

Experimental improvements to compile-time constants in Kotlin 2.4.0 promise to make support for numeric and string types more consistent and easier to use.

shutterstock 637037008 underside of jet aircraft and jet turbines on runway
Credit: frank_peters / Shutterstock

Kotlin 2.4.0, an update to JetBrains’s statically typed language for building JVM, native, Wasm, and web applications, introduces experimental improvements to compile-time constants, making support for numeric and string types more consistent and easier to use, JetBrains said.

Kotlin 2.4.0 was released June 3. Its experimental improvements to compile-time constants include support for unsigned type operations; standard library functions for strings, such as the .lowercase(), .uppercase(), and .trim() functions, and evaluation of the .name property of enum constants and the KCallable interface. To make it clear which functions are evaluated at compile time, Kotlin 2.4.0 introduces the IntrinsicConstEvaluation annotation.

JetBrains warned that some functions are evaluated at compile time but do not have the annotation yet. Later releases will add the annotation to the remaining functions.

Also in Kotlin 2.4.0:

  • Kotlin 2.4.0 improves export to JavaScript and TypeScript, including support for exporting value classes, interfaces, and type variance, as well as ES2015 features when inlining JavaScript code.
  • The Kotlin compiler can generate classes containing Java 26 bytecode.
  • Experimental support is highlighted for the WebAssembly Component Model. The proposal defines a way to build components from Wasm modules through standardized interfaces and types. This approach helps Wasm evolve from a low-level binary instruction format into a system for composing reusable, language-agnostic components.
  • Kotlin 2.4.0 has been included in the IntelliJ IDEA and Android Studio IDEs.

An update to Kotlin 2.4.0 will arrive soon. Beta1 of Kotlin 2.4.20 was released on June 24, adding the StackTraceRecoverable interface to the standard library. This interface improves integration with the kotlinx.coroutines library because it lets users define how to create exception instances for stack trace recovery without adding a dependency onkotlinx.coroutines, according to JetBrains.

A build tools API in the Kotlin 2.4.20 beta adds support for the Kotlin/JS, Kotlin/Wasm, and Kotlin metadata targets.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author