Five Features That Make Kotlin a Better Language Than Java [From a Java Developer]
Today, I want to talk about Kotlin, the latest challenger to Java’s crown. Specifically, I’d like to compare the two within the context of Android development.
In the years I’ve worked with Java, I’ve frequently run into issues I wish the language would handle directly so I could spend more time creating apps, and less time wrestling with workarounds. I’ve come to the conclusion that Java is a second-class citizen when compared with other languages, like C# or Scala.
That’s why I was so blown away when I first used Kotlin. It wasn’t just an iterative improvement (solving some issues and creating others) but a close to complete solution to Java’s persistent issues. It’s safe to say I’m now a paid-up member of the Kotlin hype train, jumping on board the moment Google officially supported it. Hopefully, by the time you’ve read through this article, you will be too.
Before you read on though, indulge me for one second. Stop and think about your own experiences with Java and come up with a mental list of 5 things that annoy you the most. Chances are as you read through this you’ll realize that Kotlin has addressed all of them. That’s a real achievement.
Table Of Contents
Five Java Problems that Kotlin Solves
To get you started, here is my list of things that frustrate me about Java. I’ll get into the specifics of how Kotlin elegantly addresses all 5 in the next section.
1. Data classes. As with any Android app, server communication is crucial, and creating lots of data classes with ‘getters’, ‘setters’, ‘overriding equals’ and ‘hashcode implementations’ is no fun in Java.
2. Async calls. Java has no mechanism for easy ‘async’ execution, except callbacks.