Posted on Leave a comment

Kotlin Symbol Processing API

[https://github.com/android/kotlin/tree/ksp/libraries/tools/kotlin-symbol-processing-api]

Compiler plugins are powerful metaprogramming tools that can greatly enhance how you write code. Compiler plugins call compilers directly as libraries to analyze and edit input programs. These plugins can also generate output for various uses. For example, they can generate boilerplate code, and they can even generate full implementations for specially-marked program elements, such as Parcelable. Plugins have a variety of other uses and can even be used to implement and fine-tune features that are not provided directly in a language.

While compiler plugins are powerful, this power comes at a price. To write even the simplest plugin, you need to have some compiler background knowledge, as well as a certain level of familiarity with the implementation details of your specific compiler. Another practical issue is that plugins are often closely tied to specific compiler versions, meaning you might need to update your plugin each time you want to support a newer version of the compiler.

Posted on Leave a comment

First Look at Kotlin 1.4-M2: Standard Library Improvements

[https://blog.jetbrains.com/kotlin/2020/05/1-4-m2-standard-library/]

We keep working on Kotlin 1.4 and the next preview 1.4-M2 is just around the corner. Right now we’re ready to unveil some improvements from this preview; in this post, we’ll get you acquainted with the standard library changes.

Here are some key improvements in the standard library in 1.4-M2:

Changes to the existing API like updating signatures and introducing new constants
More functions in the common library
New functions for Arrays and Collections
Property delegation improvements
Even though Kotlin 1.4-M2 hasn’t been released yet, we’ve deployed its early version to the Kotlin playground so that you can try everything you find in this post. The code samples in this post run on the new version as well.

If you can’t wait to try the new version, subscribe to the Kotlin blog newsletter and you won’t miss the release day.