Google releases alpha version of the Kotlin Symbol Processing

by Joseph K. Clark

Google wants to help build lightweight compiler plugins in Kotlin more accessible and address some of the challenges developers face with the programming language. For instance, developers have struggled with the language’s lack of a native annotation processing system. To address these issues, the company has announced the alpha version of Kotlin Symbol Processing (KSP). 

KSP features similar functionality to Kotlin’s KAPT compiler plugin but is up to 2x faster and offers direct access to Kotlin compiler features. According to Ting-Yuan Huang‎, a software engineer, and David Winer, a product manager at Android, it is being developed with multiplatform compatibility in mind. 

Kotlin Symbol Processing

“This is the goal of KSP: most Android app developers don’t need to worry about its internals; other than this one line change, a library that supports KSP looks just like a normal annotation processor, only it’s up to 2x faster,” the Android development team wrote in a blog post.

The KSP playground project is available on GitHub. It contains a toy test-processor library that implements the builder pattern as a KSP processor and a workload directory that shows how to use the builder processor in a real-world Kotlin project.

JetBrains released Kotlin 1.4.3 this month with a new JVM backend and new language and multiplatform features. 

According to JetBrains, the new JVM backend reached beta, and it now produces stable binaries, which means it’s safe for use.  The latest version also previews language features that are planned for release in Kotlin 1.5.0. 

Inline classes have become a specific JVM optimization for a value class with one parameter, whereas they were a particular language feature before. 

Another addition is Java records, analogous to Kotlin data classes and mainly used as simple data holders. Interfaces can also be declared and sealed as well as types. 

In the Kotlin update, the Kotlin Gradle plugin is compatible with the Gradle configuration cache, which helps speed up the build process. According to Alina Grebenkina, the marketing communications lead at JetBrains, in a blog post. 

When running a command, Gradle executes the configuration phase and calculates the task graph. However, this feature is still in alpha for multiplatform. 

The team explained that the compilation time to rebuild the KMM Networking and data storage sample framework was reduced from 9.5 seconds to 4.5. Kotlin also now offers a 64-bit watchOS simulator and Xcode 12.2 SDK support. 

When it comes to standard library changes, Kotlin 1.43.0 includes an experimental locale-agnostic API for changing the case of strings and characters. The update also separates Char conversions into two sets of clearly named functions, including functions that get the integer code of Char and construct Char and parts to convert Char to the numeric value of the digit it represents.

Related Posts

Leave a Comment