Meta has been on a years-long undertaking to translate our entire Android codebase from Java to Kotlin.
To leverage the full value of Kotlin, Meta decided to take roughly ten million lines of Java code and rewrite them in Kotlin.
The benefits of translating virtually all of the code include maximizing gains in developer productivity and null safety, and minimizing the drawbacks of a mixed codebase.
At first, they clicked the IntelliJ IDE button for translation repeatedly but later, they built their own infrastructure—the Kotlinator – to automate the conversion process.
The Kotlinator is sophisticated enough to handle most compatibility changes required in external files.
To become null-safe, the code needs to be checked by a static analyzer such as Nullsafe or NullAway.
There are other ways to break your code during conversion—such as confusing initialization with getters and nullable booleans—besides regressing null safety.
At this point, more than half of Meta’s Android Java code has been translated to Kotlin, and still going.
Meta is hoping to contribute to J2K and also help other companies translating their Android codebases.
Come chat with them and others in the #j2k channel of the Kotlinlang Slack.