Optimizing Scala bytecode for fun and profit
summary
Scala compiler adds a bytecode optimizer that turns high-level code into the same low-level bytecode you’d hand-write (benchmarks show array.map -> while loop equivalence) and yields small wins like ~2–3% faster compilation. It runs a sequence of passes (nullability, unreachable code, inlining) and exposes flags -opt (local optimizations) and -opt-inline (cross-method inlining). Limitations: no incremental compilation, worse debugging, inlining can stale third-party fixes, and JVM safety rules block constructor/ private-field elision (Scala.js can do more).
AI-written summary · about
