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

Kotlin: The "New" Kid On The Block!

Kotlin: The "New" Kid On The Block!

This talk was held on the Mobile track of The Developer Conference São Paulo 2017, which happened on July 20th. The talk was an introduction to the Kotlin language, with steps about how to start to use it, which companies are using and what are the most benefits of using it on Android, backend, game development and such!

More details about the event: www.thedevelopersconference.com.br/tdc/2017/saopaulo/trilha-mobile

Walmyr Carvalho

July 20, 2017
Tweet

More Decks by Walmyr Carvalho

Other Decks in Technology

Transcript

  1. Walmyr Carvalho
    #TrilhaMobile
    #TheDevConf
    Kotlin:
    The “New" Kid On The Block

    View full-size slide

  2. Walmyr Carvalho
    @walmyrcarvalho

    View full-size slide

  3. Kotlin! Por que esse buzz todo?

    View full-size slide

  4. • Criada pela JetBrains
    • Open source <3
    • Compila para JVM e JS
    • Null safety
    • Suporta OO e FP (kinda)

    View full-size slide

  5. Kotlin na 99

    View full-size slide

  6. Usamos Kotlin em produção
    há mais de um ano
    em dois projetos Android:

    View full-size slide

  7. Somos 7 desenvolvedores Android,
    com experiências distintas,
    trabalhando com Kotlin diariamente.

    View full-size slide

  8. Quem mais tá usando?

    View full-size slide

  9. A oficialização da linguagem pelo Google é só um reflexo
    de uma vontade que a comunidade já tinha há muito tempo.

    View full-size slide

  10. Onde eu posso usar Kotlin?

    View full-size slide

  11. Kotlin and Android - Android Developers
    goo.gl/JzeMwI

    View full-size slide

  12. Introducing Kotlin support in Spring Framework 5.0
    goo.gl/6t2qsE

    View full-size slide

  13. Kotlin/Native Tech Preview - Kotlin Without a VM
    goo.gl/kUe7d7

    View full-size slide

  14. TL;DR: Se você hoje trabalha com JVM,
    seja no Android, backend ou em jogos,
    muito provavelmente você pode usar Kotlin

    View full-size slide

  15. Overview da linguagem

    View full-size slide

  16. fun sum(a: Int, b: Int): Int {
    return a + b
    }

    View full-size slide

  17. fun sum(a: Int, b: Int) = a + b

    View full-size slide

  18. val a: Int = 1 // valor associado e tipagem definida
    val b = 2 // Tipo `Int` inferido
    val c: Int // Tipo é requerido
    c = 3

    View full-size slide

  19. var x = 5 // `Int` é inferido
    x += 1

    View full-size slide

  20. String templates

    View full-size slide

  21. var a = 1
    // nome simples no template:
    val s1 = "a is $a"
    a = 2
    // expressão arbitrária template:
    val s2 = "${s1.replace("is", "was")}, but now is $a"

    View full-size slide

  22. Condicionais

    View full-size slide

  23. fun maxOf(a: Int, b: Int): Int {
    if (a > b) {
    return a
    } else {
    return b
    }
    }

    View full-size slide

  24. fun maxOf(a: Int, b: Int) = if (a > b) a else b

    View full-size slide

  25. val items = listOf("apple", "banana", "kiwi")
    for (item in items) {
    println(item)
    }

    View full-size slide

  26. val items = listOf("apple", "banana", "kiwi")
    for (index in items.indices) {
    println("item at $index is ${items[index]}")
    }

    View full-size slide

  27. val items = listOf("apple", "banana", "kiwi")
    var index = 0
    while (index < items.size) {
    println("item at $index is ${items[index]}")
    index++
    }

    View full-size slide

  28. fun describe(obj: Any): String =
    when (obj) {
    1 -> "One"
    "Hello" -> "Greeting"
    is Long -> "Long"
    !is String -> "Not a string"
    else -> "Unknown"
    }

    View full-size slide

  29. when {
    "orange" in items -> println("juicy")
    "apple" in items -> println("apple is fine too")
    }

    View full-size slide

  30. Nulabilidade

    View full-size slide

  31. var a: String = "abc"
    a = null // erro de compilação

    View full-size slide

  32. var b: String? = "abc"
    b = null // ok

    View full-size slide

  33. Elvis operator

    View full-size slide

  34. // Como melhorar esse código?
    val l: Int = if (b != null) b.length else -1

    View full-size slide

  35. // yay! <3
    val l = b?.length ?: -1

    View full-size slide

  36. Legal, bora ver mais?

    View full-size slide

  37. Considerações finais

    View full-size slide

  38. Links úteis

    View full-size slide

  39. Kotlin - Página Oficial
    kotlinlang.org

    View full-size slide

  40. Kotlin Meetup São Paulo
    meetup.com/kotlin-meetup-sp

    View full-size slide

  41. Talking Kotlin - Podcast
    talkingkotlin.com

    View full-size slide

  42. Kotlin Conf 2017
    kotlinconf.com

    View full-size slide

  43. Kotlin - Android Developers
    developer.android.com/kotlin

    View full-size slide

  44. Android Dev BR - Slack
    slack.androiddevbr.org

    View full-size slide

  45. Temos muitas vagas!
    carreiras.99taxis.com

    View full-size slide

  46. Kotlin is Awesome
    kotlin.link
    Swift is like Kotlin
    nilhcem.com/swift-is-like-kotlin/

    View full-size slide

  47. Muito obrigado!
    Walmyr Carvalho
    @walmyrcarvalho

    View full-size slide

  48. Fonte das imagens e conteúdo utilizado:
    developer.android.com/kotlin
    twitter.com/kotlin
    kotlinlang.org
    kotlinconf.com
    blog.jetbrains.com

    View full-size slide