Does kotlin-compiler itself can be built under Kot...
# kotlin-native
c
Does kotlin-compiler itself can be built under Kotlin/Native? I’m working on https://github.com/facebookincubator/ktfmt, which currently requires Java 11. I’d like to compile to a native image so (1) it’s easier to use by organizations that haven’t moved to Java 11 and (2) an AWS Lambda that runs ktfmt has faster cold startups. Ktfmt depends on Kotlin-compiler and parts of google-Java-format. The latter should be easy to build under Native, the former I’m not so sure.
j
Neither the Kotlin compiler nor google-java-format can be built with Kotlin/Native as both rely heavily on JDK APIs. You'll have better luck with Graal nativeimage
👍 3
c
(I only need engine part of GJF, not the Java front end) For posterity, @Ty Smith attempted graalvm and documented his progress at https://github.com/facebookincubator/ktfmt/issues/44#issuecomment-656891978
👋 1
t
Unless I am missing something obvious, google-Java-format is written in Java, so you’d first have to port it to Kotlin anyway. But that would pale in comparison to the task of bootstrapping the Kotlin compiler for K/N.
n
I'm confident that the Kotlin Native compiler will eventually be written in itself (bootstrapping), which will make it easier to completely remove all reliance on the JDK. Not all platforms are supported by the JDK, and that can hinder efforts to port the Kotlin Native compiler to other platforms.
j
Maybe in 20 years. I can think of so many more high-leverage efforts than that.
😆 1
t
I assume at some point some common Java APIs could easily be shimmed (when called from multiplatform Kotlin code), especially as more established multiplatform APIs to back the shims emerge. But the Kotlin compiler relies on two decades of JVM work by Jetbrains, in particular all the stuff in the
com.intellij
namespace, a lot of which is not even written in Kotlin but in Java. There’s very little incentive to port that to multiplatform, even if it would be ported to Kotlin.
c
Thanks everyone for your replies!
s
👀 building the Kotlin compiler with Multiplatform would be a perfect way of dogfooding mpp 👀
👍 4