Better immutability in Kotlin with Valhalla
summary
Kotlin moves its immutable-data work onto Project Valhalla to get runtime-optimized, identity-less value types and multi-field scalarization instead of the current single-field inline class hacks that require mangled bytecode and fall back to boxing. The plan adds ergonomic updates via copy vars and library wither/copy-with lambdas that compile to structural wither calls for stable binary compatibility, while unresolved early initialization rules and some language integration details remain to be fixed. Performance wins come from JVM runtime optimizations rather than compiler-only inlining.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 1:07Current state of Kotlin inline classes
- 9:53Benefits of Project Valhalla
- 16:18Challenges with early initialization
- 23:31Beyond shallow immutability
- 26:16Ergonomic updates with copy vars
- 35:41Integrating copy vars and functions
- 40:39Feature interactions with lambdas
- 46:13Conclusion








