Translating Java to Kotlin at Scale
Article Summary
Meta is rewriting 10 million lines of perfectly good Java code into Kotlin. Why would anyone do that?
Meta's Android team has been on a multi-year mission to convert their entire codebase from Java to Kotlin since going Kotlin-first in 2020. They're now past the halfway point on one of the world's largest Android codebases, having built custom infrastructure to automate translation at scale rather than leaving existing Java untouched.
Key Takeaways
- Built 'Kotlinator' tool with 6 phases and 200+ custom conversion steps
- Automated translations run remotely in 30 minutes vs manual IDE clicks
- Collaborated with JetBrains to fix J2K issues plaguing conversions for years
- Shipped over 40,000 automated conversions with null safety validation layers
- Runtime nullability data collection plugin catches missing @Nullable annotations
Critical Insight
Meta automated the translation of millions of lines of Java to Kotlin by building sophisticated tooling around JetBrains' J2K converter, complete with preprocessing, postprocessing, and build error fixes.