by pron · 11y ago · 0 comments
> Lambdas can be inlined!
Kotlin's inline functions are meant to serve as a poor man's macro system (to implement simple control structures) and/or for argument type specialization -- not to save the "inner class overhead" because, guess what? There isn't one! While HotSpot's JIT will certainly not inline lambdas in every circumstance (though it's getting better), it will inline them in all cases where Kotlin's inline functions can be used (and many others where they can't). It is possible, however, that inner classes do have some overhead on Android.
> Reified generics!
Kotlin does not reify generics, and like in Java, that's a good thing! Java's erased generics are precisely what makes polyglot interop easy.
Again I wasn't being very clear, sorry about that: Kotlin doesn't always reify generics, but it can for functions you mark as inline if you want (it's useful!). Check out the inline function docs!
Also, there are few compilers anywhere with optimizations as powerful as HotSpot :) And HotSpot compilation is only getting better and better. Java 9 will even let us use Graal as the optimizing compiler (i.e. instead of C2), which can do this: https://twitter.com/ChrisGSeaton/status/619885182104043520