DEV Community

Mahesh K
Mahesh K

Posted on


Kotlin - Is it time to switch from Java?

Kotlin is now official part of the Android development. But I am trying to find out if existing Android app should move to kotlin now.

I am skeptical about kotlin because community tutorials and articles or even youtube videos are limited in numbers when it comes to Kotlin and Android.

What are some of the features and performance benefits you get from switching to kotlin code?

Oldest comments (8)

quii profile image
Chris James

It's unlikely you'll get much performance benefit but you'll probably be more productive as it's a lot more expressive than Java.

bgadrian profile image
Adrian B.G.

Flutter, flutter, flutter

Oh sorry, don't mind me, web dev passing trough

As a general note, very few scenarios exists when you changing the programming language/technologies worth the trouble (from a business perspective). Maybe try it with the next new project?

lalunamel profile image
Cody Sehl

I've been using Kotlin in Android development since before it was officially supported and I've loved it.

If you and your team are willing to take the time to learn a new language, then I'd say why not?

The features of Kotlin that I enjoy:

  • A Strong Type System
  • Null Safety
  • Functional Constructs

Those features come together to produce a language that moves a majority of errors from runtime to compiletime (functional constructs don't do that, but I do enjoy using them nonetheless). That, in my book, is why Kotlin is better than Java.

It's fully supported by Android Studio. I've never had any major issues using it. It does get updated quite frequently, though, and that upgrade process can get a bit tricky. Just make sure you commit first, do the upgrade, then commit after.

The Android APIs haven't caught up to Kotlin and I don't expect them to any time soon, if ever. Most Android APIs rely on returning null (tends to be a bad practice in Kotlin) and none use functional programming concepts. That's okay though - the interop is very easy. Using Kotlin on a Java project requires no extra work - just start making classes in Kotlin instead of Java. It's very simple!

It also has great documentation!
I didn't learn Kotlin through tutorials or videos - I just learned by writing a few simple programs and looking up information when I got stuck. If you'd like to learn about Kotlin's functional programming constructs, take a look at the Kotlin Koans

Best of luck!

eljayadobe profile image

Java (1996) alternative languages for the JVM platform:

  • Scala (2001) • OO with FP
  • Groovy (2003) • Java without all the ceremonial cruft
  • Fantom (2005) • platform agnostic general purpose language (can target JVM or CLR)
  • Clojure (2007) • Lisp with FP
  • Ceylon (2010) • Java-like, with more expressiveness
  • Kotlin (2011) • looks a lot like Swift (even though created independently by JetBrains)
  • Xtend (2011) • Java-like, with more expressiveness

Several of the above can also target CLR, or transpile to JavaScript.

I've programmed in Java for a couple years. I have played with Scala, Clojure, and Kotlin. The others I have no experience with.

My friends who have programmed a lot in Kotlin really like it. (They also really like Swift.)

I distinguish Scala as a "OO language, with FP" from F# as a "FP language, with OO". That may be a subtle distinction if you just language browsing.

fre_d profile image
Frederik Ar. Mikkelsen

In my opinion, the only thing you need to learn Kotlin is Kotlin Koans, followed by occasionally reading the documentation. This will guide you through the most important features of Kotlin. I wouldn't recommend going cold turkey.

Kotlin has made development less tedious because it is much less verbose. It also enforces null safety, as opposed to the nullability annotations I was using before. Kotlin's lambdas are easier, more powerful, and often faster than Java's. A small but awesome feature is that it adds functional operators to collections (map, filter, associate, etc).

Though I'm not an Android developer.

eljayadobe profile image

To me, Kotlin and Scala are two different animals.

I like Kotlin. It has a lot of similarities to Swift. Although, it seems to me that Kotlin still requires the developer have a good understanding of Java, to understand what would otherwise appear to be quirky behavior. (That may just be my bias, and/or my limited experience with Kotlin.) Kotlin is made by the JetBrains folks, and they are some impressive folks over there, doing amazing things.

I am not liking Scala. I like it better than Java. But I contrast/compare Scala with F#. I really like F#. To me, Scala seems like it took some Haskell seasoning to add some FP flavor to OO. I think I would have liked Scala more if it had gone more deeply with the FP. If I were going to do FP work for JVM, I think I'd choose Clojure over Scala. If I were going to do OO work for JVM, I'd choose Kotlin over Scala.

However, my disclaimer is: I've only played with Scala and Kotlin. I have not done a real project with either language. I have friends who have done real projects with Kotlin, and like it. I do not personally know anyone who has done a real project with Scala.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.