Save 37% off PRO during our Black Friday Sale! »

Nice to meet you Kotlin

B6bf611a9e4f70a8455cb175339e0587?s=47 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.

B6bf611a9e4f70a8455cb175339e0587?s=128

Gerard

September 04, 2017
Tweet

Transcript

  1. NICE TO MEET YOU Gerard Paligot

  2. KOTLIN

  3. KOTLIN

  4. KOTLIN

  5. KOTLIN

  6. KOTLIN

  7. KOTLIN Presentation

  8. KOTLIN - Started in mid 2010 Presentation

  9. KOTLIN - Started in mid 2010 - Avoid huge Java

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

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

    codebase - Building tools for many languages - Want a modern, expressive language Presentation
  12. 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
  13. KOTLIN Design Goals

  14. KOTLIN - Full Java interoperability Design Goals

  15. KOTLIN - Full Java interoperability - Compile as fast as

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

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

    Java - More concise than Java - Prevent more kinds of errors than Java Design Goals
  18. 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
  19. WHY USE KOTLIN?

  20. WHY USE KOTLIN?

  21. WHY USE KOTLIN? - In a future, will replace Java

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

    as first language - High adoption of the Android community
  23. 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
  24. 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
  25. 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!
  26. 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
  27. WHY USE KOTLIN? High adoption of the Android community

  28. WHY USE KOTLIN? Compilation speed

  29. WHY USE KOTLIN? Compilation speed Deamon Gradle deactivated

  30. WHY USE KOTLIN? Compilation speed Deamon Gradle activated

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

  32. WHY USE KOTLIN? Compilation speed One file changed

  33. ONE MORE THING…

  34. KOTLIN IS AVAILABLE ON…

  35. KOTLIN IS AVAILABLE ON…

  36. KOTLIN IS AVAILABLE ON…

  37. KOTLIN IS AVAILABLE ON…

  38. KOTLIN IS AVAILABLE ON…

  39. KOTLIN IS AVAILABLE ON… Native

  40. KOTLIN IS AVAILABLE ON… Native

  41. KOTLIN IS AVAILABLE ON… Native

  42. KOTLIN IS AVAILABLE ON… Native

  43. WHAT DOES IT MEANS?

  44. WHAT DOES IT MEANS? - Can create only one project

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

    for Android and iOS - Back Office can be developed in Kotlin
  46. 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
  47. VERSUS

  48. SWIFT vs KOTLIN

  49. JAVA vs KOTLIN

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

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

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

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

  54. JAVA vs KOTLIN val person: KotlinPerson? = KotlinPerson("John Doe") println(person.name)

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

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

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

    (person != null) println(person.name) Null safety
  58. 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
  59. JAVA vs KOTLIN data class KotlinPerson(val name: String) Data classes

  60. JAVA vs KOTLIN val person = KotlinPerson("John Doe") println("Name is

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

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

    $person") // Use toString function Data classes
  63. JAVA vs KOTLIN fun <K, V> MutableMap<K, V>.getKey(value: V): K

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

    { return keys.first { get(it) == value } } val key = map.getKey(value) Extensions
  65. SUMMARY

  66. SUMMARY - Kotlin is mature and ready for production

  67. SUMMARY - Kotlin is mature and ready for production -

    Designed to be compatible and better than Java
  68. 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
  69. 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!
  70. KOTLIN READY FOR US?

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

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

    - Android applications can migrate to Kotlin right now
  73. 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
  74. NICE TO MEET YOU Gerard Paligot