《多鄰國 (Duolingo)》完成遷移至 Kotlin 的程序,行數平均減少 30%
透過集合功能整理內容
你可以依據偏好儲存及分類內容。

Duolingo 是全球最受歡迎的語言學習平台之一,也是 Google Play 上最多人下載的免費教育應用程式之一,下載次數超過 2 億次。
大多數人會學習新語言,藉此獲得更多機會,而多鄰國 (Duolingo) 的使命是為超過 3 億名學生提供免費且無障礙的語言教育。
具體措施

在發現程式碼集的行數每年增加 46% 後,多鄰國的 Android 開發人員決定從 Java 遷移至 Kotlin。
以真正的多鄰國風格 (Duolingo) 為例,該團隊利用每日排行榜進行比賽,鼓勵學習,以遊戲化的方式進行遷移。本團隊經驗豐富的 Kotlin 開發人員會成為「Kotlin 檢查工具」,並在程式碼審查中分享最佳做法,直到所有 Android 開發人員都成為 Kotlin 專家為止。
兩年後,大幅改善程式碼可維護性。他們發現將 Java 檔案轉換為 Kotlin 後,行數平均減少了 30%,在特定情況下最多可達 90%。
「整體來說,在遷移至 Kotlin 後,我們感到很滿意,也很高興看到 Kotlin 在公司內部和整個軟體產業的使用率持續提高!」- 資深軟體工程師 Art Chaidarun
成果
儘管有新的產品功能、活躍貢獻者人數超過一倍,其程式碼集大小仍和兩年前遷移前幾乎相同,證明這個決定是良好的投資。更重要的是,內部問卷調查顯示,開發人員的滿意度下降了 129 個 NPS 分數,而 Kotlin 是回應中引用的一大因素。
《多鄰國 (Duolingo)》也是不斷擴充和發展階段,就像使用語言一樣。進行嚴謹的 A/B 測試以及應用程式內意見回饋,確保團隊持續修正方法,為全世界提供最優質的語言教育。現在 Android 應用程式擁有 100% 的 Kotlin 程式碼集,因此能更安心、更有效率地完成這項工作。
開始使用
進一步瞭解如何使用 Kotlin 開發 Android 應用程式。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2020-05-15 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2020-05-15 (世界標準時間)。"],[],[],null,["# Duolingo completes migration to Kotlin and reduces its line count by an average of 30%\n\n[Duolingo](https://play.google.com/store/apps/details?id=com.duolingo&hl=en_US)\nis one of the most popular language learning platforms in the world, and one of\nthe most-downloaded free education apps on Google Play, with more than 200\nmillion downloads.\n\nThe majority of people learn a new language to gain access to better\nopportunities, and it's Duolingo's mission to provide free and accessible\nlanguage education to its 300+ million learners.\n\nWhat they did\n-------------\n\nAfter seeing that their codebase's line count was growing 46% every year, a\nunanimous decision was made by Duolingo's Android developers to migrate from\nJava to Kotlin.\n\nIn true Duolingo style, the team gamified the migration process by running a\ncontest with a daily leaderboard and encouraging learning. The team's\nexperienced Kotlin developers became \"Kotlin checkers\" and shared best practices\nin code reviews, until all the Android developers became Kotlin experts\nthemselves.\n\nAfter two years the migration was complete, [dramatically improving code\nmaintainability](https://blog.duolingo.com/migrating-duolingos-android-app-to-100-kotlin/).\nThey found that **converting a Java file to Kotlin reduced its line count by an\naverage of 30%, and in certain cases by as much as 90%**.\n\n\"Overall we're very happy that we migrated to Kotlin when we did, and we're\nexcited to see its usage continue to grow both within our company and throughout\nthe software industry!\" - Art Chaidarun, Sr. Staff Software Engineer\n\nResults\n-------\n\nDespite having new product features and more than double the number of active\ncontributors, their codebase is nearly the same size as it was before the\nmigration two years ago, proving that the decision was a good investment. What's\nmore, internal surveys show their **developer satisfaction has skyrocketed by\n129 NPS points**, and Kotlin is a major factor cited in responses.\n\nDuolingo is always expanding and evolving, just like languages. [Rigorous A/B\ntesting](https://www.youtube.com/watch?v=xAx0ccvKw-M) and in-app feedback ensure\nthe team will continue to refine methodology and offer the best language\neducation in the world. Now with their Android app having a 100% Kotlin\ncodebase, they can do so with even more confidence and efficacy.\n\nGet started\n-----------\n\nLearn more about [developing an Android app with Kotlin](/kotlin)."]]