What is the meta-programming story for KMP? Is it ...
# multiplatform
d
What is the meta-programming story for KMP? Is it planned, is there an issue on bugtracker I can vote on? JVM has (imperfect)
kapt
, but I'd really like to be able to also generate common code. I know about kotlin compiler plugins, but this seems like an overkill.
s
Compiler Plugins are the intended multiplatform meta-programming strategy as far as I know. It’s worth noting that there are different levels of compiler plugins. Compiler plugins at there simplest are generating new sources (similar to annotation processors), and from what I understand, don’t require an IDE plugin in order to see the generated code. This of course isn’t true if your are modifying an existing class / file. I don’t know much about what I’m talking about here though. I’m sure other people can explain better. We still don’t have a stable compiler plugin api.
d
I see, thanks! I didn't know that sources generated by compiler plugins can be seen in IDE. This would be nice indeed. Otherwise it feels like black magic which I don't like for a common use case...
I would appreciate an official statement/roadmap too
s
I think they’ve been pretty clear on this in their roadmap. in the 2011 Kotlin Conf keynote I think this was discussed
this was taken from a talk from Andrey Breslev
I’m also not sure that compiler plugins are more black-magic than annotation processors. Compiler plugins have access to add to and edit the existing AST, while annotation processors could only add to it.
d
The editiing of AST is what I consider a black magic. I mean this is the tool which is awesome in the right hands, but given the opportunity one can come up with a lot of bad things 🙂