https://kotlinlang.org logo
#compiler
Title
# compiler
a

Alexander Maryanovsky

08/04/2022, 3:40 PM
Today (well, yesterday actually) I realized that every lambda and function reference is compiled (for the JVM) into a separate class, and this slows down app startup.
h

hfhbd

08/04/2022, 3:46 PM
a

Alexander Maryanovsky

08/04/2022, 4:04 PM
I’ll give it a try, but it sounds like it will be even slower at runtime, just with a smaller jar size.
z

Zac Sweers

08/04/2022, 4:49 PM
it sounds like it will be even slower at runtime
citation needed?
a

Alexander Maryanovsky

08/04/2022, 4:50 PM
Just a hunch. Hope it's wrong.
Ok, so the number of classes did go down significantly from ~1250 to ~750. Interestingly, this eliminates lambda classes, but method references are still compiled to a class. No noticeable change in startup performance, though.
a

Alexander Maryanovsky

08/04/2022, 7:39 PM
Yes, sad that they decided to go with option C. I think once this is enabled by default (and non-experimental), there will be much more pressure to apply it to function references too.
4 Views