Kotlin 2021 Recap
Kenji Abe (@STAR_ZERO)
Android, Kotlin GDE / DeNA Co., Ltd.
[Tokyo]
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
Kotlin 1.5
Slide 5
Slide 5 text
value class UserId(val id: Int)
val userId = UserId(1)
Slide 6
Slide 6 text
// State.kt
sealed interface State
// Success.kt
data class Success(val data: Data): State
// Failure.kt
data class Failure(val e: Exception): State
Slide 7
Slide 7 text
val uint: UInt = 1u
val ulong: ULong = 2u
val ushort: UShort = 3u
val ubyte: UByte = 4u
Slide 8
Slide 8 text
val value = "..."
value.toUpperCase()
value.uppercase()
value.toLowerCase()
value.lowercase()
value.capitalize()
value.replaceFirstChar { it.uppercase() }
value.decapitalize()
value.replaceFirstChar { it.lowercase() }
Slide 9
Slide 9 text
Coroutines 1.5
Slide 10
Slide 10 text
No content
Slide 11
Slide 11 text
val channel = Channel(...)
channel.offer("...") // true or false or throw Exception
channel.trySend("...") // ChannelResult
channel.poll() // get or null
channel.tryReceive() // ChannelResult
class Func : suspend (String) -> Result {
override suspend fun invoke(s: String): Result {
// ...
}
}
val func: suspend (String) -> Result = Func()
val result = func("test")
Slide 18
Slide 18 text
annotation class Marker(val value: String)
val marker = Marker("Sample")
val list = buildList {
add("a")
if (condition) {
add("b")
}
add("c")
}
val map = buildMap {
put("a", 1)
}
val set = buildSet {
add("a")
}
Slide 24
Slide 24 text
Coroutines 1.6
Slide 25
Slide 25 text
Coroutines 1.6
1. kotlinx-coroutines-test に様々な変更
2. CoroutineDispatcher.limitedParallelism の導入
3. Kotlin/Native new memory model をサポート
Slide 26
Slide 26 text
K2 Compiler
Slide 27
Slide 27 text
*.kt
Frontend
Native Backend
LLVM bitcode
generator
IR
JS Backend
JVM Backend
IR Generator
*.so
*.js
*.class
Syntax tree +
Semantic info
Before
Slide 28
Slide 28 text
*.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
Slide 29
Slide 29 text
*.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