Kotlin adoption on the Android open source community

Víctor Albertos
5 min readJan 23, 2019

--

Thanks @pabloppp for his amazing casual style

It’s well known how much Android developers claim to love Kotlin. But as love is not satisfied with words, -and because I had to write a post for a data scientist course (you’re welcome Udacity), I thought to gather some evidence to verify that claim.

How? By evaluating the adoption of Kotlin on the Android open source community (I mean Github). To do so, we’ll address several points relying on descriptive analyses to put the matter in perspective. The raw data to build the datasets has been gathered from GitHub GraphQL API v4. As you may expect, expect all kind of bugs and inaccurate interpretations. But this is a happy place, for data disclaimers and other sad considerations refer to the backing Github repository.

Kotlin vs Java Android repositories created on Github

Let’s first take a look at the number of Android repositories whose main language is Kotlin that have been created since Kotlin 1.0 (the first officially stable release) was publised at 2016–02–15.

Monthly Android Kotlin repositories created from 2016–02–15 to 2019–01–15

Every dot in the plot shows the number of Android Kotlin repositories created during a month. In the last month, about 1,900 Kotlin repositories were created. Are these numbers high? I couldn’t tell, what I can tell is that there is a steady increasing trend.

To know if these numbers represent a significant part of the Android open source community we have to compare them. By making them relative to some terms, we get a sense of their impact in the scope represented by those terms. The scope is formed by two terms: 1) Kotlin vs Java within the Android community to know in what degree Kotlin has been adopted by the Android community and 2) Kotlin vs Java outside the Android community to know if the ratio of adoption within the Android community is relevant.

Monthly ratio of repositories created from 2016–02–15 to 2019–01–15

The green line represents the ratio between the Kotlin vs Java repositories created in a monthly bases within the Android community. The blue one represents the same relationship but outside the Android ecosystem -meaning all those Kotlin and Java repositories not related with Android. We observe in both cases a steady increasing trend, but in the case of Android repositories is 3 times bigger. Namely, the last month shows a 16% of Android Kotlin repositories compared with the 4.3% of Kotlin not Android repositories.

It seems that there is a big difference. But does this difference mean that Android developers love Kotlin more than common Java ones? I don’t think so. I think that common Java developers hate less Java because they are not stuck with the same language version that they used to create their scholar projects in Netbeans.

Also because of the following fact.

Google made Kotlin an official programming language for Android development

You may have noticed that on May 17, 2017, there was a huge pike on the percentage of Kotlin repositories. Let’s highlight that date:

During an unbearable time, Android developers had to keep their love in secret. But it was during the Google I/O 2017 that an announcement made from Google changed the whole vaudeville picture: a parent’s blessing in marriage, by which Android developers were now allowed to fulfill their true love for Kotlin.

And they did it. The month in which the statement was made the percentage of repositories created with Kotlin increased to 6.3%. Having the previous month a percentage of 2.4%, we can infer the huge impact that that blessing had. And the effect was not limited to that specific month, but rather it kept affecting subsequent months until the present day.

What motivations are behind Google’s decision is something beyond my resources and interest. One thing is clear though: this parent allows polygamy because Java has not been (yet) expelled from the marriage.

Kotlin Android repositories migrated from Java on Github

To almost complete this incomplete analysis, I think it would be worth knowing how many active repositories have migrated from Java since Kotlin was release.

As it has been said before, you can refer to the backing Github repository for implementation details about the dataset creation. That being said, a repository is considered to be migrated if it was created before the first stable Kotlin 1.0 release date and its main language nowadays is Kotlin.

Data shows that 8.6% of the repositories were migrated to Kotlin. Comparing this ratio with the percentage of Kotlin repositories created during the whole historical, 6.9%, we can observe that both ratios show a similar pace. It seems that Android developers are not only willing to use Kotlin for brand new projects, but also for those which are already a valuable contribution to the community.

Another interesting (?) question is if the migrated repositories share some common features. Let’s draw a table showing the mean for several attributes:

Attribute averages grouping by Kotlin migrated and Java repositories

Having in mind that the dataset distribution for migrated vs not migrated repositories is not symmetric (kotlin: 78 vs java: 833), we can try to formulate some thoughts about their compositions.

Kotlin migrated repositories seems to be slightly more popular, showing higher mean for the number of forks (kotlin: 324 vs. java: 256), watchers (kotlin: 72 vs. java: 67) and starts (kotlin: 1192 vs. java: 943). It goes along with the previous trends where we saw how the percentage of repositories created with Kotlin was increasing almost constantly in a monthly bases.

On the other hand, Java not migrated repositories tends to be “bigger”, having a greater size on disk (kotlin: 26MB vs. java: 78MB) as such as a more number of pull requests (kotlin: 96 vs. java: 117). This makes sense because of the amount of time invested is higher to migrate bigger projects (probably meaning larger code bases).

As a last step, let’s just draw a correlation heatmap to see if there are relationships with the target feature “migrated”.

The correlation heatmap shows very low coefficients but the direction of their relationships points out to the same conclusion drawn when inspecting the means: the projects migrated to Kotlin are more popular and less big than those which did not migrate.

Should I move to Kotlin?

We’re already doing it.

--

--