KotlinConf’23 — Meta-programming with KSP and Kotlin compiler plugins by Tadeas Kriz

Matthew Dolan
2 min readApr 15, 2023

I really enjoyed watching the talk on meta-programming by Tadeáš Kříž at KotlinConf’23 where he provided an excellent overview of the two main options for generating and/or altering code during compilation. It was great to see the pros and cons of each option even compared to Java’s annotation processing which more developers are familiar with.

“there are the things that break your heart 💔”

The lack of documentation around writing a Kotlin Compiler Plugin makes getting started hard work. Fortunately the speaker provides plenty of links to resources you can use to help you on your way — I wish I’d seen this talk before writing my own compiler plugin last week!

Perhaps you were aware of the move to JVM IR; for most Kotlin developers the compiler implementation doesn’t really matter unless, of course, you are writing a compiler plugin. As such it was interesting to have an overview of both SyntheticResolveExtension and IrGenerationExtension.

How do you decide what to use for meta-programming? Prefer KSP where possible.

The talk mentions plenty of examples of KSP and Kotlin Compiler Plugins you can check out to help you write your own plugin.

Additionally, during the conference I had the opportunity to talk with Tadeas about a Kotlin Compiler Plugin he’s been writing, Skie (pronounced sky) which, by the way, looks awesome. We both have our fingers crossed that it can become open source so the Kotlin community has another good example of how to write a compiler plugin.

“What do you do next. Hopefully profit.”

You can find my thoughts on more KotlinConf’23 talks at KotlinConf’23. Please let me know your thoughts.

Join medium to read all of my articles or subscribe for e-mail updates.

--

--

Matthew Dolan

Matt Dolan has been eating doughnuts and developing with Android since the dark days of v1.6.