KotlinConf 2017
* Introduction to Coroutines *
https://resources.jetbrains.com/storage/products/kotlinconf2017/slides/2017+KotlinConf+-+Introduction+to+Coroutines.pdf
- Synchronous
- Asynchronous
-> Callback
- Futures/Promises/Rx
-> returns promise for a future result immediately
- Coroutines
-> suspend: returns result when received
-> like regular code
- Coroutines are like very light-weight threads
http://github.com/kotlin/kotlinx-coroutines
* Deep Dive into Coroutines on JVM *
https://resources.jetbrains.com/storage/products/kotlinconf2017/slides/2017+KotlinConf+-+Deep+dive+into+Coroutines+on+JVM.pdf
- Continuation Passing Style(CPS)
-> Callback
- State Machine
- Communicating Sequential Processes(CSP)
* Kotlin Types: Exposed *
Int vs Int?
IntArray vs Array<Int>
Any vs Object
Boxing under the hood vs No boxing
Unit vs Nothing vs void
Unit
-> a type that allows only one value and thus can hold no information
-> the function completes successfully
Nothing :
-> a type that has no values
-> It means "this function never returns"
- Unit과 Nothing은 Kotlin에서 위와 같은 차이가 있지만 JVM에서 똑같이 void로 컴파일된다.
Nothing?
@Nullable -> Type? and @NotNull(@NonNull) -> Type
How to still prevent NPEs? - 자바 코드를 코틀린에서 사용하는 경우 문제가 발생
-> Annotate your Java types
compileKotlin {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
}
}
-> Specify types explicitly
Collections
-> Read-only : it is not immutable
-> Mutable
* Generating Kotlin Code *
KotlinPoet
A Functional Approach to Android Architecture using Kotlin
- Modeling Error and Success Cases
-- Result wrapper(Error or Success)
-- RxJava
-- KATEGORY
- Asynchronous Code and Threading
-- Java : ThreadPoolExecutor + exceptions + callbacks
-- RxJava : Schedulers + observable + error subscription
-- KATEGORY
Lazy evaluation
- Dependency Injection
-- Reader Monad: ReaderT, Monad Transformers
Exploring Kotlin's hidden costs - Part 1
Coroutine Theory
- Normal function
Call/Return
activation frame(stack)
- Coroutine
Suspend/Resume/Destroy
coroutine frame(heap) and stack frame
Kotlin Coroutines on Android: Things Wish I Knew at the Beginning
- Executor를 CoroutineDispatchers로 바꿀 수 있다.
- RxJava의 disposable 같은 것을 위해 "root" coroutine parent를 사용할 수 있다.
- CommonPool 의 크기를 조절할 수 있다.
- Async에서의 exception은 바로 발생되지 않는다.
- coroutine들을 협력적으로 cancel 하려면 CoroutineContext를 통한 parent-child 관계가 필요하다.
Async code using Kotlin Coroutines
RxJava to Kotlin coroutines
코루틴과 관련해서 Continuation에 대해서도 알면 좋을것 같다.
What's in a Continuation
Implementing a Stepping Debugger in JavaScript
Exploring Continuations: Resumable Exceptions
댓글 없음:
댓글 쓰기