Is Kotlin a new Java for Android?

When creating native apps for Android, you will normally use the Java programming language for your logic. The same way as Objective C for iOS, Java was written long before mobile development took place. Both languages are powerful, fully-functional and effective. But the fact is that they were not optimized for mobile. Why not to design something better?

With that purpose an open source programming language for the JVM and Android – Kotlin v1.0 – was released.

It is thought to be industrial-strength object-oriented, and in general a “better language” than Java. Still it is fully interoperable with Java code, which allows companies make a gradual migration from Java to Kotlin.

Is it all? Definitely not. Let’s look more closely at Kotlin.

Java can’t be characterized by being the most laconic language while Kotlin is very concise. One might argue that this isn’t a con in and of itself. Sure, but when you’re programming for Android and using dozens of common idioms, “wordy” code will likely result in additional bugs. Besides, writing innumerous lines of code can be really tedious. When you’re able to write less code with a language that’s more succinct, the chance for additional errors decrease. “Consise” also means you’ll need less code to achieve more things.

Kotlin is extensible too. This helps to build really clean APIs and solve a bunch of other problems. No more need for Helper or Util classes.
No more null pointer exceptions too (a cry from the heart of most Java developers)! Nullability problems are common in Java, and Android uses null quite a bit to represent the absence of a value. Basically, having a null point exception can kill an app. Kotlin solves this by having null right in its type system, not forcing developers to use different bypasses.

Kotlin is characterized by absolutely easy learning curve. It aims to be an enhancement to Java, not a complete rewrite. This means that many of the skills a Java developer acquired and cultivated throughout their career should still be applicable to your Kotlin projects. Besides most of the Kotlin syntax feels familiar and the language itself is intuitive and easy to read. It won’t be difficult to get the gist of what code is doing.

So, the switch from Java is not an issue. You can reuse any Java class ever written, all Java code can work with Kotlin and vice versa. In IntelliJ or Android Studio, converting Java files to Kotlin just requires installing the Kotlin plugin, adding it to the Gradle build files, and clicking convert. You can even have Java and Kotlin code existing side by side in the same project, and everything will still compile perfectly.

In other words Kotlin is offering Android developers a more concise, readable language that let them be more productive and write better mobile apps. No wonder it is becoming more and more popular with Android developers.

But can it create a real challenge for Java? What do you think?

%d bloggers like this: