论文标题

为什么开发人员将Android应用程序从Java迁移到Kotlin?

Why did developers migrate Android applications from Java to Kotlin?

论文作者

Martinez, Matias, Mateus, Bruno Gois

论文摘要

当前,在移动设备上运行的大多数应用程序是Java开发的Android应用程序。但是,开发人员现在可以使用一种新的编程语言编写Android应用程序:Kotlin,Google在2017年将其作为开发Android应用程序的官方编程语言。从那时起,Android开发人员已经能够:a)使用Kotlin从头开始编写Android应用程序,b)通过添加Kotlin代码(两种语言之间的互操作性)来进化其现有的Android应用程序,或者通过Java编写的Android应用程序,或者通过C)将其Android Apps从Java迁移到Kotlin。本文旨在研究最后一个案例。我们进行了一项定性研究,以了解为什么Android开发人员将Java代码迁移到Kotlin,并将他们在过程中的经验汇集在一起​​,以确定他们所面临的主要困难。为了执行这项研究,我们首先确定了将Java代码迁移到Kotlin的开源Android项目的提交。然后,我们通过电子邮件发送了撰写这些迁移的开发人员。因此,我们从98位从Java迁移到Kotlin的开发人员那里获得了信息。本文介绍了研究进行迁移的主要原因。我们发现,开发人员将Java代码迁移到Kotlin,以访问编程语言功能(例如,扩展功能,Lambdas,Smart Casts),Java无法用于Android开发,并获得更安全的代码(即避免使用Null-POINTER例外)。我们还确定了研究界可以关注的研究方向,以帮助开发人员改善将其Java应用程序迁移到Kotlin的经验。

Currently, the majority of apps running on mobile devices are Android apps developed in Java. However, developers can now write Android applications using a new programming language: Kotlin, which Google adopted in 2017 as an official programming language for developing Android apps. Since then, Android developers have been able to: a) start writing Android applications from scratch using Kotlin, b) evolve their existing Android applications written in Java by adding Kotlin code (possible thanks to the interoperability between the two languages), or c) migrate their Android apps from Java to Kotlin. This paper aims to study this last case. We conducted a qualitative study to find out why Android developers have migrated Java code to Kotlin and to bring together their experiences about the process, in order to identify the main difficulties they have faced. To execute the study, we first identified commits from open-source Android projects that have migrated Java code to Kotlin. Then, we emailed the developers that wrote those migrations. We thus obtained information from 98 developers who had migrated code from Java to Kotlin. This paper presents the main reasons identified by the study for performing the migration. We found that developers migrated Java code to Kotlin in order to access programming language features (e.g., extension functions, lambdas, smart casts) that are not available with Java for Android development, and to obtain safer code (i.e., avoid null-pointer exceptions). We also identified research directions that the research community could focus on in order to help developers to improve the experience of migrating their Java applications to Kotlin.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源