One of the cool things about being a software developer is there’s always something new to learn. New programming languages, new frameworks, new development methodologies, new techniques.
New things can also be a source of frustration. The last 20 years or more have seen numerous new possibilities, each with some advantage over existing approaches.
Some of these were incremental improvements. Some were good ideas that never really caught on. Some ideas (such as the widespread adoption of the Agile development methodology) have proven to be revolutionary.
Developers can only cram so much knowledge in their heads. Many developers choose familiarity with a platform lots of people understand. Some become an “expert” on a platform no one uses.
One recent new thing that gaining significant traction is Kotlin programming language. Kotlin is a Google-backed, open-source alternative to Java that is going to make life easier for Android app development. Let’s look at Kotlin versus Java.
Kotlin: A Background
Kotlin’s origins date to 2011. It was a project of IDE-maker JetBrains. Its official release in 2016 was followed the next year with its designation by Google as the second (after Java) official Android development language.
Since then, Kotlin has seen widespread adoption in the Android development community. Many big-name companies, such as Pinterest and Airbnb, are using Kotlin for their Android mobile apps.
What accounts for Kotlin’s rapid uptake? Java is well established, with a reported 12 million developers worldwide and programs running on approximately 3 billion devices. But Java has disadvantages that can make it a pain for mobile app developers. Many observers of the Kotlin-versus-Java debate have noted differentials including:
- Better compiler – The Kotlin compiler identifies and locates code issues faster and more thoroughly than Java’s compiler. Java’s compiler can leave developers with the tedious task of manually tracking and fixing errors called out by the compiler.
- Error-reducing design – Kotlin is designed to reduce certain types of errors common with Java. For example, Java allows “raw” data types (as opposed to those defined in classes), which can cause issues the compiler may miss. This results in runtime crashes. Kotlin doesn’t allow raw types, so there are fewer chances for post-release bugs.
- Less verbose code – Java has a reputation for requiring many lines of code to implement simple tasks. More lines of code mean more chances to make mistakes. Kotlin simplifies many tasks into fewer, less-buggy lines of code.
- More active support community – Despite its smaller developer base, Kotlin has attracted an active, supportive community of developers eager to help each other.
- Technical advantages – Kotlin includes numerous goodies only a developer could love, including such esoterica as null safety, the prohibition of checked exceptions, and the availability of extension functions.
Kotlin Versus Java: Whither Java?
Despite its many advantages, Kotlin does not appear poised to supplant Java in the Android ecosystem. “Kotlin versus Java” is not an either-or proposition.
Kotlin was designed to coexist nicely with Java. Legacy Java code and new Kotlin code can live in the same app. And Kotlin is structurally similar to Java, resulting in a gentle learning curve for existing Java developers.
Look for Kotlin to continue growing in popularity within Android app development, with Java doing a slow fade…but always somewhere in the mix.