I’ve been developing in Java for over 17 years on both client and server side. I don’t get involved with the JVM-based “language wars”, quietly frankly it’s because I’m not overly passionate about programming languages. That’s not to say that I don’t have preferences or enjoy languages it’s just that I choose not to put energy into defending or justifying features/deficiencies of a language. I’m a consultant so my focus is to be aware of strengths and weaknesses of a language so I can make informed decisions on selecting or recommending the “right tool for the job”
If it wasn’t for Android application development, I probably would be focusing on other programming languages that intrigue me like Clojure, Go, Swift, etc. I’ve always believed that developer’s experience and expertise in a technology stack is driven by opportunity and not necessarily preference. You could say that I’m slightly bias because of my consulting profession however, I still believe that statement is true regardless if you work for a product company or are employed in an IT department.
I’ve been building mobile applications for about 5 years now. I found my way to Android by opportunity and my Java experience. I’ve embraced Java over the years and have focused my efforts on writing clean code and leveraging features of the language. For me, native Android development was a matter of understanding the framework and platform for building applications without needing to learn a new language. It was a natural progression for me however, I was/am still writing Java code…until now.
My first real exposure to Kotlin was at Philly ETE 2015 with a presentation by Svetlana Isakova called “Kotlin on Android“. I remember feeling good about Kotlin because JetBrains was behind it and my favorite IDE Intellij IDEA is written in Kotlin. In 2015, there were people experimenting with Scala and Clojure to build Android apps. So, my first reaction to Kotlin was it’s just another JVM-based language you could use to build an app. The fact is that without official support from Google, not many people would seriously consider anything other than Java for native app development. I knew a few developers that took a leap of faith and committed to Kotlin for Android development a few years ago. It was not until Google I/O 2017 when Kotlin officially became a supported language for Android and those who rolled the dice were suddenly ahead of everyone else.
Should I migrate Android Apps to Kotlin?
I would say yes. You might ask, why? Aside from the many benefits of Kotlin for Android development, if you are building and supporting native Android Apps then you have experienced Java developers using Android Studio. That might seem like I’m stating the obvious however, the point I’m making is that Java developers can easily understand Kotlin and Android Studio serves as an awesome learning tool that helps developers as they are migrating code to Kotlin. So, your developers are learning Kotlin under the tutelage of Android Studio. I find it quite remarkable how much I’ve learn about Kotlin using the built-in features of Android Studio, which is really Intellij IDEA. One example, Java code is automatically converted to Kotlin when copy and pasted into a file. I find it very useful to compare and contrast code snippets between Java and Kotlin within the code base for which I’m working.
Kotlin looks interesting but I’m still not sure?
This is a valid concern especially if you’re in an environment that is risk-averse and/or slow to change. A simple yet very affective approach is to convert a small existing app to Kotlin using Android Studio. If you manage a team, have someone convert an app and get their feedback. What you are looking for is feedback on the process of converting, tools and initial impression of the Kotlin language. It’s easy to get caught up in the goal of getting the app to run. That’s obviously important but the experience getting there is what is most valuable for making decisions. Don’t forget to ask yourself or others if they enjoyed working with Kotlin! 😃
Should I migrate all at once?
You don’t have to fully commit to Kotlin. Kotlin and Java are interoperable so you can decide what code to migrate. You don’t have to migrate all your source code because Java and Kotlin can co-exist, again interoperable. I suggest reading the Kotlin on Android FAQ. It’s short but very informative.
What I like about Kotlin on Android in no particular order…
- Kotlin Android Extensions – eliminates lots of boilerplate code for finding views and no need for third-party libraries like Butterknife, which is still awesome!
- Learning curve – the Kotlin converter included in the plugin for Android is invaluable. The converter coupled with Android Studio gives developers the confidence to start working with Kotlin immediately.
- Anko – Kotlin library to make code even cleaner and easier to read!
- Kotlin language
- Null Safety – we continue to suffer from Tony Hoare’s billion dollar mistake however, Kotlin’s type system is helping against null references.
- Lambda expressions
- Inline functions
- Extension functions
- Data classes
I’ll leave you with this quote from the blog post Android Announces Support for Kotlin:
“Why did the Android team decide to support Kotlin? Most importantly, it was because we think Kotlin is a great language that will make writing Android apps easier and more enjoyable.”