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

Kotlin > 🏝 (Kotlin: more than an island)

Kotlin > 🏝 (Kotlin: more than an island)

2017-07-15: MobileOptimized 2017
2017-05-31: https://www.meetup.com/GDG-Berlin-Android/events/238173227

The last Google I/O was probably the most exciting ever, especially for one reason: Kotlin received official recognition as a first-class citizen on Android.
The quantity of developers cheering for this shouldn't come as a surprise, as some of them have already been using the language for years, and for good reasons.
Join us to understand what Kotlin really is, and witness how its principles and advanced features make it so unique today, plus what will make it transcend into something even more powerful in the future.

Animated slides (Keynote): https://goo.gl/QfQLdp

Fde10bcf0813b2162545477be4e7470b?s=128

Eugenio Marletti

May 31, 2017
Tweet

Transcript

  1. !

  2. ! “…Kotlin is a new JVM language…”

  3. ! “…Kotlin is a new JVM language…”

  4. ! “…Kotlin is a new JVM language…”

  5. None
  6. None
  7. made by JetBrains open source, non-profit foundation pragmatic safe(r than

    Java) “good” magic ✨ FUN
  8. packages optional no need to match folder files multiple classes

    top level functions
  9. // src/main/kotlin/covfefe/Whatever.kt fun main(args: Array<String>) { } println("Hello World!")

  10. fun main(args: Array<String>) { val immutable = 0 immutable +=

    1 }
  11. fun main(args: Array<String>) { var mutable = 0 mutable +=

    1 }
  12. fun main(args: Array<String>) { val nullable: String? = null val

    alternative = nullable ?: "¯\_(ϑ)_/¯" val lengthOrNull = nullable?.length if (nullable != null) { println(nullable.length) } } }
  13. fun Int.twice() = this * 2 fun test() = 1.twice()

    // 2
  14. inline fun <K, V> Map<K, V>.getOrElse( key: K, defaultValue: ()

    -> V ) = get(key) ?: defaultValue()
  15. abstract class NetworkResult { object Cancelled : NetworkResult() data class

    Success(val json: String) : NetworkResult() data class Error(val error: Throwable) : NetworkResult() } fun test(result : NetworkResult) = when (result) { NetworkResult.Cancelled -> null is NetworkResult.Success -> result.json is NetworkResult.Error -> throw result.error else -> error("WTF") }
  16. sealed object Cancelled : NetworkResult() data class Success(val json: String)

    : NetworkResult() data class Error(val error: Throwable) : NetworkResult() } fun test(result : NetworkResult) = when (result) { NetworkResult.Cancelled -> null is NetworkResult.Success -> result.json is NetworkResult.Error -> throw result.error class NetworkResult { }
  17. why?

  18. everything you can do in Kotlin can be done in

    Java
  19. everything you can do in Java can be done in

    bytecode
  20. high level abstractions, enforced by the compiler extend the language

    through DSL built in symbiosis with tools moving fast, but carefully change of mindset
  21. myths

  22. slow compilation runtime overhead learning curve not knowing what’s really

    going on confusing without IDE
  23. cons

  24. occasional rough edges around tooling not being able to go

    back to Java, ever
  25. future

  26. immutable collections universal serialization type classes multiplatform metaprogramming

  27. Official website goo.gl/xL99fk Kotlin and Android (blog) goo.gl/FQYAcW Introduction to

    Kotlin (video) goo.gl/3n6wic Life is Great and Everything Will Be Ok, Kotlin is Here (video) goo.gl/NTaYqi Using Project Kotlin for Android (doc) goo.gl/T0SDTJ The Future of Kotlin (video) goo.gl/INLPDl Kotlin 1.1 (video) goo.gl/iKojmn
  28. BIT .LY /KO TLIN -M O RE -TH A N

    -A N -ISLA N D Eugenio Marletti @workingkills