Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 13 min read Case study mediumAdept

From zero to 10 million lines of Kotlin

Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator. The pipeline preprocesses Java packages, runs J2K headlessly through Android Studio, then applies automated refactors and linters built on the Kotlin compiler's PSI AST. Those refactors fix issues such as JUnit @Rule annotations needing @JvmField or @get:Rule, and replace TextUtils.isEmpty with isNullOrEmpty. Meta chose a full conversion over Kotlin-for-new-code-only to avoid platform-type null risks from Java interop. Results: about 11% fewer lines, no runtime performance regression in A/B tests, negligible APK size impact after Proguard/Redex, and longer build times as the main cost.

Related posts

  • Translating Java to Kotlin at Scale

    Meta Engineering mediumAdept

    Meta is translating roughly ten million lines of Android Java to Kotlin using the Kotlinator, an automated pipeline built around a headless version of JetBrains' J2K. It runs six phases: a deep build, about 50 preprocessing steps, headless J2K, about 150 postprocessing steps, linters with autofixes, and fixes driven by compiler errors. A daily cron system produces the conversion diffs for human review. Null safety comes first, because Kotlin inserts runtime null checks at the Java interop boundary, so the Kotlinator errs toward nullable types to avoid introducing new NPEs. Meta is also working with JetBrains to add extension hooks to J2K for better symbol resolution and to open-source some of its steps.

  • Kotlin Multiplatform in Production: Two Real-World Use Cases from Booking.com

    Booking.com Engineering mediumAdept

    Booking.com applied Kotlin Multiplatform in two production cases: a shared experimentation library replacing drifting Java/Kotlin and Objective-C implementations, and a Compose Multiplatform (Kotlin/JS) web playground that renders the real Android BUI design-system components in a browser. The experimentation library ships as a Gradle dependency on Android and an XCFramework via CocoaPods on iOS, and was validated by running old and new implementations side by side behind experiment flags. During that parallel phase iOS saw roughly +140 ms p90 startup and +2.5 MB download size, but startup improved once the legacy code was removed, which shows migration-time performance data can mislead. iOS engineers were brought on board through an evaluation framework with an explicit exit ramp, and some later became contributors, though Xcode's lack of Kotlin support remains a tooling gap.

  • How we use Kotlin for backend services at Zalando

    Zalando Engineering easyNovice

    Zalando moved Kotlin from TRIAL to ADOPT on its Tech Radar, making it the third supported JVM language alongside Java and Scala after 100+ new Kotlin applications were written in a year. A Kotlin Guild with 250+ members produced guidelines, templates and default tooling recommendations for backend services. These defaults include Spring Boot (with Ktor as a rising option), Gradle with Kotlin build scripts, ktlint, kotlin-logging, Lettuce for Redis, JPA or jOOQ for relational databases, and opentracing-toolbox. APIs are defined in OpenAPI and linted with Zally, and auth is handled at the Skipper ingress rather than with Spring Security.

  • It’s a non-transitive R class world

    Slack Engineering mediumAdept

    Slack migrated its 400+ module Android codebase to non-transitive R classes, where each module's R class contains only its own resources, yielding ~14% faster incremental builds after resource or layout changes and an ~8.5% (about 5.5MB) APK/DEX size reduction. Because Android Studio's built-in migration refactor stalled at this scale, the team used regex find-and-replace on the two modules holding most resources, a script to add Kotlin import aliases (e.g. L10nR, SlackKitR), and then enabled android.nonTransitiveRClass and android.enableAppCompileTimeRClass. Shared live templates and three auto-fixing lint checks enforce consistent alias conventions, and the migration also exposed misplaced resources and made resource origins easier to trace.

  • Enabling Kotlin incremental compilation on Buck2

    Meta Engineering mediumAdept

    Meta integrated the Kotlin incremental compiler into Buck2 via Kotlin's experimental Build Tools API, making some large Android modules build up to 3x faster and improving incremental build times about 30% for the average developer. The work involved migrating the toolchain to the shaded kotlin-compiler-embeddable, using Buck2 incremental actions to keep prior outputs and compute changed-file lists from input hashes, making the cache relocatable for remote execution, and generating classpath snapshots as a separate cacheable action. Custom compiler plugins had to be made incremental and accumulate results across multiple compilation rounds. jvm-abi-gen still lacks incremental support, so a stopgap merges the new ABI with the previous output.

The quest for software engineering knowledge.

Look:
Layout: