Kotlin industry adoption


#1

Hello

Our team is trying to convince other team to use kotlin and compatibility with Java + async IO are very solid arguments. However people are hesitant to switch to Kotlin because of “industry adoption” - they are afraid that language would die at some point (e.g. as dart). Google with android is good example of Kotlin adoption, but maybe someone could help with examples of teams/companies that are using Kotlin for backend services?

Thanks.


#2

I personally don’t know any. There is a short section in the faq however: https://kotlinlang.org/docs/reference/faq.html#what-companies-are-using-kotlin
listing Square, Pinterest and Basecamp.


#3

Thanks. Interestingly all 3 companies (square, pinterest, and basecamp) are using Kotlin for android apps, not for server side (at least their announcement was about that)…


#4

Well one obvious company, which is using kotlin for backend as well is JetBrains, other than that, no idea.


#5

We are using Kotlin as our main language in the backend of a large German website that has more than 10 million visits and about 100 million page impressions per month. In the backend, Kotlin makes no problems whatsoever.

In the frontend, we are currently in the process of replacing our view templates with kotlinx-html. It works very well so far. Also, we have plans to replace our JavaScript in the Browser with Kotlin in the very near future.

We have an experimental framework for sharing the same kotlin code in our backend (server) as well as in the frontend (browser). Initial demos show that this works well, but the tooling support lacks behind, especially IntelliJ.

Ironically, we don’t have yet a production release of our Android app that has Kotlin code. This is planned for the next major version of the app.


#6

A good indicator is that more and more modules of the Spring framework are coming with Kotlin APIs by default. The new Gradle DSL is written in Kotlin, too.

Here are some more companies known to use Kotlin. You can find some more on StackShare.


#7

That is super helpful. Didn’t know about spring supporting Kotlin. Thanks!


#8

Wow, that’s a big bet on Kotlin. Thanks for sharing.


#9

I work at a small (<10 devs) non-startup company. We recently built a small Spring Boot 2.0 webservice with Kotlin, and it has been a pleasure. Using IDEA, adoption pains were … non-existent?


#10

I went to a Kotlin meetup yesterday where Oleksii Fedorov of https://iwillteachyoukotlin.com/ was presenting on this the related topic of how to convince your manager to switch to Kotlin. Lots of good discussion there. I’d argue that leading by example is the best way to do this. Do a spike to enable Kotlin in your project and convert a single class or test. This is extremely easy for most projects. This proves: 1) it works 2) it’s easy, as advertised 3) it can be done gradually (kotlin-java interop is seamless) 4) if you do it right, you can demonstrate the advantages by pointing out how much better the Kotlin class is than whatever replaced it. It also cuts short a lot of debate over complexity, feasibility, etc. I’ve heard of people just doing stuff like this under the radar.

First, Kotlin is relatively new but has been out of beta for a few years nevertheless. It has been adopted by Google as the preferred language for Android. So, most new Android projects are done in Kotlin; it’s a first class citizen in Android Studio. It’s not an optional skill to have for Android developers. It’s been one of the fastest growing languages in the JVM world and people are jumping ship from other JVM languages like e.g. Scala.

Kotlin on the backend has always been possible but got a lot more mainstream with the release of Spring 5.x late last year and Spring Boot 2.x beginning of this year. Both include Kotlin specific features such as extension functions, several spring plugins for gradle and maven to make the compiler do the right thing with opening Kotlin classes and adding default constructors that Spring needs. I’ve switched one project completely and am in the process of switching another project. This is by far the easiest transition of one language to another that I’ve experienced. You’re not switching build tools, libraries, dependencies, etc. Everything stays the same (initially) except you are now writing Kotlin instead of Java. Intellij converts your Java code for you and you can get it working with very little effort (it tends to get some stuff wrong). It’s a great way to learn Kotlin too.

There are many advantages to using Kotlin with Spring Boot but my favorite one is being able to use immutable data classes for Entities, DTOs, etc. and the related feature of having very elegant ways of working with properties (e.g. delegated properties, primary constructors with default values for properties, etc.). If you are doing any kind of Spring code that involves model classes, this clears up a lot of very ugly code. Spring and Hibernate were always a bit broken by design because you had to have setters/getters, default constructors, non final classes, etc. for the reflection based magic that Spring and Hibernate use to work.

The same is true in Kotlin except there you can use compiler plugins to open up spring annotated classes. So you can have a nice closed, immutable data class for your entities and your IDE will never know otherwise. But at compile time, it’s opened up so that Spring can work with it. You get safety and full compatibility with Spring. That’s awesome. Most of my model classes become a one liner: data class Foo(val field: String, val anotherField: String="defaultValue".

Null safety is another good argument. If you operate servers that run JVMs, just look at all the incidents involving NullPointerExceptions and then ask your self if you’d like to live in a world where none of those incidents would have happened. Kotlin is null safe by default; NPEs are not a thing with Kotlin unless you choose to opt out of the null safety by using !! or by depending on legacy java code that isn’t null safe. That alone is a great argument to make the switch.

In terms of industry adoption, I’d argue that Kotlin is definitely growing very rapidly already and in particular people from languages like Groovy and Scala are jumping ship. To the extent that people in the Scala community are getting worried about this. Kotlin borrows a lot from both languages and you can think of it as a safer Groovy (statically compiled) and a simpler Scala that has most of its popular features and lacks most of the ugly-ness, failed type system experiments and abandon-ware in the standard library, and complexity that the Scala community has been struggling with.

That is in addition to all the Android developers that have switched. Things are about to get even more interesting as Android/Kotlin is acting like a gateway drug for Javascript people as well. I know a few Javascript full stack developers that first got exposed to Kotlin on Android and are now adopting it in the backend where stuff like node.js would have been their preferred choice in the past. They are liking it much to their own surprise. Add Kotlin Native to the mix and you have a perfect recipe for Kotlin to become a dominant language for full stack development. With Kotlin Native you will be able to target browsers through WASM, IOS & Android native, servers, desktops, embedded, server less, etc. Kotlin adoption is great now but we’ve seen nothing yet.

That will cause two things to happen 1) there will be lots more people with Kotlin skills 2) there will be lots of people wanting to get some Kotlin skills. Both are great when you are hiring for a Kotlin project.


#11

OTTO NOW, a German E-Commerce company renting electronics and other stuff to consumers has written their backend system and all the business processes in Kotlin.