Scala ❤️ Kotlin

2 min read Original article ↗

Hielke de Vries

Scala engineers are a different breed than Java engineers. They pride themselves in having learned a difficult but also powerful language. Scala is very powerful and much more versatile than Java. If you build more complex systems than just another REST API, then you greatly benefit from the power that Scala provides you. Java is just too limited, has some bad design choices and provides less tools for building robust, high-load scalable systems. Java has improved a lot over the years, but some things you cannot change about a language. Immutability, nullability and functional programming is something that Java will never be very good at.

Scala is small language with support coming largely from hobbyists and some small companies. Companies see that Scala can help them solve problems, but also gives them a lot of problems. The pool of Scala engineers is small, the compensation of Scala engineers is high. Only so few engineers dedicate the enormous amount of time and energy to really understand Scala. Many know how to write hello world in Scala, a few understand how to write a pure-functional, highly-scalable system in ZIO, Cats or Akka.

And thus companies are trying to get rid of Scala. But they need an alternative. You can write complex systems in Java, but it’s not as good as in a language such as Scala.

Then came along Kotlin. Kotlin is heavily inspired by Scala and the creators of Kotlin are big fans of Scala¹. But they also saw Scala’s flaws, it’s complexity and difficulty. Kotlin is not as difficult as Scala, but has almost the same power. It has default immutability, nullability and good functional programming support. It has simple pattern matching, good streams support and a built-in Option monad² and IO monad³ (kind of). The killer feature of Kotlin is that it seamlessly integrates with Java. Whereas Java is not a good replacement for Scala, Kotlin is.

[1] https://en.wikipedia.org/wiki/Kotlin_(programming_language)

[2] https://kotlinlang.org/docs/null-safety.html

[3] https://kotlinlang.org/docs/composing-suspending-functions.html