Compiled | Produced by Xin Xiaoliang | CSDN (ID: CSDNnews) According to Meta's official blog, Meta is migrating the Java code of its Android application to Kotlin. Meta said that Kotlin has some key advantages over Java.

2025/07/0505:37:37 technology 1768

sorted | Xin Xiaoliang

Produced | CSDN (ID: CSDNnews)

According to Meta's official blog, Meta is migrating the Java code of its Android application to Kotlin. Meta said that Kotlin has some key advantages over Java. As of now, its Android code base has more than 10 million lines of Kotlin code.

Compiled | Produced by Xin Xiaoliang | CSDN (ID: CSDNnews) According to Meta's official blog, Meta is migrating the Java code of its Android application to Kotlin. Meta said that Kotlin has some key advantages over Java. - DayDayNewsCompiled | Produced by Xin Xiaoliang | CSDN (ID: CSDNnews) According to Meta's official blog, Meta is migrating the Java code of its Android application to Kotlin. Meta said that Kotlin has some key advantages over Java. - DayDayNews

Android development preferred language: Kotlin

In July 2011, JetBrains officially launched the Kotlin programming language, which is a static programming language for modern multi-platform applications. Kotlin can be compiled into Java bytecode or into JavaScript, which is convenient for running on devices without JVM. Compared with Java, Kotlin's syntax is more concise and also provides more feature support, such as advanced functions, string templates, etc. Kotlin has been compared with Java since its release. It was only after Google 's two actions that completely allowed Kotlin to gain a foothold. At the 2017 Google I/O conference, Google announced support for Kotlin in the Android Studio IDE, and two years later, Google officially announced that Kotlin is the preferred language for developers of Android applications. In addition to the advantages of Kotlin's basic features, Google supports Kotlin, and its Java infringement case with Oracle is also a major factor. In 2010, Oracle believed that Google used 37 Java APIs on Android for free, infringing their patents; 9 lines of code in Android plagiarized Java, infringing their copyrights. Although Oracle eventually lost the case, Google was not the winner in the eight or nine-year showdown between Google and Oracle. After 2017, Google placed its hopes on Kotlin, first integrating Kotlin into Android Studio, and then successively launched Android KTX (to help Kotlin's code be more concise) and Android Jetpack (to be fully compatible with Kotlin). Finally, in 2019, it announced that Kotlin became the preferred language for Android development and encouraged Android developers to migrate from Java to Kotlin. At the 2019 I/O Conference, Google also announced that its Android team adopted the "Kotlin-first" approach. Google has more than 70 Android apps built at least in part using Kotlin, including maps, homes, Play Stores, Drive, and more. Google says Kotlin is more efficient than Java, generates safer code and smaller code bases, and is 100% interoperable with the Java language, making it easier to convert from the Java code base by allowing them to coexist.

Compiled | Produced by Xin Xiaoliang | CSDN (ID: CSDNnews) According to Meta's official blog, Meta is migrating the Java code of its Android application to Kotlin. Meta said that Kotlin has some key advantages over Java. - DayDayNews

Meta Android code migration is in progress

Meta is also interested in Kotlin. Facebook software engineer Omer Strulovich said that they are already replacing the Java code in several of their popular Android applications with Kotlin, including Facebook, Instagram, Messenger, Portal and Quest. As of now, Facebook, Messenger and Instagram Android apps have over 1 million lines of Kotlin code. Meta's Android code base already contains over 10 million lines of Kotlin code. "Kotlin is generally considered a better language than Java, and Kotlin also has a higher praise rate than Java in the annual Stack Overflow Developer Survey report," Strulovich said, saying that Kotlin has become a popular language for Android development. "So it is reasonable for us to turn Meta's Android development to Kotlin." Although Kotlin has many benefits to promote Meta migration, Strulovich also mentioned some obvious shortcomings of Kotlin, which make migration risky, at least for large applications. First, the huge gap in popularity between Java and Kotlin has caused the latter to use fewer tools, and these tools must take into account the interoperability of Kotlin with Java, so it is very complex. Despite the 100% interoperability of the two languages, Meta found that it could not remove all Java code. “Kotlin is a popular language, but the gap in popularity is obvious compared to Java. Java is the second or third most popular language in the world (depending on how this is measured). This means there are fewer tools available in Kotlin.Worse, all Kotlin tools need to consider the interoperability of Kotlin and Java, which complicates their implementation," Strulovich noted. But Meta's biggest concern is that on the other hand, has slower build time than Java . "We knew from the beginning that Kotlin would be built longer than Java, and Java is 20 years ahead of optimizing its compiler. As we have multiple large applications, longer build times can negatively impact our developers’ experience. " Strulovich cited the compilation time comparison of the HTTP client project OkHttp after switching from Java to Kotlin in 2019. OkHttp is very small, with only 24,000 lines of Kotlin. Its compilation time in Java is 2.4 seconds, while in Kotlin is 10.2 seconds, a 5-fold gap. After weighing the pros and cons, Meta still believes that it will convert the code base of its many Android applications from Java to Kotlin and share its migration process and experience. Google's Kotlin product manager James Ward welcomed Meta's move: "For three years, Android has been Kotlin First, because it gives us the best developer experience while building on top of Java and its ecosystem,” he said. “So we are happy to see Meta migrate to Kotlin and are glad they have succeeded. Many Google teams have also gone through a similar journey from Java to Kotlin, which ended up reaching more than 11 million lines of Kotlin code as of October 2022. Other large projects have carried out similar journeys again confirming the path we chose. ” reference link: https://engineering.fb.com/2022/10/24/android/android-java-kotlin-migration

Compiled | Produced by Xin Xiaoliang | CSDN (ID: CSDNnews) According to Meta's official blog, Meta is migrating the Java code of its Android application to Kotlin. Meta said that Kotlin has some key advantages over Java. - DayDayNews

technology Category Latest News