Session

Dissecting the inline keyword in Kotlin

A deep-dive into the internal workings of the inline keyword in Kotlin

While being mostly under-recognized, this little optimization forms the backbone for a lot of features and APIs in Kotlin, features which are directly dependent on the lambda infrastructure.

And it doesn't stop there, the inline keyword opens up the ecosystem to have capabilities for type reification, which still isn't possible when writing Java.

Java 8 introduced the concept of lambdas, while this was done at the language level, using bytecode instructions introduced in Java 7, Kotlin, tries to make this lambda functionality available for applications targeting Java 6. Kotlin does this by creating Classes of functions are lambdas. This can lead to performance problems as a good number of instances for the classes might get created.

This talk dives into:

* How does Kotlin achieve it? What changes does it do to make this compatibility happen?
* How does inlining optimize a lambda?
* How this little optimization makes it possible to have type reification?
* How it doesn't stop there and introduces the concept of Inline classes, which enable Kotlin to have unsigned integers.
* How all of this is done, by just adding one keyword support in Kotlin.

Also presented at:
* FOSDEM20, Brussels: https://fosdem.org/2020/schedule/event/kotlin_dissecting_the_inline_keyword/
Video link: https://video.fosdem.org/2020/UA2.118/kotlin_dissecting_the_inline_keyword.mp4

Link to medium article submitted on proandroiddev:
https://proandroiddev.com/dissecting-the-inline-keyword-in-kotlin-chapter-1-51735600d7

Suraj Shah

Technical Lead, SuperShare

Bengaluru, India

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top