Kotlin is renowned for being a null-safe, concise, and expressive programming language, catering to increasingly broad and cross-platform use cases. From its humble beginning to becoming one of the few Google-recommended Android programming languages, Kotlin has experienced rapid growth – and a bright outlook going forward

Overview of Kotlin

Development

JetBrains unveiled Kotlin Projects in July 2011 as a new programming language for Java Virtual Machine (JVM). In February of 2012, JetBrains officially made Kotlin open source under the Apache 2.0 license, which started Kotlin on its path to adoption. In May 2017, Google announced Kotlin as a preferred Android development language.

Modern use

Today, Kotlin is extensively used by developers around the world for Android application development, backend server creation, frontend development, and cross-platform mobile applications. In 2018, Kotlin was the fastest-growing language on GitHub, and is used by several large companies including Google, Amazon, Netflix, Uber, Pinterest, and many more

What is Kotlin?

Kotlin is a general-purpose, statically typed, and type-safe programming language with a concise and expressive syntax. Kotlin is an object-oriented language that also supports functional and asynchronous/concurrent programming.

Despite being an alternative to Java, Kotlin is interoperable with Java, Java Libraries, and JVM (Java Virtual Machine). Kotlin boasts cross-platform capabilities by supporting compilation to JavaScript or native code via its LLVM compiler – though Kotlin is most widely used to build Android applications.

Compared to Java, Kotlin offered several advantages, including more concise and expressive code that is easier to read and maintain, null safety to help avoid NullPointExceptions, support for asynchronous code using Kotlin Coroutines, and much more. Kotlin also supported functional programming, which wasn’t possible with Java.

As Kotlin is fully interoperable with Java, existing Java applications don’t need to be rewritten. New features and code can be written in Kotlin and work with Java’s extensive libraries. Developers don’t have to migrate all of their code over to Kotlin, easing much of the pain associated with adopting a new programming language.

Why Kotlin became so popular

Dmitry Jemerov of JetBrains pointed to the fact that most programming languages before Kotlin missed several important and modern features such as a clean, concise, and expressive syntax. While there were some languages such as Scala that had a concise and readable syntax, their slow compilation time was a big drawback.

 

Kotlin exploded in popularity when Google announced it as a preferred Android development language in 2017. Google needed a language that could target the JVM, access Java’s extensive libraries, had a great IDE, and leverage developers’ existing knowledge of Java, as well as being interoperable with Java.

Kotlin provided an easy-to-learn, safe, expressive, concise, and modern programming language. Existing languages like Scala and Clojure that could run on JVM were functional languages and object-oriented programming was hard or resulted in the slow compilation. Kotlin is an object-oriented language but still supports functional programming. Adopting Kotlin was time-saving and intuitive for Google, leading to Kotlin ultimately being one of the most widely used Android development languages.

Where Kotlin is commonly used

Kotlin has long been considered an Android application development language, and JetLabs (Kotlin’s creator) is pushing for the adoption of Kotlin on a general-purpose and cross-platform level. While Android development still accounts for most of Kotlin’s use cases, new use cases are becoming increasingly common.
According to JetBrains, more than half of Kotlin developers use it for mobile app development, just under half of them use Kotlin for web backend development, and only around 6% use Kotlin Native. Most Kotlin developers target either JVM or Android, with only small percentages targeting Native or Kotlin for JavaScript. Below, we look at the 3 main ways Kotlin is used in the real world.

Android development

Kotlin is primarily used to develop Android applications. According to Google, 60% of professional Android developers use Kotlin, and around 95% of the 1,000 top Android applications contain at least some Kotlin code. Google also estimates that around 70% of the apps on the Play Store are built with Kotlin. Kotlin is extensively used for Android development, and still seems to be on an upward trajectory.

Server-side for JVM applications

Kotlin is seeing increased use for server-side development and offers full compatibility with existing Java-based technology stacks and Java-based frameworks. Kotlin’s expressive and concise syntax helps to keep coding efficient and maintainable.

Kotlin is extensively supported by Java frameworks such as Spring, with Spring-specific tooling available, extensive supporting documentation, and respectable IDE support. Since Kotlin supports concurrent programming, scalability is another reason why it’s seeing increased use for server-side development. Kotlin’s Coroutines and optimized hardware usage play key roles for server-side scalability.

Kotlin-supported frameworks for server-side development include:

  • Spring

  • Http4k

  • Javalin

  • Vert.x (reactive web apps that run on the JVM)

  • Ktor (built by JetBrains for web apps with Kotlin)

  • Micronaut (modular apps and microservices, etc.)

Multi-platform mobile applications

Kotlin allows for multi-platform programming using the same codebase while leveraging some of the benefits of native code. Multi-platform programming helps to save time as less code is required and helps streamline maintenance and cross-platform implementations. Kotlin supports multi-platform programming in 3 main ways:

Multi-platform iOS and Android apps

Kotlin provides Kotlin Multi-Platform Mobile to allow developers to build iOS and Android applications that share common code such as some business logic, network requests and connectivity, and more.

Full-stack web apps

Use Kotlin Multi-Platform to build web applications that share and reuse logic on both the frontend and the server side. Create connected applications with Kotlin/JVM for the server side and Kotlin/JavaScript for the frontend web client.

Mobile and web apps with common code

Although less commonly used, Kotlin Multi-Platform allows the creation of web and mobile apps that share common code and business logic.

Kotlin’s main features

