Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nice to meet you Kotlin

Gerard
September 04, 2017

Nice to meet you Kotlin

Kotlin has been announced as a first class language for Android developement by Google at the Google I/O 2017. This talk presents Kotlin as a mature and production ready language to migrate all Android projects from Java to Kotlin.

Gerard

September 04, 2017
Tweet

More Decks by Gerard

Other Decks in Programming

Transcript

  1. NICE TO MEET YOU
    Gerard Paligot

    View full-size slide

  2. KOTLIN
    Presentation

    View full-size slide

  3. KOTLIN
    - Started in mid 2010
    Presentation

    View full-size slide

  4. KOTLIN
    - Started in mid 2010
    - Avoid huge Java codebase
    Presentation

    View full-size slide

  5. KOTLIN
    - Started in mid 2010
    - Avoid huge Java codebase
    - Building tools for many languages
    Presentation

    View full-size slide

  6. KOTLIN
    - Started in mid 2010
    - Avoid huge Java codebase
    - Building tools for many languages
    - Want a modern, expressive language
    Presentation

    View full-size slide

  7. KOTLIN
    - Started in mid 2010
    - Avoid huge Java codebase
    - Building tools for many languages
    - Want a modern, expressive language
    - Easy to introduce in the existing environment
    Presentation

    View full-size slide

  8. KOTLIN
    Design Goals

    View full-size slide

  9. KOTLIN
    - Full Java interoperability
    Design Goals

    View full-size slide

  10. KOTLIN
    - Full Java interoperability
    - Compile as fast as Java
    Design Goals

    View full-size slide

  11. KOTLIN
    - Full Java interoperability
    - Compile as fast as Java
    - More concise than Java
    Design Goals

    View full-size slide

  12. KOTLIN
    - Full Java interoperability
    - Compile as fast as Java
    - More concise than Java
    - Prevent more kinds of errors than Java
    Design Goals

    View full-size slide

  13. KOTLIN
    - Full Java interoperability
    - Compile as fast as Java
    - More concise than Java
    - Prevent more kinds of errors than Java
    - Was simpler than Scala
    Design Goals

    View full-size slide

  14. WHY USE KOTLIN?

    View full-size slide

  15. WHY USE KOTLIN?

    View full-size slide

  16. WHY USE KOTLIN?
    - In a future, will replace Java as first language

    View full-size slide

  17. WHY USE KOTLIN?
    - In a future, will replace Java as first language
    - High adoption of the Android community

    View full-size slide

  18. WHY USE KOTLIN?
    - In a future, will replace Java as first language
    - High adoption of the Android community
    - Easy learning for iOS and Android developers

    View full-size slide

  19. WHY USE KOTLIN?
    - In a future, will replace Java as first language
    - High adoption of the Android community
    - Easy learning for iOS and Android developers
    - Null safety

    View full-size slide

  20. WHY USE KOTLIN?
    - In a future, will replace Java as first language
    - High adoption of the Android community
    - Easy learning for iOS and Android developers
    - Null safety
    - Less code is better!

    View full-size slide

  21. WHY USE KOTLIN?
    - In a future, will replace Java as first language
    - High adoption of the Android community
    - Easy learning for iOS and Android developers
    - Null safety
    - Less code is better!
    - Compilation speed

    View full-size slide

  22. WHY USE KOTLIN?
    High adoption of the Android community

    View full-size slide

  23. WHY USE KOTLIN?
    Compilation speed

    View full-size slide

  24. WHY USE KOTLIN?
    Compilation speed
    Deamon Gradle deactivated

    View full-size slide

  25. WHY USE KOTLIN?
    Compilation speed
    Deamon Gradle activated

    View full-size slide

  26. WHY USE KOTLIN?
    Compilation speed
    One isolated file changed

    View full-size slide

  27. WHY USE KOTLIN?
    Compilation speed
    One file changed

    View full-size slide

  28. ONE MORE THING…

    View full-size slide

  29. KOTLIN IS AVAILABLE ON…

    View full-size slide

  30. KOTLIN IS AVAILABLE ON…

    View full-size slide

  31. KOTLIN IS AVAILABLE ON…

    View full-size slide

  32. KOTLIN IS AVAILABLE ON…

    View full-size slide

  33. KOTLIN IS AVAILABLE ON…

    View full-size slide

  34. KOTLIN IS AVAILABLE ON…
    Native

    View full-size slide

  35. KOTLIN IS AVAILABLE ON…
    Native

    View full-size slide

  36. KOTLIN IS AVAILABLE ON…
    Native

    View full-size slide

  37. KOTLIN IS AVAILABLE ON…
    Native

    View full-size slide

  38. WHAT DOES IT MEANS?

    View full-size slide

  39. WHAT DOES IT MEANS?
    - Can create only one project for Android and iOS

    View full-size slide

  40. WHAT DOES IT MEANS?
    - Can create only one project for Android and iOS
    - Back Office can be developed in Kotlin

    View full-size slide

  41. WHAT DOES IT MEANS?
    - Can create only one project for Android and iOS
    - Back Office can be developed in Kotlin
    - Only one language for all projects, all teams

    View full-size slide

  42. SWIFT vs KOTLIN

    View full-size slide

  43. JAVA vs KOTLIN

    View full-size slide

  44. JAVA vs KOTLIN
    val person = KotlinPerson("John Doe")
    Null safety

    View full-size slide

  45. JAVA vs KOTLIN
    val person: KotlinPerson = KotlinPerson("John Doe")
    Null safety

    View full-size slide

  46. JAVA vs KOTLIN
    val person: KotlinPerson? = KotlinPerson("John Doe")
    Null safety

    View full-size slide

  47. JAVA vs KOTLIN
    val person: KotlinPerson? = null
    Null safety

    View full-size slide

  48. JAVA vs KOTLIN
    val person: KotlinPerson? = KotlinPerson("John Doe")
    println(person.name) // ERROR compilation
    Null safety

    View full-size slide

  49. JAVA vs KOTLIN
    val person: KotlinPerson? = KotlinPerson("John Doe")
    println(person?.name) // print null if person is null
    Null safety

    View full-size slide

  50. JAVA vs KOTLIN
    val person: KotlinPerson? = KotlinPerson("John Doe")
    println(person!!.name) // NPE if person is null
    Null safety

    View full-size slide

  51. JAVA vs KOTLIN
    val person: KotlinPerson? = KotlinPerson("John Doe")
    if (person != null) println(person.name)
    Null safety

    View full-size slide

  52. JAVA vs KOTLIN
    public class JavaPerson {
    private String name;
    public JavaPerson(String name) { this.name = name; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    @Override public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    JavaPerson that = (JavaPerson) o;
    return name != null ? name.equals(that.name) : that.name == null;
    }
    @Override public int hashCode() {
    return name != null ? name.hashCode() : 0;
    }
    @Override public String toString() {
    return "JavaPerson{name='" + name + "'}";
    }
    }
    Data classes

    View full-size slide

  53. JAVA vs KOTLIN
    data class KotlinPerson(val name: String)
    Data classes

    View full-size slide

  54. JAVA vs KOTLIN
    val person = KotlinPerson("John Doe")
    println("Name is " + person.name)
    Data classes

    View full-size slide

  55. JAVA vs KOTLIN
    val person = KotlinPerson("John Doe")
    println("Name is ${person.name}")
    Data classes

    View full-size slide

  56. JAVA vs KOTLIN
    val person = KotlinPerson("John Doe")
    println("Name is $person") // Use toString function
    Data classes

    View full-size slide

  57. JAVA vs KOTLIN
    fun MutableMap.getKey(value: V): K {
    return keys.first { get(it) == value }
    }
    Extensions

    View full-size slide

  58. JAVA vs KOTLIN
    fun MutableMap.getKey(value: V): K {
    return keys.first { get(it) == value }
    }
    val key = map.getKey(value)
    Extensions

    View full-size slide

  59. SUMMARY
    - Kotlin is mature and ready for production

    View full-size slide

  60. SUMMARY
    - Kotlin is mature and ready for production
    - Designed to be compatible and better than Java

    View full-size slide

  61. SUMMARY
    - Kotlin is mature and ready for production
    - Designed to be compatible and better than Java
    - Easy to learn and high adoption by the Android community

    View full-size slide

  62. SUMMARY
    - Kotlin is mature and ready for production
    - Designed to be compatible and better than Java
    - Easy to learn and high adoption by the Android community
    - Compatible with Java, Android, Javascript and soon native!

    View full-size slide

  63. KOTLIN READY FOR US?

    View full-size slide

  64. KOTLIN READY FOR US?
    - Not ready for iOS project

    View full-size slide

  65. KOTLIN READY FOR US?
    - Not ready for iOS project
    - Android applications can migrate to Kotlin right now

    View full-size slide

  66. KOTLIN READY FOR US?
    - Not ready for iOS project
    - Android applications can migrate to Kotlin right now
    - Back-Office to develop? Think to Kotlin, Ktor is there

    View full-size slide

  67. NICE TO MEET YOU
    Gerard Paligot

    View full-size slide