Since I was intrigued by this for quite some time already, I analyzed almost 40 of Kotlin's features and language constructs (which are probably almost all there are) to see how each ends up looking when compiled to run on the JVM as the target platform (which of course is the most common target still)!
Since byte-code is pretty tedious to read, I created an example for each, compiled that into JVM byte-code and then decompiled it again into Java to have a more or less close look at what the results are. This is of course not 100% accurate but for most features the output is pretty clear.
I produced a video looking at the most interesting ones and discussing them:
default arguments have some different handling for constructors vs other function calls, and IMO it's useful to call out that many features rely on Kotlin metadata to be available to other Kotlin consumers at compile-time
s
sorianog
12/30/2021, 2:07 PM
Great work! Thanks for sharing!
j
Jakob Löhnertz
12/30/2021, 3:21 PM
@ephemient Good point! I should have mentioned that difference with the
DefaultConstructorMarker
.
I will look into producing a follow-up video regarding the metadata, I think it would be an equally interesting topic!
e
ephemient
12/30/2021, 3:26 PM
it is interesting :) the JVM ABI is relatively easy to see, but the metadata contains a lot of powerful information like package-level functions/variables, Kotlin names (which may be distinct from JVM names), which functions are operators (as opposed to simply being named the same as an operator), etc.
j
Jakob Löhnertz
12/30/2021, 11:08 PM
@ephemient Nice, sounds good! I have to first dive deeper into this myself, only got basic knowledge about the usage of the metadata annotations after researching for this video. But I'll look into it 🙌
@sorianog Thanks so much 😊
Take a look at the other videos on the channel, if you'd like. I got quite a lot of Kotlin-themed content.
👀 1
s
sorianog
12/30/2021, 11:28 PM
Your narrator voice is amazing! Definitely fitting of these types of videos! Must have been consistent practice to get to that point too! 👏
j
Jakob Löhnertz
12/31/2021, 9:18 AM
@sorianog That is so kind of you, very happy to hear!
It did take practice and I also notice myself how much worse it is on older videos. Cool that you noticed.
You made my day today already 🤗