Kotlin 1.9 Adds K2 Compiler
Written by Mike James   
Tuesday, 11 July 2023

The Kotlin team at JetBrains has announced a new version of Kotlin that includes a beta of the new Kotlin K2 compiler for JVM. Kotlin 1.9 also includes new language features as well as improvements for Kotlin Multiplatform and Kotlin/Native.

Kotlin is the open source language originated by JetBrains and promoted by Google as a first class language for Android to replace or supplement Java. It makes Android programming easier by reducing the need for long chunks of boilerplate code that the average programmer just doesn't understand, or perhaps more accurately doesn't bother understanding at a deep level.

kotlinlogo

JetBrains says that the compiler has been thoroughly tested by successfully compiling an extensive range of projects that the Kotlin Team uses for quality assurance.

The Kotlin team says that the K2 compiler will bring major performance improvements, speed up new language feature development, unify all platforms that Kotlin supports, and provide a better architecture for multiplatform projects.

Away from the K2 compiler, Kotlin 1.9 has a stable replacement of the enum class values function. The entries property for enum classes was introduced as an experimental feature in Kotlin 1.8, and is now stable. The team says that the values() function is still supported, but they recommend that you use the entries property instead.

Data object declarations that were introduced in Kotlin 1.8.20 are also now stable. This includes the functions added for symmetry with data classes: toString(), equals(), and hashCode().

Support has been added for secondary constructors with bodies in inline value classes. Previous releases of Kotlin allowed using only public primary constructors in inline classes, but this made it impossible to encapsulate underlying values or create an inline class that would represent some constrained values.

This release also adds the ability to generate classes with a bytecode version corresponding to JVM 20.

Kotlin/Native improvements include more work on the Kotlin/Native memory manager that the team says should enhance its robustness and performance. These improvements start with a preview of a custom memory allocator that improves the runtime performance of the Kotlin/Native memory manager.

There's also a change to the way the Objective-C or Swift object deallocation hook is called. This is now called on the main thread if the object is passed to Kotlin on the main thread. The intention is that this should avoid memory leaks.

This release also now treats linkage issues in Kotlin libraries the same way as Kotlin/JVM. The developers say you might face such issues if the author of one third-party Kotlin library makes an incompatible change in experimental APIs that another third-party Kotlin library consumes. From now on, builds won't fail during compilation in case of linkage issues between third-party Kotlin libraries. Instead, you'll only encounter these errors during run time, exactly as on the JVM.

Kotlin 1.9 is available now.

kotlinlogo

More Information

Kotlin Home Page

What's New In Kotlin 1.9

Related Articles

Kotlin 1.8 Beta Adds New JVM Functions

Kotlin 1.7 Unveils New Compiler

Kotlin 1.5 - Mature But Still Growing

Why Do Android Devs Convert To Kotlin?

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Hour Of Code 2024 Is About To Kick Off
04/12/2024

This year the event that aims to provide a coding experience for all school students and anyone else who wants to join in runs between December 9th and 15th and includes new activities. Let's find out [ ... ]



.NET Community Toolkit Adds Partial Properties Support For MVVM
19/12/2024

Microsoft has announced version 8.4 of the .NET Community Toolkit, a collection of helpers and APIs that work for all .NET developers. The new version adds support for partial properties for the MVVM  [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

<ASIN:1871962706>

<ASIN:1871962544>

Last Updated ( Tuesday, 11 July 2023 )