Kotlin: Java Evolved?

Kotlin has been gaining some serious ground in usage the past couple years. If you haven’t checked out JetBrains’ language for the JVM, you should!

Not only does it now have incredible support and integration with IntelliJ IDEA, but it also has its own subreddit and a growing list of books.

At first glance, Kotlin is quite similar to Scala: right down to details like being able to define functions with blocks or even with an equals sign if it is a one-liner (see figure 1).

private fun add1(addend: Int, otherAddend: Int): Int {
    return addend + otherAddend

private fun add2(addend: Int, otherAddend: Int) = addend + otherAddend

Fig. 1 – Equivalent functions

But there are also some differences from Scala, even improvements! Kotlin defaults to non-nullable variables. To make a variable nullable, you have to explicitly define it with the “?” syntax. It also has a nice data class syntax.

In short, if you haven’t checked out Kotlin lately (or at all), you should!

Leave a Reply

Your email address will not be published. Required fields are marked *