Productive Server-Side Development With Kotlin: Stories From The Industry
Kotlin was created as an alternative to Java, meaning that its application area within the JVM ecosystem was meant to be the same as Java’s. Obviously, this includes server-side development.
We would love to hear about your experience with Kotlin for developing server-side applications and share your experience with the community!
Kotlin has experienced immense growth in the Android ecosystem in recent years. The adoption of Kotlin for server-side development is growing steadily as well. However, the question we often get from companies considering adopting Kotlin for server-side development is “Who else is using Kotlin for this?”.
Companies want to be sure that they are making the right decision when choosing technologies. They are looking for confirmation that other companies are successfully employing these technologies for the same intended purpose.
In this post, we would like to briefly highlight a few companies that have adopted Kotlin for server-side development. We hope that this will help you make the decision if you are considering adopting Kotlin for the same purposes.
The blog post is based on the presentation content from Kotlin 1.4 Online Event. You can watch the full video at our YouTube channel.
We are constantly talking to developers who use Kotlin, and we have learned about quite a few companies, big and small, that use Kotlin for server-side development. We’re always interested in finding out why companies are choosing Kotlin, and what benefits they gain from it.
There are a lot of nice features in Kotlin, but we’ll highlight those that the users we’ve spoken with liked the most:
- Concise syntax. The expressiveness of the language results in concise code. The less code there is to write, the fewer bugs sneak into the final application, and the more maintainable the final code is.
- Null-safety. This is the Kotlin feature that developers like the most. Kotlin’s type system is aimed at eliminating the risk of null references from code, also known as The Billion Dollar Mistake. This extra safety feature is built into Kotlin’s compiler, resulting in fewer issues with dereferencing null values.
- Java-interoperability. Interoperability with the host platform is a serious productivity booster! With Kotlin, you can leverage the Java ecosystem, with all its frameworks and libraries. It is also possible to introduce Kotlin gradually into an existing Java project without having to convert all the Java code to Kotlin.
- Kotlin Coroutines. These offer an easy way to master asynchronous code with an imperative programming model. Coroutines are especially useful for developing high-load server-side applications with a lot of IO operations, as they save a lot of system resources. The fact that Coroutines support was added to the Spring Framework made it even easier to take advantage of this feature for server-side developers.
Now let’s take a look at a few examples where Kotlin takes development to the next level.
JetBrains Space: extreme code reuse
You won’t be surprised to learn that we use Kotlin at JetBrains. We use it not only for tools but also for services. JetBrains Space, a team collaboration platform announced at KotlinConf 2019, is built with Kotlin and the Ktor framework. Space uses Kotlin for everything: server-side services that run on JVM, an Android application, an iOS application, the web application, and an IDE plugin.
Thanks to Kotlin Multiplatform, a large portion of the code is shared between all these different applications. In addition to sharing the data model across the UI and server-side code, Space also shares the view model, validation logic, and common libraries. The UI components are platform-specific, however, so interoperability is also important for each platform that Kotlin code targets.
The String class belongs to Kotlin’s standard library but not LocalDate. We can specify what class should be used as LocalDate for each platform that the application targets. To do this, in the common module that is shared across different platforms, we declare the LocalDate class by using the expect keyword, assuming that the different modules will provide the real implementation. The actual keyword indicates what type should be used in the platform-specific code:
The code that is not platform-specific can be written just once, in the common module of the project. The common code is then reused by the different modules that target specific platforms.
Kotlin support for multiplatform development is especially popular among mobile developers, who use it to share code between Android and iOS applications. You can learn more about this on the Kotlin Multiplatform Mobile website, and you can read about other companies’ experiences with the technology.
Jira Software: Microservices with Kotlin and Spring Boot
Another interesting example is Atlassian’s Jira. Kotlin is used at Atlassian for developing Jira Software cloud products.
Jira used to be a standalone monolithic Java application that users installed on their servers. However, with the introduction of Jira cloud, the need emerged to decompose the application into multiple services in order to scale it better.
The move to the cloud created an opportunity to update the technology stack, and this is how Kotlin came into the picture. The developers felt happy adopting the language, and with happiness comes a productivity boost! Now they use Kotlin with Spring Boot to implement microservices that power critical user experiences. Kotlin and Spring are used across the entire Jira cloud family — in Jira Software, Jira Service Desk, and Jira Core.
Adobe: going lock-free with Kotlin coroutines for high-load services
The Adobe Experience Platform team shared their thoughts on why they prefer Kotlin for server-side development.
They point out that application backends have evolved from monolithic web containers into a distributed mesh of data-driven applications. These applications have to process a lot of data, receive and send messages, and everything is latency-critical.
In their article, they list the key benefits of using Kotlin for server-side development. Support for asynchronous programming is cited as the most valuable Kotlin feature. Kotlin coroutines are described as “easy to learn”, with the resulting code being straightforward and easy to maintain.
“With Kotlin, we can write code in ‘direct style’ that reads almost like blocking, imperative code.”
The applications are quite I/O-heavy, having to rely on external services like queues, various databases, and other services. And these network calls can easily degrade application throughput. Therefore, Kotlin coroutines were immediately appealing for their use case. Going asynchronous improves overall throughput and consequently saves hardware resources.
The other benefits are the key language features in Kotlin: data classes, the sound type system, null safety, and support for functional programming. Kotlin’s flexible syntax makes it easy to create an internal DSL. This is something that appears to have been quite useful for Adobe engineers, too. They also wrote an article about their experience of building a DSL with Kotlin.
Expedia Group: building GraphQL APIs with Kotlin
Expedia adopted Kotlin because of its null-safety compiler guarantees, the conciseness of the language, and its full Java interoperability. Interoperability with Java made a gradual Kotlin integration possible without having to fully rewrite applications. Java interoperability also allowed Expedia to easily integrate Kotlin applications with Java libraries and fully utilize the existing JVM ecosystem.
Kotlin coroutines were a critical factor in the wide adoption of the language. They allow developers to write fully asynchronous code in an imperative way, which leads to more readable and maintainable code. The Spring Framework is used heavily at Expedia, and starting with version 5.2 it introduced interoperability between WebFlux and coroutines. For the engineers at Expedia, this was a game changer that made it possible to leverage the Spring and Reactive stack in a more imperative way.
Recently, Expedia decided to move toward GraphQL and build a single API gateway to power all frontend applications. To achieve this, they applied Kotlin’s powerful reflection library to generate the GraphQL schema directly from the source code. The resulting set of libraries, graphql-kotlin, turned out to be quite useful. They were open-sourced and are now hosted on GitHub.
At KotlinConf 2019, Dariusz Kuc and Guillaume Scheibel talked about how to utilize the power of Spring Boot together with graphql-kotlin. Here’s the video:
In this article we shared a few examples of Kotlin adoption for server-side development. At JetBrains, Adobe, Expedia, and Atlassian, Kotlin powers business critical applications that are highly sensitive to performance metrics. This shows that Kotlin is a mature programming language suitable for developing web applications and services.
Subscribe to Blog updates
Thanks, we've got you!
Join Us for a Live Introduction to Algorithmic Challenges in Kotlin!
Are you preparing for technical interviews, or do you simply want to master algorithms? Join us for a practical livestream where we’ll introduce the Algorithmic Challenges in Kotlin course!
Kotlin News: KotlinConf 2024 Tickets, Compose Multiplatform 1.5.0, Grants Program Winners, and More
KotlinConf 2024 Tickets, Kotlin Multiplatform Naming Update, Grants Program Winners, and other Kotlin news!
Win a Trip to KotlinConf’24 in the Kotlin Multiplatform Contest!
Are you a student or recent graduate? Create a cross-platform project in Kotlin, if your entry takes one of the top spots, you’ll win a trip to KotlinConf'24!