Kotlin will displace Java in the Android ecosystem.

Kotlin will displace Java in the Android ecosystem.

Survey report on the adoption of Kotlin for Android.

Zainab Bawa

Zainab Bawa

@zainabbawa

Madhusudhan Sambojhu

@madz314

Anand Venkatanarayanan

Anand Venkatanarayanan

@anandvenkatanarayanan

Bhavani Seetharaman

Bhavani Seetharaman

@Bhavani-21

Anish TP

Anish TP

@anishtp

Key findings of the survey

Submitted Sep 9, 2021

Based on the historical context of Kotlin’s growth in the Android ecosystem, the survey’s findings reinforce that many users of Kotlin also have a Java background.

Experience levels and comfort working with Kotlin

Despite being a much younger language, Kotlin is the second most popular language that developers are comfortable working with. The survey results also show that most developers have only recently begun working with Kotlin, with a majority of the respondents stating that they have been working with Kotlin for 1-3 years.

{
  "title": {
    "text": ["Since how long have you been", "working with Kotlin?"],
    "orient": "bottom",
    "dy": 20,
    "fontSize": 16
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": "container",
  "data": {
    "values": [
    {"category": "> 3 years", "value": 12.3, "label": "12.3 %"},
    {"category": "< 1 year", "value": 30.8,"label": "30.8 %"},
    {"category": "NA", "value": 1.5, "label": "1.5 %"},
    {"category": "1-3 years", "value": 55.4, "label": "55.4 %"}
    ]
  },
  "encoding": {
    "theta": {"field": "value", "type": "quantitative", "stack": true},
    "color": {"field": "category", "type": "nominal", "legend": null}
  },
  "layer": [
    {"mark": {"type": "arc", "outerRadius": 120}},
    {
    "mark": {"type": "text", "radius": 150},
    "encoding": {
        "text": {"field": "label", "type": "nominal"},
        "size": {"value": 18}
        }
    },
    {
    "mark": {"type": "text", "radius": 85},
    "encoding": {
        "text": {"field": "category", "type": "nominal"},
        "fill": {"value": "#fff"},
        "size": {"value": 14}
        }
    }
  ]
}

Style of writing Kotlin code

The data also shows that almost 68 percent of respondents write Kotlin using idiomatic Kotlin code, while 32 percent of the respondents still continue to use Java style of writing code.

{
    "title":{
    "text": "How do you write code in Kotlin?",
    "orient": "bottom",
    "dy": 20,
    "fontSize": 16
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": "container",
  "data": {
    "values": [
    {"category": "Idiomatic Kotlin code", "value": 64.6, "label": "64.6 %"},
    {"category": "Java style of code", "value": 30.8, "label": "30.8 %"},
    {"category": "NA", "value": 4.6, "label": "4.6 %"}
    ]
  },
  "encoding": {
    "theta": {"field": "value", "type": "quantitative", "stack": true},
    "color": {"field": "category", "type": "nominal", "legend": null}
  },
  "layer": [
    {"mark": {"type": "arc", "outerRadius": 120}},
    {
    "mark": {"type": "text", "radius": 150},
    "encoding": {
        "text": {"field": "label", "type": "nominal"},
        "size": {"value": 18}
        }
    },
    {
    "mark": {"type": "text", "radius": 55},
    "encoding": {
        "text": {"field": "category", "type": "nominal"},
        "fill": {"value": "#fff"},
        "size": {"value": 14}
        }
    }
  ]
}

Bangalore-based design firm, Obvious Ventures Private Limited, identified this gap in Kotlin adoption i.e., that individuals use Java style of writing code despite moving to Kotlin. This slows down the transition that teams can make to Kotlin. Between February and March 2021, Obvious conducted workshops for mid-career Android programmers and teams on how to write code in Kotlin efficiently.

Ease of working with Kotlin

When asked why their organizations chose Kotlin as a choice of language for building apps, participants indicated faster compile times and less verbosity of code as the key advantages of Kotlin. One of the survey respondents said:

“Kotlin is chosen as the framework for Android app development in my organization mainly due to ease of coding, elimination of null references, and excellent interoperability with Java.”

Yet another respondent highlighted the sentiment that developers use Kotlin because of the features it has to offer.

“Kotlin is much more succinct and fun to use compared to Java. We can achieve more with less boilerplate. It has so many cool features, like nullability checks, stateflows and coroutines without which it wouldn’t be as easy to develop.”

Related to the above, the survey shows that 34 percent of respondents’ organizations have 80-100 percent of their codebase in Kotlin, while 33 percent of the respondents’ organizations have between 0-20 percent of their codebase in Kotlin.

The response below summarizes why developers prefer Kotlin over Java:

“Reduced boilerplate code, improved app stability, better tooling support, better null safety. Overall, increased developer happiness.”

Percentage of codebase migrated to Kotlin in organizations

We also see that approximately 32 percent of respondents had only 0-20 percent of their codebase in Kotlin, indicating that a significant proportion of the industry has still not adopted the language. When probed further, respondents indicated that their organizations were resisting the move towards Kotlin. This was the case for 22 percent of the respondents.

{
   "title": {
    "text": ["What percentage of your", "codebase is in Kotlin?"],
    "orient": "bottom",
    "dy": 20,
    "fontSize": 16
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": "container",
  "data": {
    "values": [
    {"category": "0-20 %", "value": 32.3, "label": "32.3 %"},
    {"category": "21-40 %", "value": 9.2, "label": "9.2 %"},
    {"category": "41-60 %", "value": 12.4, "label": "12.4 %"},
    {"category": "61-80 %", "value": 10.8, "label": "10.8 %"},
    {"category": "81-100 %", "value": 33.8, "label": "33.8 %"},
    {"category": "NA", "value": 1.5, "label": "1.5 %"}
    ]
  },
  "encoding": {
    "theta": {"field": "value", "type": "quantitative", "stack": true},
    "color": {"field": "category", "type": "nominal", "legend": null}
  },
  "layer": [
    {"mark": {"type": "arc", "outerRadius": 130}},
    {
    "mark": {"type": "text", "radius": 160},
    "encoding": {
        "text": {"field": "label", "type": "nominal"},
        "size": {"value": 18}
        }
    },
    {
    "mark": {"type": "text", "radius": 90},
    "encoding": {
        "text": {"field": "category", "type": "nominal"},
        "fill": {"value": "#fff"},
        "size": {"value": 14}
        }
    }
  ]
}

Key challenges in working with Kotlin

When asked to describe the major challenges that teams/organizations face in migrating their codebase to Kotlin, the following were identified as key issues:

  1. Null safety and handling nullable objects.
  2. Not enough documentation is available; lack of library support.
  3. Novelty of functional programming for teams that aren’t used to writing code in this paradigm.
  4. Hiring and onboarding developers to ramp up to Kotlin; apprehension among managers whether they’d be able to hire Kotlin programmers.
  5. Syntax confusion for Java developers who now have to work with Kotlin.
  6. Large codebase, and lack of bandwidth to migrate. One respondent specifically pointed out:

“We’re a B2B company. We cannot introduce Kotlin in our SDKs as they will require shipping the Kotlin standard library dependency with the SDK. This can be problematic for apps still using Java as it will increase the SDK size at compile time.”

{
     "title": {
    "text": "Challenges to Incorporate Kotlin",
    "orient": "bottom",
    "dy": 20,
    "fontSize": 16
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": "container",
  "data": {
    "values": [
    {"category": "Other", "value": 6.3, "label": "6.3 %"},
    {"category": "Null checks", "value": 9.5, "label": "9.5 %"},
    {"category": "No challenges", "value": 7.9, "label": "7.9 %"},
    {"category": "Coding structure", "value": 19, "label": "19 %"},
    {"category": "Team", "value": 6.3, "label": "6.3 %"},
    {"category": "NA", "value": 28.6, "label": "28.6 %"},
    {"category": "Not migrated", "value": 22.2, "label": "22.2 %"}
    ]
  },
  "encoding": {
    "theta": {"field": "value", "type": "quantitative", "stack": true},
    "color": {"field": "category", "type": "nominal", "legend": null}
  },
  "layer": [
    {"mark": {"type": "arc", "outerRadius": 130}},
    {
    "mark": {"type": "text", "radius": 160},
    "encoding": {
        "text": {"field": "label", "type": "nominal"},
        "size": {"value": 18}
        }
    },
    {
    "mark": {"type": "text", "radius": 90},
    "encoding": {
        "text": {"field": "category", "type": "nominal"},
        "fill": {"value": "#fff"},
        "size": {"value": 12}
        }
    }
  ]
}

Leveraging Kotlin beyond UI development

This survey results show three key findings in this regard:

  1. Developers rarely utilize new tooling in Kotlin such as Jetpack Compose.
  2. The primary comfort of developers is to use Kotlin for UI development. We read this as a bias among the survey respondents who may primarily be UI developers, and who therefore don’t use Kotlin for backend development purposes.
  3. Only 33 percent of the respondents use Kotlin for building data pipelines, again indicating lack of diversity in the roles of survey respondents i.e., the survey has most responses from UI developers rather than from backend developers working with Kotlin.

Comments

{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}