THE MIGRATION LINE
INCIDENT // DUOLINGO-2020SHIPPED

Duolingo's Android app spent its first five years as a Java codebase, then fully converted to Kotlin over two years — cutting converted files' line counts by around 30% on average and flattening a previously 46% year-over-year codebase growth rate.

DUOLINGO·2020·LANGUAGE / MOBILE / ANDROID / KOTLIN·✓ Sourced — blog.duolingo.com
System stress over timeNominal
2 yearsMigration span
~30%Avg LOC reduction
46%/yrCodebase growth (before)
+129 ptsDeveloper NPS
BASELINE

Five years of Java, and a codebase growing 46% a year

REQUIREMENTS

Productivity, stability, and a language developers actually wanted to write

When Duolingo first considered Kotlin in early 2018, Android support for it was less than a year old, and it wasn’t yet clear it would ever unseat Java as Google’s preferred Android language. The team weighed three anticipated benefits — reduced verbosity for faster writing and maintenance, null-safety features to prevent the NullPointerException class of bugs, and developer happiness, informed by positive reactions to earlier language upgrades on Duolingo’s other platforms (Swift on iOS, a full TypeScript rewrite of duolingo.com) — against the real risk that a Kotlin migration might not be worth its opportunity cost in developer time.

THE CALL

All new code in Kotlin first, full migration decided unanimously afterward

Android developers unanimously decided the benefits justified writing all new Android code in Kotlin, though the team wasn’t yet committed to migrating all existing Java code. Getting developers up to speed relied on biweekly assemblies with introductory Kotlin presentations, a rotating “Kotlin checker” reviewer role that eventually included every Android developer, and a required three-commit pattern per file conversion: run the IDE’s autoconverter, fix compilation errors, then refactor to idiomatic Kotlin.

CONSEQUENCES

A codebase that stopped growing, and a 129-point jump in developer NPS

Converting a Java file to Kotlin reduced its line count by around 30% on average, and by as much as 90% in some cases. Two years after introducing Kotlin, with more than twice the number of active contributors and many new product features shipped, the Android codebase was almost exactly the same size as it had been at the start — a direct reversal of the prior 46% annual growth rate. Developer happiness, measured by NPS, increased by 129 points for Android over the same period, with most developers citing Kotlin and its surrounding tooling as a major factor. Kotlin’s smaller tooling ecosystem compared to Java’s was manageable, though the team still occasionally hit NullPointerExceptions and IllegalArgumentExceptions from third-party Java dependencies that didn’t use nullability annotations.

A language migration doesn’t just change syntax — reducing verbosity and eliminating a whole bug class can flatten a codebase’s growth curve even as the product keeps shipping more.

Source — read the original

A plain-language, AI-drafted and human-edited retelling of the article published on blog.duolingo.com, reorganized and explained in our own structure and words, with original analysis in the editor's note above. The facts, numbers, and decisions belong to the original author and are not altered. For the full depth, read the source.

← All systems