4 ms·
I have written Kotlin for an Android app now in production. Having written plenty of Java for Android, Kotlin is really good. It feels like Java in some ways, b
by staltz 11y ago
I have written Kotlin for an Android app now in production. Having written plenty of Java for Android, Kotlin is really good. It feels like Java in some ways, but helps you more than gets in your way. Nullable/non-null features crush NullPointerException, which are the most common and annoying type of run-time error, this is actually a very pragmatic feature for professional programming. Overall it's less verbose than Java. It's not hardcore on functional programming as Scala is, but adds some FP niceties with its standard library, allowing you to use map/filter/reduce/etc functions on Iterables, which matches very nicely with RxJava if your project is using that already. Also, lambdas make it easier to use RxJava. And IntelliJ IDEA's plugin for Kotlin has a button "Convert Java file to Kotlin", which does a fairly good conversion.
The problems I had with Kotlin are minimal. When converting a Java file to Kotlin, I got ClassNameException (I might not remember the name correctly), but you just need to clean and rebuild the project. Lack of support for multiple constructors of a class made me scratch my head, but they added this support in a recent version. Overall Kotlin is a better Java (in less radical ways than Scala). The reason it's feasible for Android is that its size is comparable to small libraries like Retrofit, while Scala is huge and building Android apps together with sbt has been a nightmare for many who tried.
The adoption issue is a chicken and egg problem: long-term viability depends on people adopting it, and people want to adopt tools reliable in the long-term. So just do it. Java sucks anyway, I would do anything not to write it.