Despite being a relatively new and more modern language, Kotlin is still widely considered to be quite mature. Its features and use cases are well-established and broadly accepted – with several new branches emerging. In this section, we take a look at four of the main Kotlin features and the real-world benefits they offer developers and businesses.

Expressive and concise

Kotlin is a concise programming language thanks to modern features including type inference, infix functions, and data classes. Kotlin reduces time spent on boilerplate code as it is an object-oriented programming language that can use functional programming. This frees up the developers’ time to work more on functionality and the application’s business logic.

Kotlin is also an expressive and lightweight language, letting developers achieve the same tasks as other languages such as Java, with fewer lines of code. The drawback of Kotlin’s expressive and concise syntax is that it can be a little more complex at the beginning for developers that are used to working with Java.

Safety

Kotlin is considered a very safe programming language with features that help developers avoid and greatly reduce errors such as NullPointExceptions. In Kotlin, semicolons are optional, named parameters keep code readable (and therefore enhance maintainability), optionals (“?”) allow passing null values, and support passing code as functions and Lambda.

Achieving Kotlin’s level of safety in Java required a lot of extra code and work on the developer’s part. When Kotlin’s safety features are combined with its simple, clear, and concise syntax, maintaining complex codebases and working with Kotlin at large scales is eased.

Android Jetpack

Android Jetpack is a collection of libraries that you can import into your Kotlin application to help developers follow the best modern practices, reduce memory leaks and thus get fewer crashes, and allow backward compatibility with older versions of Android.

Jetpack helps reduce fragmentation in Kotlin applications when using complex libraries across several different Android devices and Android versions. Jetpack’s libraries also guide developers into writing good code that works across different Android devices and versions.

Using Jetpack with Kotlin (and Android KTX), the amount of time spent writing boilerplate code is reduced as there are libraries to handle operations such as lifecycle management, background processes, navigation, etc., giving developers more time to focus on the code’s functionality and business logic.

Jetpack Compose

Jetpack Compose is Android’s recommended toolkit for building native UI, making it quicker and easier to develop UIs for Android applications with less code and powerful Kotlin APIs. The main issue with Jetpack Compose is its lack of maturity, being a relatively new toolkit. Many developers prefer to use more established toolkits for building UI such as XML – though this may change as Compose reaches maturity.

Support for concurrency

Using Kotlin’s Coroutines, developers can build applications that support concurrency/asynchronous/non-blocking applications with Kotlin. For example, heavy computational work can be handled without blocking updating the UI.

Kotlin Coroutines simplify the asynchronously executed code and manages computational tasks that would typically block the main thread, thus preventing the app from becoming unresponsive.

Kotlin’s coroutines are lightweight and several coroutines can run on a single thread without blocking the thread running the coroutine as Kotlin supports suspension.

Android Jetpack supports Kotlin Coroutines, with several popular Jetpack libraries coming with extensions that provide comprehensive coroutine support – with some even supporting structured concurrency (for fewer memory leaks).

Kotlin support for Android development

Kotlin is most widely known for its usefulness in building Android applications. Kotlin and Android are deeply intertwined, with features like Android Studio and Android KTX easing the developer experience and helping them get the most from Android Jetpack.

Android Studio

Android Studio is the official IDE (Integrated Development Environment) for building Android applications. Android Studio offers an intelligent code editor with a host of autocomplete and assistive features to make coding faster, more intuitive, and better organized.

Developers can build multiple builds for various Android versions and devices from a single project through technologies such as Gradle, saving developers’ time and getting applications to production-ready more efficiently.

Android Studio also provides a suite of features and tools that make it easier to emulate various devices, fine-tune code with live feedback, and even access newer UI features such as Jetpack Compose.

Android KTX

Android KTX is a set of extensions for Kotlin that come with Android Jetpack (and some other popular Android libraries). Android KTX helps to make writing code in Kotlin more natural, idiomatic, and concise. It also includes an API layer for Kotlin to the Android framework and various supporting libraries.

Frequently
Asked Questions.

Whether you’re curious about the language’s industry footprint or its utility in various development scenarios, the following FAQs provide a comprehensive overview.

Kotlin is primarily used for Android development, with over 95% of the top 1,000 Android applications containing Kotlin code. While Kotlin is used most prominently for Android development, it’s also a good solution for backend, server-side development, and even client-side web development. Currently, Kotlin is working on adding support for different platforms such as iOS, macOS, and more.

Kotlin is used by the vast majority of the top 1,000 Android applications on the Play Store. The average Kotlin developer is becoming more experienced, with 31% of Kotlin developers stating that they have used it for between 2 to 4 years, according to JetBrains. Kotlin is still a widely used, mature, and increasingly cross-platform, general-purpose programming language. As one of the few Google-recommended programming languages, Kotlin doesn’t seem to be going away soon.

Kotlin is most commonly used for Android development, with 63% of active Kotlin developers using it for Android, according to JetBrains. Kotlin’s second most common use is for backend and server-side development, with 52% of Kotlin developers reporting to have used Kotlin on the server side. 11% of Kotlin developers used Kotlin for multiplatform mobile and desktop applications. 8% used Kotlin for native development, and 6% of Kotlin developers used it for front-end web development.

Major applications such as Pinterest and Evernote are built with Kotlin for Android, along with thousands of other Android applications including Uber, Netflix, Coursera, and Postmates. Popular applications built using Kotlin MultiPlatform include Memrise (language learning) and Cash App (fintech).

Do you have a project in mind?

Let’s discuss the future of your organization and how we can guide you on your journey to successful digital transformation.