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

Kotlin 2021 Recap / DevFest 2021

star_zero
December 11, 2021

Kotlin 2021 Recap / DevFest 2021

star_zero

December 11, 2021
Tweet

More Decks by star_zero

Other Decks in Programming

Transcript

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

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

    val ushort: UShort = 3u val ubyte: UByte = 4u
  3. val channel = Channel<String>(...) channel.offer("...") // true or false or

    throw Exception channel.trySend("...") // ChannelResult channel.poll() // get or null channel.tryReceive() // ChannelResult
  4. class Func : suspend (String) -> Result { override suspend

    fun invoke(s: String): Result { // ... } } val func: suspend (String) -> Result = Func() val result = func("test")
  5. 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 }
  6. val list = buildList { add("a") if (condition) { add("b")

    } add("c") } val map = buildMap { put("a", 1) } val set = buildSet { add("a") }
  7. *.kt Frontend Native Backend LLVM bitcode generator IR JS Backend

    JVM Backend IR Generator *.so *.js *.class Syntax tree + Semantic info Before
  8. *.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
  9. *.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
  10. 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
  11. 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