Why Do Android Devs Convert To Kotlin?
Written by Mike James   
Wednesday, 01 April 2020

Not just why, but how? Moving an app from an existing language to a new one isn't something that happens every day, but since the advent of Kotlin it's more common than it was. So what is Java to Kotlin all about?

Some new research based on an interview technique and a program that analyses code repositories aims to answer the why and the how of Kotlin migration. There is a full account of the methodology in the research paper, but it is worth extracting the main findings and thinking about them a little.

The first question is: How many Android applications have been fully migrated to Kotlin? 

We know from Google that Kotlin is a growing force and it shouldn't be a surprise to learn that of 374 apps 86 (30%) have been 100% migrated to Kotlin - that's a lot of work - or is it? Of the migrated applications, 36% were completely migrated in a single commit. Others migrated slowly from one language to the other and partial migrations accounted for 63% of the 214 apps that included Kotlin code.

Of the people who didn't do a complete migration the reasons for not doing so were:

  1. only Java code that needs to be modified is migrated
  2. only new code is written in Kotlin
  3. lack of time to complete the migration.

So why migrate at all? The survey concludes that there were four reasons:

  1. to avoid limitations of Java versions
  2. to produce safer code
  3. to use a modern program language with new features
  4. to follow Google’s direction

I think a. and c. are very similar, but d.? Does anyone do what Google tells them? And did no one think that moving to Kotlin might provide some protection from fallout over the Oracle v Google lawsuit?

And what advice is there if you are thinking of migrating:

  1. Developers used the auto-converter tool for migrating code, however, the converted code often needs to be manually modified.

    No surprise there - what tool ever does a perfect conversion?

  2. Coroutines simplify the implementation of concurrency in Android.

    This one surprised me  a little as this is a different approach to concurrency than Java offers.

  3. Kotlin code is easier to read and maintain according to the majority of the interviewed developers.

    I think I would agree with this observation. I don't mind writing Java but I perfer writing Kotlin and I get so used to the Kotlin idioms that I increasingly find going back to Java unpleasant.

So should you migrate?

I would say the answer is very much yes, but I don't think you have to make a complete migration. Writing new code in Kotlin is a good start and see how it progresses. The good news is that Kotlin and Java work together.

More Information

How and Why did developers migrate Android Applications from Java to Kotlin? A study based on code analysis and interviews with developers Matias Martinez and Bruno Gois Mateus

Related Articles

Kotlin Versus Java - A Developer's Rosetta Stone

The Programmer's Guide To Kotlin

How is Java Doing?-State of Java in 2019

Developing Android Apps with Kotlin

Google Developers Codelab Refactoring to Kotlin

Udacity Kotlin BootCamp for Programmers 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


The Advent of SQL 2024 Has Commenced
11/12/2024

It's Advent - the time of year when we countdown the days to Christmas - and if your are a programmer complete daily coding challenges with the Advent of Code, the Advent of Perl, the Advent of Java,  [ ... ]



Visual Studio 17.12 Released Along With Aspire
25/11/2024

Visual Studio 2022 v17.12 is now available. The release can be used for .NET 9 projects and has a range of other improvements.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

<ASIN:1871962536>

<ASIN:1871962544>

<ASIN:1871962552>

 

 

Last Updated ( Friday, 19 August 2022 )