Whether you’re a new software developer or you’re a veteran looking to expand your skill set, it’s always a good idea to research programming languages. While there are plenty of languages available, the most common Android language is Java. However, Kotlin is starting to catch up, and many developers are taking notice. So, which language should you stick with: Java or Kotlin?
First, Kotlin is completely interoperable with Java. Since Google announced Kotlin as an official language for Android development, the open source, statically typed language has gained momentum. It runs on the JVM and you can easily start using Kotlin on an existing Java project. Many convoluted tasks in Java become simplified and shortened in Kotlin. In many instances Kotlin allows you to add just one word or phrase that replaces at least twenty lines of Java code. The Kotlin website does a great job of outlining key differences between the two languages. As a preview:
- Null references are backed into its type system (no more NPE!)
- Kotlin arrays are invariant
- Kotlin has proper function types, compared to Java’s SAM-conversions.
Second, Java is more traditional. As this article from TechBeacon points out, Java doesn’t have support for method references, streams, or lambdas. It’s also less concise, meaning it takes longer to write and more time to read, which in turn makes it more error prone.
For total beginners…
If you’re completely new to programming, it’s a good idea to start with Java. Most Android code is still written in Java and more learning resources exist. However, once you have a basic understanding of Java, start to integrate Kotlin, and other languages, in your practices as well.