What led me to look at Kotlin was that LibGDX and LWJGL have been giving it some attention. One of the challenges for game development in Java is that most Java core classes produce garbage (for more safety). LibGDX and LWJGL get around this by creating non-garbage producing versions of common collections. I would love a resource telling me what does and does not produce garbage in Kotlin. Some things in Java caught me by surprise, like Enum.values() generates a new array every time.
Kotlin has a lot of nice language features that I'm not sure how they work under the hood. For example,
does
for (i in 1..100)
create a new iterator object?
does
fun outer() {
fun inner() {
}
}
create a new method closure when outer() is called?
I’m sure a lot more will become clear to me with experience, but I’d love to hear from the experts!
As you can see, it’s just two integers on the stack.
As for inner function, it’s just singleton functional object, it gets initialised only once and doesn’t produce allocations, if you don’t capture any locals:
Thanks for the quick response. Do you have any recommendations for good Java profilers? I don't really like VisualVM. If Jetbrains makes one I'll buy it :)