Effective Kotlin: Item 6 — Avoid creating unnecessary objects

Android’s performance tips briefly mention Avoid Creating Unnecessary Objects. However, item 6 of Joshua Bloch’s recently updated book, Effective Java, has far more practical examples I recommend you check out. The hardest to spot of these being autoboxing. How does it apply to Kotlin where the compiler decides for you whether, for example, an Int turns into a primitive type, int, or a reference type, Integer.

Typically the compiler sticks to the advice of Effective Java preferring primitives to reference types. Lukas Lechner…