Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Kotlin vs Java • Bapusaheb Patil • TechieAid Talk

249 views

Published on

Slides to a talk I gave on-stage at TechieAid about Kotlin vs Java.
Date: August 1st, 2018
My website: https://bapspatil.com

Published in: Software
  • Login to see the comments

  • Be the first to like this

Kotlin vs Java • Bapusaheb Patil • TechieAid Talk

  1. 1. Kotlin vs Java Bapusaheb Patil Google Certified Android Developer & OpenClassrooms Android Mentor www.bapspatil.com TechieAid
  2. 2. www.bapspatil.com What’s Kotlin?
  3. 3. www.bapspatil.com Kotlin is a new programming language… ...that’s gonna replace Java.
  4. 4. www.bapspatil.com Hold on, what’s wrong with Java?
  5. 5. www.bapspatil.com ● Requires more code to do simple tasks. ● NullPointerExceptions make life hell. ● Not that friendly with Android.
  6. 6. www.bapspatil.com Enter, Kotlin. ● Takes care of null-safety. ● More concise & much shorter code. ● Runs on JVM. ● Can be used along with Java files. ...and more that can’t be covered in my talk.
  7. 7. www.bapspatil.com Basic Data Types ● Double ● Float ● Long ● Int ● Short ● Byte ● Boolean ● Char ● String ● Array
  8. 8. www.bapspatil.com Declaring A Variable... ● var - Mutable variable ● val - Immutable or final variable Example: var name: String? = “TechieAid” val students: Int = 120 ? means the variable can be null.
  9. 9. www.bapspatil.com Null-Safety // Doesn’t compile, to be safe. var name: String = null // Compiles safely var name: String? = null
  10. 10. www.bapspatil.com Java Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Toast.makeText(getApplicationContext(), “Hey there!”, Toast.LENGTH_SHORT).show(); } } Kotlin button.onClick { toast(“Hey there!”) }
  11. 11. www.bapspatil.com Java public class User { private int id; private String name; public User() { } public User(String name, int id) { this.id = id; this.name = name; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String toString() { return “User: “ + “ID=” + this.id + “Name=” + this.name; } } Kotlin data class User ( val id: Int, val name: String ) And that’s another reason Kotlin rules!
  12. 12. www.bapspatil.com Fun Facts About Kotlin?
  13. 13. www.bapspatil.com Android Documentation is now in Kotlin too!
  14. 14. www.bapspatil.com Number of Android Apps in Kotlin Stats from Jetbrains.com 2018 2019
  15. 15. www.bapspatil.com Number of Android Apps in Kotlin
  16. 16. www.bapspatil.com Great! Where Do I Learn Kotlin From? Kotlinlang.org • Official Website & Documentation Google Codelabs • Kotlin Is Awesome! • kotlin.link Mindorks.com • Talking Kotlin • Kotlin Bootcamp for Programmers • 
  17. 17. Thank you. Questions? Get in touch with me: Website • www.bapspatil.com Email  • hi@bapspatil.com TechieAid

×