DEV Community

Cover image for Why use Kotlin for Android development? Kotlin benefits, features, versions

Why use Kotlin for Android development? Kotlin benefits, features, versions

Diana Maltseva on October 04, 2018

In accordance with Stack Overflow Developer Survey 2018, Kotlin is the 2nd most loved programming language and the 4th most wanted in the world. ...
Collapse
 
pawarpayal005 profile image
Payal Pawar • Edited

Which is better programming language (Java or Kotlin) to use in Android Development and how to use it? Please guide me.

Collapse
 
dianamaltseva8 profile image
Diana Maltseva • Edited

Hi.) Kotlin is much simpler and allows writing more concise code. Provides features missed in Java, while it is fully compatible with it. Java is more popular as it exists for decades and it is really great. Many companies are using Java, so you might need it to work on some projects.

Here is a list of sources that will help you learn Kotlin:

Kotlin on Android:

  1. Get Started with Kotlin on Android: A short guide to start using Kotlin in Android Studio.
  2. Kotlin-Java Interop Guide: A set of rules for authoring public APIs interoperable in Java and Kotlin.
  3. Kotlin Style Guide: Google’s Android coding standards for source code in the Kotlin Programming Language.

Samples

  1. Sunflower: An end-to-end sample app that illustrates Android development best practices with Kotlin and Jetpack.
  2. Kotlin samples: A collection of Android code samples written in Kotlin.
  3. Converting your iOS App to Android Using Kotlin

Other

  1. Tutorials
  2. Kotlin on StackOverflow

Hope, I've helped you!)

Collapse
 
savnisharma1 profile image
savnisharma

If you are starting with Android, definitely go with Java as you will be able to find much more information about Android development in Java which will be extremely important in the starting phase.

Later, you can switch to Kotlin or stay with Java as per your preference.

Kotlin is just another language for JVM (Java Virtual Machine) and knowing Java will help you to grasp Kotlin faster as a lot of information is available in form of comparation between Kotlin and Java.

As you will become skilled in both languages, you can find solution in Kotlin or Java and you will be easily able to transform it to the language you are actually using.

And do not worry about Google replacing Java. Kotlin is just a language and needs Java VM to work and the heart of Android is defacto Java VM, so Kotlin is not a new language for Android - it’s just an another option how to write code that will be then compiled to Java byte code, so both Java and Kotlin will co-exists together. For Kotlin, this kind of co-existence is extremely important because Java’s ecosystem is mature, stable and provides way more libraries than is available for any other language. And this gives Kotlin a huge advantage over new programming languages written from scratch.

Spring Framework Online Course

Collapse
 
kabirules profile image
kabirules

I've translated this article to Spanish in case anyone is interested
developinginspanish.com/2019/08/24...

Collapse
 
dianamaltseva8 profile image
Diana Maltseva

Hey! I want to share the link to this article on my Twitter (twitter.com/DianaMaltseva8) and include your name or better - a link to your account on Twitter, too. Could you please provide me with this info?)

Collapse
 
kabirules profile image
kabirules

Sure! My twitter is twitter.com/kabi_rules
Thanks a lot for sharing!

Collapse
 
dianamaltseva8 profile image
Diana Maltseva

Great, well done!

Collapse
 
martin profile image
Martin Beentjes

How is the support with Streams today?

Collapse
 
tedhagos profile image
Ted Hagos

There's an article about Kotlin in here;

There's a portion in it where Streams are discussed; short answer is
  • Kotlin has Streams
  • All collection classes in Kotlin already supports the one-time_iterator behavior of java.util.stream.Stream instance
  • Kotlin doesn't need the initial conversion (collection to stream) and the final conversion (stream back to a collection)
  • BUT remember that Java streams are lazily evaluated while Kotlin streams are eagerly evaluated unless you convert to a Sequence
Collapse
 
dianamaltseva8 profile image
Diana Maltseva

If I've understood you right (you mean the ability to work with streams from Java 8 and Kotlin), kotlin-stdlib provides several extension-functions for transferring Java-Stream into Kotlin-Sequence or Kotlin-List kotlinlang.org/api/latest/jvm/stdl....

If you want to know what alternative Kotlin provides Java-Streams with, collections in Kotlin "out of the box" offer operations, available in Java only when transferring collections into Stream.

To compare:

  • Java someList .stream() .map() // some operations .collect(Collectors.toList());
  • Kotlin someList .map()
Collapse
 
noahbenz2 profile image
Noah Benz

I believe most of the developers still use Java since its the old way. But Kotlin could be a better switch. Take Java Certification Course.