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

An Introduction to Kotlin

An Introduction to Kotlin

Kotlin has been catching on lately as an alternative to Java because of its null safety guarantees, type inference, cross-platform support, and ease of use with Android and Spring. Not to mention the fact that it is fully interoperable with Java. Is this something you and your team should considering spending time to learn?

Come to this session for an overview of Kotlin intended for Java developers (don't worry if you don't know Java, Kotlin is very easy to learn!). We will go over the major language features, syntax, and the Kotlin ecosystem so you'll know enough to make your own decisions by the end.

You will come away from this session with enough knowledge to decide if this is something you and your team should consider adopting.

Todd Ginsberg

October 11, 2019
Tweet

More Decks by Todd Ginsberg

Other Decks in Technology

Transcript

  1. @ToddGinsberg
    An Introduction
    To Kotlin
    DevSpace 2019
    2019-10-11
    Todd Ginsberg
    Principal Software Developer

    View full-size slide

  2. @ToddGinsberg
    Kotlin in 30 Minutes?!

    View full-size slide

  3. @ToddGinsberg
    Kotlin in 30 Minutes?!
    No, that’s crazy!

    View full-size slide

  4. @ToddGinsberg
    Kotlin in 30 Minutes?!
    No, that’s crazy!
    (But come have lunch with me after!)

    View full-size slide

  5. @ToddGinsberg
    Kotlin in 30 Minutes?!
    No, that’s crazy!
    (But come have lunch with me after!)
    (Or come to the open space!)

    View full-size slide

  6. @ToddGinsberg
    Agenda
    - What Is Kotlin?

    View full-size slide

  7. @ToddGinsberg
    Agenda
    - What Is Kotlin?
    - Am I Alone?

    View full-size slide

  8. @ToddGinsberg
    Agenda
    - What Is Kotlin?
    - Am I Alone?
    - Syntax & Features

    View full-size slide

  9. @ToddGinsberg
    Agenda
    - What Is Kotlin?
    - Am I Alone?
    - Syntax & Features
    - Summary

    View full-size slide

  10. @ToddGinsberg
    Agenda
    - What Is Kotlin?
    - Am I Alone?
    - Syntax & Features
    - Summary
    - Questions?

    View full-size slide

  11. @ToddGinsberg
    Who is this Guy?
    Todd Ginsberg

    View full-size slide

  12. @ToddGinsberg
    Who is this Guy?
    Todd Ginsberg
    Just moved to Dallas from Chicago

    View full-size slide

  13. @ToddGinsberg
    Who is this Guy?
    Todd Ginsberg
    Just moved to Dallas from Chicago
    Principal Developer at Netspend
    - A payments company in Austin, TX!
    - We love Kotlin and Java!

    View full-size slide

  14. @ToddGinsberg
    What Is Kotlin?

    View full-size slide

  15. @ToddGinsberg
    What Is Kotlin?
    Statically typed language, developed by JetBrains

    View full-size slide

  16. @ToddGinsberg
    What Is Kotlin?
    Statically typed language, developed by JetBrains
    Released under Apache 2.0 license

    View full-size slide

  17. @ToddGinsberg
    What Is Kotlin?
    Statically typed language, developed by JetBrains
    Released under Apache 2.0 license
    Designed as a general purpose language

    View full-size slide

  18. @ToddGinsberg
    What Is Kotlin?
    Statically typed language, developed by JetBrains
    Released under Apache 2.0 license
    Designed as a general purpose language
    ● Targets JVM 6 or 8 bytecode

    View full-size slide

  19. @ToddGinsberg
    What Is Kotlin?
    Statically typed language, developed by JetBrains
    Released under Apache 2.0 license
    Designed as a general purpose language
    ● Targets JVM 6 or 8 bytecode
    ● Targets ECMAScript 5.1

    View full-size slide

  20. @ToddGinsberg
    What Is Kotlin?
    Statically typed language, developed by JetBrains
    Released under Apache 2.0 license
    Designed as a general purpose language
    ● Targets JVM 6 or 8 bytecode
    ● Targets ECMAScript 5.1
    ● Targets other native platforms thanks to LLVM

    View full-size slide

  21. @ToddGinsberg
    Major Features
    100% Interoperable with Java

    View full-size slide

  22. @ToddGinsberg
    Major Features
    100% Interoperable with Java
    Designed to avoid entire classes of defects

    View full-size slide

  23. @ToddGinsberg
    Major Features
    100% Interoperable with Java
    Designed to avoid entire classes of defects
    Lots of small improvements that add up

    View full-size slide

  24. @ToddGinsberg
    Major Features
    100% Interoperable with Java
    Designed to avoid entire classes of defects
    Lots of small improvements that add up
    Far less code to accomplish the same task in Java
    - Less cognitive load on developers

    View full-size slide

  25. @ToddGinsberg
    Major Features
    Null-safe

    View full-size slide

  26. @ToddGinsberg
    Major Features
    Null-safe
    189,000+ issues on GitHub!

    View full-size slide

  27. @ToddGinsberg
    Major Features
    Null-safe
    189,000+ issues on GitHub!
    14,492 duplicates on Stack Overflow!

    View full-size slide

  28. @ToddGinsberg
    Major Features
    Pragmatic Improvements
    No shame in copying language features that
    make developers more productive

    View full-size slide

  29. @ToddGinsberg
    Am I Alone?

    View full-size slide

  30. @ToddGinsberg
    Supported on Android
    2017
    It should work,
    give it a try!

    View full-size slide

  31. @ToddGinsberg
    Supported on Android
    2018
    Prefer Kotlin
    over Java

    View full-size slide

  32. @ToddGinsberg
    Supported on Android
    2019
    Android is now
    Kotlin first!

    View full-size slide

  33. @ToddGinsberg
    Spring Framework Support
    Kotlin is fully supported since Spring Framework 5

    View full-size slide

  34. @ToddGinsberg
    Spring Framework Support
    Kotlin is fully supported since Spring Framework 5
    Kotlin is an option on start.spring.io

    View full-size slide

  35. @ToddGinsberg
    Spring Framework Support
    Kotlin is fully supported since Spring Framework 5
    Kotlin is an option on start.spring.io
    Spring @NotNull annotations == Better Kotlin nullability support

    View full-size slide

  36. @ToddGinsberg
    Spring Framework Support
    Kotlin is fully supported since Spring Framework 5
    Kotlin is an option on start.spring.io
    Spring @NotNull annotations == Better Kotlin nullability support
    Comprehensive Kotlin documentation and examples

    View full-size slide

  37. @ToddGinsberg
    Gradle DSL

    View full-size slide

  38. @ToddGinsberg
    Syntax

    View full-size slide

  39. @ToddGinsberg
    Variables and Values
    var place: String = "Huntsville"

    View full-size slide

  40. @ToddGinsberg
    Variables and Values
    var place: String = "Huntsville"
    place = "Alabama" // OK!

    View full-size slide

  41. @ToddGinsberg
    Variables and Values
    var place: String = "Huntsville"
    place = "Alabama" // OK!
    val name: String = "Todd"

    View full-size slide

  42. @ToddGinsberg
    Variables and Values
    var place: String = "Huntsville"
    place = "Alabama" // OK!
    val name: String = "Todd"
    name = "Emma" // Compile Error!

    View full-size slide

  43. @ToddGinsberg
    Type Inference
    val d: Int = 2
    val text: String = "Todd has $d doughnuts"

    View full-size slide

  44. @ToddGinsberg
    Type Inference
    val d: Int = 2
    val text: String = "Todd has $d doughnuts"

    View full-size slide

  45. @ToddGinsberg
    Type Inference
    val d = 2
    val text = "Todd has $d doughnuts"

    View full-size slide

  46. @ToddGinsberg
    Equality
    val name1 = "EXAMPLE"
    val name2 = "example"

    View full-size slide

  47. @ToddGinsberg
    Equality
    val name1 = "EXAMPLE"
    val name2 = "example"
    // Structural Equality
    name1 == name2.toUpperCase() // True!

    View full-size slide

  48. @ToddGinsberg
    Equality
    val name1 = "EXAMPLE"
    val name2 = "example"
    // Structural Equality
    name1 == name2.toUpperCase() // True!
    // Referential Equality
    name1 === name2 // False!

    View full-size slide

  49. @ToddGinsberg
    Raw Strings
    val json = "{\n\"name\": \"Todd\"\n}"

    View full-size slide

  50. @ToddGinsberg
    Raw Strings
    val json = "{\n\"name\": \"Todd\"\n}"
    val json = """{ "name": "Todd" }"""

    View full-size slide

  51. @ToddGinsberg
    Raw Strings
    val json = "{\n\"name\": \"Todd\"\n}"
    val json =
    """
    {
    "name": "Todd"
    }
    """

    View full-size slide

  52. @ToddGinsberg
    Null Safety
    // Guaranteed to never be null
    var name: String = "Todd"

    View full-size slide

  53. @ToddGinsberg
    Null Safety
    // Guaranteed to never be null
    var name: String = "Todd"
    // May be null
    var salary: Int? = null

    View full-size slide

  54. @ToddGinsberg
    Null-Safe Traversal
    var city: String? = "Huntsville"

    View full-size slide

  55. @ToddGinsberg
    Null-Safe Traversal
    var city: String? = "Huntsville"
    // Not allowed, might be null!
    city.toUpperCase()

    View full-size slide

  56. @ToddGinsberg
    Null-Safe Traversal
    var city: String? = "Huntsville"
    // Not allowed, might be null!
    city.toUpperCase()
    // Safe traversal
    city?.toUpperCase()

    View full-size slide

  57. @ToddGinsberg
    Elvis
    val lowest : Int? = listOf(1, 2, 3).min()

    View full-size slide

  58. @ToddGinsberg
    Elvis
    val lowest : Int? = listOf(1, 2, 3).min()
    val lowest : Int = listOf(1, 2, 3).min() ?: 0

    View full-size slide

  59. @ToddGinsberg
    Combine Safe-Traversal and Elvis
    println(
    city?.toUpperCase() ?: ”UNKNOWN”
    )

    View full-size slide

  60. @ToddGinsberg
    Manual Override
    val lowest: Int? = listOf(1, 2, 3).min()

    View full-size slide

  61. @ToddGinsberg
    Hey Kotlin, Hold My Beer!
    val lowest: Int? = listOf(1, 2, 3).min()
    val lowest: Int = listOf(1, 2, 3).min()!!

    View full-size slide

  62. @ToddGinsberg
    Hey Kotlin, Hold My Beer!
    val lowest: Int? = listOf(1, 2, 3).min()
    val lowest: Int = listOf(1, 2, 3).min()!!
    val lowest: Int = emptyList().min()!!

    View full-size slide

  63. @ToddGinsberg
    Hey Kotlin, Hold My Beer!
    val lowest: Int? = listOf(1, 2, 3).min()
    val lowest: Int = listOf(1, 2, 3).min()!!
    val lowest: Int = emptyList().min()!!
    // NullPointerException!

    View full-size slide

  64. @ToddGinsberg
    Expressions - if
    val status = if (code == 42) {
    "Success"
    } else {
    "Fail"
    }

    View full-size slide

  65. @ToddGinsberg
    Expressions - try/catch
    val number = try {
    code.toInt()
    } catch (e: NumberFormatException) {
    0
    }

    View full-size slide

  66. @ToddGinsberg
    Expressions - when
    val result = when (x) {
    0 -> "x is 0”
    in 1..10 -> "x is between 1 and 10"
    in someSet -> "x is in someSet"
    is SomeType -> "x is an instance of SomeType"
    parseString(s) -> "the same as parseString"
    else -> "x doesn't match anything"
    }

    View full-size slide

  67. @ToddGinsberg
    Smart Casting
    when (x) {
    is Int -> print(x % 2 == 0)
    is String -> print(x.length + 1)
    is IntArray -> print(x.sum())
    }

    View full-size slide

  68. @ToddGinsberg
    Smart Casting
    when (x) {
    is Int -> print(x % 2 == 0)
    is String -> print(x.length + 1)
    is IntArray -> print(x.sum())
    }

    View full-size slide

  69. @ToddGinsberg
    Smart Casting
    if(x != null) {
    println(x.toString())
    }

    View full-size slide

  70. @ToddGinsberg
    Classes
    class Entity : SomeInterface {
    // ...
    }

    View full-size slide

  71. @ToddGinsberg
    Classes - Inheritance
    open class Entity : SomeInterface {
    // ...
    }
    class Customer : Entity() {
    // ...
    }

    View full-size slide

  72. @ToddGinsberg
    Properties
    public class Customer {
    private String name;
    public String getName() {
    return name;
    }
    public void setName(final String name) {
    this.name = name;
    }
    }

    View full-size slide

  73. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    }

    View full-size slide

  74. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    }
    val c = Customer()

    View full-size slide

  75. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    }
    val c = Customer()
    c.name = "Todd"

    View full-size slide

  76. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    }
    val c = Customer()
    c.name = "Todd"
    println("My name is ${c.name}")

    View full-size slide

  77. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    }

    View full-size slide

  78. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    set(value) {
    field = value?.toUpperCase()
    }
    }

    View full-size slide

  79. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    private set(value) {
    field = value?.toUpperCase()
    }
    }

    View full-size slide

  80. @ToddGinsberg
    Properties
    class Customer {
    var name: String? = null
    get() {
    return field?.toUpperCase()
    }
    }

    View full-size slide

  81. @ToddGinsberg
    Let’s Write a POJO!
    public class Person {
    public String firstName;
    public String lastName;
    }

    View full-size slide

  82. @ToddGinsberg
    Let’s Write a POJO!
    public class Person {
    private String firstName;
    private String lastName;
    public String getFirstName() {
    return firstName;
    }
    public void setFirstName(final String firstName) {
    this.firstName = firstName;
    }
    public String getLastName() {
    return lastName;
    }
    public void setLastName(final String lastName) {
    this.lastName = lastName;
    }
    }

    View full-size slide

  83. @ToddGinsberg
    Let’s Write a POJO!
    public class Person {
    private String firstName;
    private String lastName;
    public Person() { }
    public Person(final String firstName, final String lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
    }
    public String getFirstName() {
    return firstName;
    }
    public void setFirstName(final String firstName) {
    this.firstName = firstName;
    }
    public String getLastName() {
    return lastName;
    }
    public void setLastName(final String lastName) {
    this.lastName = lastName;
    }
    }

    View full-size slide

  84. @ToddGinsberg
    Let’s Write a POJO!
    import java.util.Objects;
    public class Person {
    private String firstName;
    private String lastName;
    public Person() { }
    public Person(final String firstName, final String lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
    }
    public String getFirstName() {
    return firstName;
    }
    public void setFirstName(final String firstName) {
    this.firstName = firstName;
    }
    public String getLastName() {
    return lastName;
    }
    public void setLastName(final String lastName) {
    this.lastName = lastName;
    }
    @Override
    public boolean equals(final Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    final Person person = (Person) o;
    return Objects.equals(firstName, person.firstName) &&
    Objects.equals(lastName, person.lastName);
    }
    @Override
    public int hashCode() {
    return Objects.hash(firstName, lastName);
    }
    }

    View full-size slide

  85. @ToddGinsberg
    Let’s Write a POJO!
    import java.util.Objects;
    public class Person {
    private String firstName;
    private String lastName;
    public Person() { }
    public Person(final String firstName, final String lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
    }
    public String getFirstName() {
    return firstName;
    }
    public void setFirstName(final String firstName) {
    this.firstName = firstName;
    }
    public String getLastName() {
    return lastName;
    }
    public void setLastName(final String lastName) {
    this.lastName = lastName;
    }
    @Override
    public boolean equals(final Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    final Person person = (Person) o;
    return Objects.equals(firstName, person.firstName) &&
    Objects.equals(lastName, person.lastName);
    }
    @Override
    public int hashCode() {
    return Objects.hash(firstName, lastName);
    }
    @Override
    public String toString() {
    return "Person{" +
    "firstName='" + firstName + '\'' +
    ", lastName='" + lastName + '\'' +
    '}';
    }
    }

    View full-size slide

  86. @ToddGinsberg
    Data Classes to the Rescue!
    data class Person(val firstName: String,
    val lastName: String)

    View full-size slide

  87. @ToddGinsberg
    Data Classes to the Rescue!
    data class Person(val firstName: String,
    val lastName: String)
    ● Getters (and Setters for vars) as Properties

    View full-size slide

  88. @ToddGinsberg
    Data Classes to the Rescue!
    data class Person(val firstName: String,
    val lastName: String)
    ● Getters (and Setters for vars) as Properties
    ● toString()

    View full-size slide

  89. @ToddGinsberg
    Data Classes to the Rescue!
    data class Person(val firstName: String,
    val lastName: String)
    ● Getters (and Setters for vars) as Properties
    ● toString()
    ● hashCode() and equals()

    View full-size slide

  90. @ToddGinsberg
    Data Classes to the Rescue!
    data class Person(val firstName: String,
    val lastName: String)
    ● Getters (and Setters for vars) as Properties
    ● toString()
    ● hashCode() and equals()
    ● And…

    View full-size slide

  91. @ToddGinsberg
    Copying Data Classes
    val me = Person("Todd", "Ginsberg")

    View full-size slide

  92. @ToddGinsberg
    Copying Data Classes
    val me = Person("Todd", "Ginsberg")
    val emma = me.copy(firstName = "Emma")
    // Person(”Emma", "Ginsberg")

    View full-size slide

  93. @ToddGinsberg
    FUNctions!
    fun generateRandomNumber(): Int {
    return 4
    }

    View full-size slide

  94. @ToddGinsberg
    FUNctions!
    fun generateRandomNumber(): Int {
    return 4
    }
    fun generateRandomNumber(): Int = 4

    View full-size slide

  95. @ToddGinsberg
    FUNctions!
    fun generateRandomNumber(): Int {
    return 4
    }
    fun generateRandomNumber(): Int = 4
    fun generateRandomNumber() = 4

    View full-size slide

  96. @ToddGinsberg
    FUNctions - Default Values
    fun random(offset: Int = 0): Int =
    offset + 4

    View full-size slide

  97. @ToddGinsberg
    FUNctions - Default Values
    fun random(offset: Int = 0): Int =
    offset + 4
    random() // 4

    View full-size slide

  98. @ToddGinsberg
    FUNctions - Default Values
    fun random(offset: Int = 0): Int =
    offset + 4
    random() // 4
    random(1) // 5

    View full-size slide

  99. @ToddGinsberg
    FUNctions - Adding Parameters
    fun combine(first: Int,
    second: Int): Int =
    first + second

    View full-size slide

  100. @ToddGinsberg
    FUNctions - Adding Parameters
    fun combine(first: Int,
    second: Int,
    third: Int = 0): Int =
    first + second + third

    View full-size slide

  101. @ToddGinsberg
    FUNctions - Adding Parameters
    fun combine(first: Int,
    second: Int,
    third: Int = 0): Int =
    first + second + third
    combine(1, 2)
    combine(1, 2, 3)

    View full-size slide

  102. @ToddGinsberg
    FUNctions - Named Parameters
    fun combine(first: Int,
    second: Int): Int =
    first + second

    View full-size slide

  103. @ToddGinsberg
    FUNctions - Named Parameters
    fun combine(first: Int,
    second: Int): Int =
    first + second
    combine(1, 2) // 3

    View full-size slide

  104. @ToddGinsberg
    FUNctions - Named Parameters
    fun combine(first: Int,
    second: Int): Int =
    first + second
    combine(first = 1, second = 2) // 3

    View full-size slide

  105. @ToddGinsberg
    FUNctions - Named Parameters
    fun combine(first: Int,
    second: Int): Int =
    first + second
    combine(second = 2, first = 1) // 3

    View full-size slide

  106. @ToddGinsberg
    FUNction Names
    @Test
    fun replicantsHaveAFourYearLifespan() {
    // ...
    }

    View full-size slide

  107. @ToddGinsberg
    FUNction Names
    @Test
    fun `Replicants have a four year lifespan!`() {
    // ...
    }

    View full-size slide

  108. @ToddGinsberg
    Extension FUNctions
    // Java
    public static boolean isEven(int i) {
    return i % 2 == 0;
    }

    View full-size slide

  109. @ToddGinsberg
    Extension FUNctions
    // Kotlin
    fun Int.isEven(): Boolean =
    this % 2 == 0

    View full-size slide

  110. @ToddGinsberg
    Extension FUNctions
    // Kotlin
    fun Int.isEven(): Boolean =
    this % 2 == 0
    2.isEven() // True!

    View full-size slide

  111. @ToddGinsberg
    The use Extension
    // Java
    try (Connection conn = getConnection()) {
    // ...
    }

    View full-size slide

  112. @ToddGinsberg
    The use Extension
    // Kotlin
    getConnection().use { conn ->
    // ...
    }

    View full-size slide

  113. @ToddGinsberg
    The apply Extension
    // Expression and Statements
    val p = Person()
    p.name = "Todd"
    p.age = 21

    View full-size slide

  114. @ToddGinsberg
    The apply Extension
    // Single Expression
    val p = Person().apply {
    name = "Todd"
    age = 21
    }

    View full-size slide

  115. @ToddGinsberg
    The apply Extension
    // Single Expression
    val p = Person().apply {
    name = "Todd"
    age = 21
    address = Address().apply {
    line1 = "5 Tall Cedar Rd."

    }
    }

    View full-size slide

  116. @ToddGinsberg
    One More Thing on FUNctions
    ● Functions are final by default.

    View full-size slide

  117. @ToddGinsberg
    One More Thing on FUNctions
    ● Functions are final by default.
    ● Arguments are always final.

    View full-size slide

  118. @ToddGinsberg
    One More Thing on FUNctions
    ● Functions are final by default.
    ● Arguments are always final.
    ● Functions can be defined in a file, outside of a class.

    View full-size slide

  119. @ToddGinsberg
    One More Thing on FUNctions
    ● Functions are final by default.
    ● Arguments are always final.
    ● Functions can be defined in a file, outside of a class.
    ● Functions can be defined within another function.

    View full-size slide

  120. @ToddGinsberg
    One More Thing on FUNctions
    ● Functions are final by default.
    ● Arguments are always final.
    ● Functions can be defined in a file, outside of a class.
    ● Functions can be defined within another function.
    ● Kotlin supports tail recursive functions.

    View full-size slide

  121. @ToddGinsberg
    What About Checked Exceptions?
    ?

    View full-size slide

  122. @ToddGinsberg
    What About Checked Exceptions?
    NO

    View full-size slide

  123. @ToddGinsberg
    Lambdas
    listOf(1, 2, 3, 4)
    .filter { x -> x % 2 == 0 }
    .map { y -> y * 2 }
    // List[4, 8]

    View full-size slide

  124. @ToddGinsberg
    Lambdas
    listOf(1, 2, 3, 4)
    .filter { x -> x % 2 == 0 }
    .map { y -> y * 2 }
    // List[4, 8]

    View full-size slide

  125. @ToddGinsberg
    Lambdas
    listOf(1, 2, 3, 4)
    .filter { it % 2 == 0 }
    .map { it * 2 }
    // List[4, 8]

    View full-size slide

  126. @ToddGinsberg
    Reified Generics
    // Ugly
    val log = Logger.getLogger(Metrics::class.java)
    // What I want
    val log = loggerOf()

    View full-size slide

  127. @ToddGinsberg
    Reified Generics
    // Thanks type erasure :(
    fun loggerOf(): Logger =
    Logger.getLogger(T::class.java)

    View full-size slide

  128. @ToddGinsberg
    Reified Generics
    inline fun loggerOf(): Logger =
    Logger.getLogger(T::class.java)

    View full-size slide

  129. @ToddGinsberg
    Reified Generics
    inline fun loggerOf(): Logger =
    Logger.getLogger(T::class.java)
    // Works!
    val log = loggerOf()

    View full-size slide

  130. @ToddGinsberg
    Summary

    View full-size slide

  131. @ToddGinsberg
    Make “Bad” Choices Explicit or Impossible
    Fixed in Kotlin:
    -Singleton support built in
    -Override keyword mandatory
    -Properties over fields with getter/setter
    -Mutability is minimized (val + collections)
    -Inheritance prohibited by default
    -Builders are easy with default values
    -No checked exceptions
    -Structural equality is the same everywhere
    -Delegation support makes composition easier

    View full-size slide

  132. @ToddGinsberg
    Fun == Fun

    View full-size slide

  133. @ToddGinsberg
    Fun == Fun
    Kotlin

    View full-size slide

  134. @ToddGinsberg
    Want to Learn More?
    https://play.kotlinlang.org

    View full-size slide

  135. @ToddGinsberg
    Why Do I Use Kotlin?
    ● I write far less code.

    View full-size slide

  136. @ToddGinsberg
    Why Do I Use Kotlin?
    ● I write far less code.
    ● The code I write is more expressive and clear.

    View full-size slide

  137. @ToddGinsberg
    Why Do I Use Kotlin?
    ● I write far less code.
    ● The code I write is more expressive and clear.
    ● I avoid whole classes of defects.

    View full-size slide

  138. @ToddGinsberg
    Why Do I Use Kotlin?
    ● I write far less code.
    ● The code I write is more expressive and clear.
    ● I avoid whole classes of defects.
    ● Allows me to write in a more functional style.

    View full-size slide

  139. @ToddGinsberg
    Why Do I Use Kotlin?
    ● I write far less code.
    ● The code I write is more expressive and clear.
    ● I avoid whole classes of defects.
    ● Allows me to write in a more functional style.
    ● Plays well with the tools I use (Spring, IDEA, Gradle)

    View full-size slide

  140. @ToddGinsberg
    Why Do I Use Kotlin?
    ● I write far less code.
    ● The code I write is more expressive and clear.
    ● I avoid whole classes of defects.
    ● Allows me to write in a more functional style.
    ● Plays well with the tools I use (Spring, IDEA, Gradle)
    ● Writing Kotlin, for me, is more fun.

    View full-size slide

  141. #springone
    @s1p
    @ToddGinsberg
    [email protected]
    https://todd.ginsberg.com
    http://bit.ly/DevSpace2019-Kotlin
    Thank You!

    View full-size slide