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

Kotlin 2021 Recap / DevFest 2021

80a3a3857a55f154d23acb705eff72cc?s=47 star_zero
December 11, 2021

Kotlin 2021 Recap / DevFest 2021

80a3a3857a55f154d23acb705eff72cc?s=128

star_zero

December 11, 2021
Tweet

Transcript

  1. Kotlin 2021 Recap Kenji Abe (@STAR_ZERO) Android, Kotlin GDE /

    DeNA Co., Ltd. [Tokyo]
  2. None
  3. None
  4. Kotlin 1.5

  5. value class UserId(val id: Int) val userId = UserId(1)

  6. // State.kt sealed interface State // Success.kt data class Success(val

    data: Data): State // Failure.kt data class Failure(val e: Exception): State
  7. val uint: UInt = 1u val ulong: ULong = 2u

    val ushort: UShort = 3u val ubyte: UByte = 4u
  8. val value = "..." value.toUpperCase() value.uppercase() value.toLowerCase() value.lowercase() value.capitalize() value.replaceFirstChar

    { it.uppercase() } value.decapitalize() value.replaceFirstChar { it.lowercase() }
  9. Coroutines 1.5

  10. None
  11. val channel = Channel<String>(...) channel.offer("...") // true or false or

    throw Exception channel.trySend("...") // ChannelResult channel.poll() // get or null channel.tryReceive() // ChannelResult
  12. Kotlin Symbol Processing

  13. Kotlin Symbol Processing 1. Kotlinの軽量コンパイラプラグイン開発ツール 2. KAPTのような機能 3. KAPTより高速 4.

    Kotlinのコードを直接解析 5. Multiple Platformのサポート
  14. Multiplatform

  15. Multiplatform 1. Compose multiplatform 1.0 2. KMM Beta (2022春予定) 3.

    New Kotlin/Native memory management
  16. Kotlin 1.6

  17. class Func : suspend (String) -> Result { override suspend

    fun invoke(s: String): Result { // ... } } val func: suspend (String) -> Result = Func() val result = func("test")
  18. annotation class Marker(val value: String) val marker = Marker("Sample")

  19. None
  20. // build.gradle kotlin { sourceSets.all { languageSettings { progressiveMode =

    true } } }
  21. None
  22. val sec = 10000.seconds println(sec.inWholeHours) // 2 println(sec.inWholeMinutes) // 166

    val duration = sec + 10.hours duration.toComponents { d, h, m, s, ns -> println("${d}d ${h}h ${m}m ${s}s") // => 0d 12h 46m 40s }
  23. val list = buildList { add("a") if (condition) { add("b")

    } add("c") } val map = buildMap { put("a", 1) } val set = buildSet { add("a") }
  24. Coroutines 1.6

  25. Coroutines 1.6 1. kotlinx-coroutines-test に様々な変更 2. CoroutineDispatcher.limitedParallelism の導入 3. Kotlin/Native

    new memory model をサポート
  26. K2 Compiler

  27. *.kt Frontend Native Backend LLVM bitcode generator IR JS Backend

    JVM Backend IR Generator *.so *.js *.class Syntax tree + Semantic info Before
  28. *.kt Frontend Native Backend LLVM bitcode generator IR JS IR

    Backend JavaScript generator IR JVM IR Backend JVM bytecode generator IR IR Generator *.so *.js *.class Syntax tree + Semantic info Now
  29. *.kt New Frontend Native Backend LLVM bitcode generator IR JS

    IR Backend JavaScript generator IR JVM IR Backend JVM bytecode generator IR IR Generator *.so *.js *.class FIR Goal
  30. Resources • Mascot ◦ https://blog.jetbrains.com/kotlin/2021/10/introducing-the-k otlin-mascot/ • Kotlin 1.5.x ◦

    https://kotlinlang.org/docs/whatsnew15.html ◦ https://kotlinlang.org/docs/whatsnew1520.html ◦ https://kotlinlang.org/docs/whatsnew1530.html • Kotlin 1.6 ◦ https://kotlinlang.org/docs/whatsnew16.html
  31. Resources • Coroutines ◦ https://blog.jetbrains.com/kotlin/2021/05/kotlin-coroutines -1-5-0-released/ ◦ https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1 .6.0-RC ◦

    https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1 .6.0-RC2 • Kotlin Symbol Processing ◦ https://github.com/google/ksp
  32. Resources • Multiple platform ◦ https://blog.jetbrains.com/kotlin/2021/10/compose-multiplat form-goes-beta/ ◦ https://blog.jetbrains.com/kotlin/2021/10/kmm-beta-roadmap- video-highlights/

    • K2 Compiler ◦ https://www.youtube.com/watch?v=iTdJJq_LyoY ◦ https://www.youtube.com/watch?v=db19VFLZqJM
  33. STAR_ZERO STAR-ZERO Thank you [Tokyo]