This question already has an answer here:
I'm new to Kotlin, and AFAICT its syntax only supports the object versions of Int, Float etc without the corresponding int and float primitives of Java. But does the compiler or JVM optimise to use the primitive types if possible? I'm concerned that if I use local variables in a function called from a game main loop it might cause GC stutter if the JVM has to create an object each time instead of using a primitive type.
Quoting the docs:
So yes, the compiler does optimise in a way that the JVM primitive types are used at runtime. There are certain exceptions of course:
There's also a hint in the source documentation, e.g.
Int
: