Slide 1

Slide 1 text

Is Kotlin Ready for Android Peter-John Welcome @pjapplez

Slide 2

Slide 2 text

Google announced Kotlin will be an official language for Android

Slide 3

Slide 3 text

Kotlin Was born in 2011 by JetBrains Team ● Modern ● Expressive ● Magical ● Powerful ● Concise ● Extensible https://en.wikipedia.org/wiki/Kotlin_(programming_language)

Slide 4

Slide 4 text

Kotlin ● Small runtime ● Statically typed language ● Modern language ● Runs on JVM and converts to Java byte code ● Reduces errors and boiler plate code ● Composition over inheritance

Slide 5

Slide 5 text

Why Kotlin over Java ● We still on Java 6.5 in Android ● Java Code is error Prone with all its anonymous inner classes ● Java Language Restriction ( lambdas , Default Interfaces … etc ) ● Java code is very verbose.

Slide 6

Slide 6 text

What Java doesn’t have ● High-order functions ● Properties ● Extension functions ● Static null checks ● Auto casting/Smart casting ● Default parameters ● String interpolation ● Pattern matching ● Inline functions ● Infix methods

Slide 7

Slide 7 text

Android’s Root Problem https://image.slidesharecdn.com/droidcon-bugsense-130408170720-phpapp01/95/droid-con-bugsense-16-638.jpg?cb=1365440918

Slide 8

Slide 8 text

"I call it my billion-dollar mistake... [which] has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years." — Sir Charles Antony Richard Hoare Nullability https://blog.valbonne-consulting.com/2014/11/26/tony-hoare-invention-of-the-null-reference-a-billion-dollar-mistake/

Slide 9

Slide 9 text

var a: String = "foo" a = null //Compilation error var b: String? = "bar" b = null //ok Nullability

Slide 10

Slide 10 text

val user = User() // there's no 'new' keyword in Kotlin user.name = "PJ" Properties

Slide 11

Slide 11 text

inline fun SharedPreferences.edit(action: SharedPreferences.Editor() -> Unit) { val editor = SharedPreferences.Editor() editor.action() editor.apply() } getSharedPreferences(MODE_PRIVATE).edit { putString("username", username) } Extension Functions for Android

Slide 12

Slide 12 text

Anko ● Anko Commons: a lightweight library full of helpers for intents, dialogs, logging and so on; ● Anko Layouts: a fast and type-safe way to write dynamic Android layouts; ● Anko SQLite: a query DSL and parser collection for Android SQLite; ● Anko Coroutines: utilities based on the kotlinx.coroutines library.

Slide 13

Slide 13 text

Should we be on the Kotlin Train? Most Definitely !!!!

Slide 14

Slide 14 text

Kotlin advantages ● Less crashes ● Easier to develop in ● Encourages functional paradigm ● 100 % Interoperable with Java ( Can use within existing code base.)

Slide 15

Slide 15 text

Kotlin Community

Slide 16

Slide 16 text

Resources ● https://blog.mindorks.com/a-complete-guide-to-learn-kotlin-for-android-development-b1e5d23 cc2d8 ● https://leanpub.com/kotlin-for-android-developers ● https://developer.android.com/kotlin/index.html ● https://kotlinlang.org/docs/tutorials/kotlin-android.html

Slide 17

Slide 17 text

Thanks! Contact me: google.com/u/0/+PeterJohnWelcome @pjapplez [email protected] Peter-johnwelcome.co.za https://github.com/pjwelcome