KotlinConf 2017 - Introduction to Coroutines by Roman Elizarov

  Рет қаралды 126,262

JetBrains

JetBrains

Күн бұрын

Пікірлер: 70
@igorg.8624
@igorg.8624 7 жыл бұрын
This is definitely a well-polished talk. It made Coroutines easy to understand, and the speaker is obviously well versed.
@ZelenoJabko
@ZelenoJabko 3 жыл бұрын
Well Polish-ed talk
@drakekason3928
@drakekason3928 3 жыл бұрын
InstaBlaster.
@zhou7yuan
@zhou7yuan 5 жыл бұрын
Asynchronous programming [0:50] A toy problem [1:48] token -> post -> process Threads [2:54] (how many threads we can have?) Callbacks to the rescue (sort of...) [4:23] Callbacks: before [4:34] Callbacks: after [5:11] (aka "callback hell". exceptions is a mess...) Futures/Promises/Rx to the rescue (sort of...) [6:25] Futures: before & after [6:51] Futures: after (3) [7.33] (but all those combinators...) Kotlin coroutines to the rescue [9:03] Coroutines: before [9:12] Coroutines: after [10:09] Bonus features [11:18] (Regular loops, exception handing, higher-order functions) (Everything like in blocking code) Suspending functions [12:44] Retrofit async [13:04] Composition (beyond sequential) [14:43] Higher-order functions [15:31] (retryIO{}) (suspend fun retryIO(block: suspend() -> T): T{}) Coroutine builders [16:57] Coroutines revisited [17:06] launch (coroutine builder) [18:13] (Fire and forget!) UI Context [19:22] Where's the magic of launch? [19:55] async/await [21:07] Kotlin-way [21:34] Classic-way [21:41] (async/await) (C#, Python, TS, Dart, coming to JS) (C#) (returns a future) Why no await keyword in Kotlin? [23:01] The problem with async (default async without `await` calling) Kotlin suspending functions are designed to imitate sequential behavior by default [24:53] (Concurrency is hard, has to be explicit) Kotlin approach to async (Concurrency where you need it) [25:28] Use-case for async [25:44] Kotlin async function [26:40] (Deferred - Kotlin's future type) (async coroutine builder) (await function) Using async function when needed [29:10] (suspend fun l(); async{ l() }) Kotlin approach to async [30:08] Coroutines [30:48] What are coroutines conceptually? [31:14] (very light-weight threads) Example [31:33] (runBlocking{} runs coroutine in the context of invoker thread) Demo [33:16] (Example with thread) [34:06] (Demo with thread) [34:50] (OutOfMemoryError) Java interop[35:54] (future{} coroutine builder) [37:33] (future1.await() - Extension for Java's CompletableFuture) Beyond asynchronous code [38:14] Fibonacci sequence [38:31] (buildSequence{} yield()) (Coroutine is restricted only to suspending functions defined here) Synchronous [40:07] (Synchronous with invoker) Library vs Language [41:24] Classic async [41:37] Kotlin coroutines [41:54] Experimental status [42:41]
@Ab-no6rz
@Ab-no6rz 3 жыл бұрын
God bless you
@ravindraverma8413
@ravindraverma8413 3 жыл бұрын
Thanks Bro
@harshagarwal00
@harshagarwal00 Жыл бұрын
you are god sent!
@alexsmart2612
@alexsmart2612 Ай бұрын
38:31 It's amazing to witness the moment when every single programming community in the world discovers Monads. This was the moment for the JVM community. Congrats!
@dansadventures5514
@dansadventures5514 7 жыл бұрын
This was one of the best videos I've seen on coroutines as it really helped me get a sense for how I would use them in practice. Thank you!
@methodsignature
@methodsignature 6 жыл бұрын
Excellent! This is exactly the talk I wanted. The what, the why, and the promise presented in a thoughtful and concise fashion.
@AlexGLuque
@AlexGLuque 6 жыл бұрын
Thank you for posting this talk. It's the best initial approach I've seen so far after some weeks of reading about the coroutines. Great speaker for a great language!
@vipullal7689
@vipullal7689 4 жыл бұрын
Another brilliant and comprehensive talk. I now understand coroutines. Thanks a ton!
@JetBrainsTV
@JetBrainsTV 4 жыл бұрын
You're very welcome!
@alekseimulin6151
@alekseimulin6151 6 жыл бұрын
Jet Brains guys, you're great, I think it's a breakthrough and a way cooler concept than anything else at the moment.
@carrefamily01
@carrefamily01 6 жыл бұрын
Great presentation and a even greater product by Jetbrains! Kudos to the kotlin team! Can't wait to use coroutines in my project.
@ChrisAthanas
@ChrisAthanas 5 жыл бұрын
Excellent presentation by an obvious master of his craft
@sleepydev4700
@sleepydev4700 4 жыл бұрын
I've seen other tutorials but this is the best explanation of them
@MarcusWolschon
@MarcusWolschon 7 жыл бұрын
Next time: repeat the questions into a microphone!
@centurieswisdom
@centurieswisdom 7 жыл бұрын
Please, fix the volume of the intro music and the volume of record itself!
@guptaanmol184
@guptaanmol184 3 жыл бұрын
Wow, way to go kotlin with saner defaults! Amazing work! ~ from a C# dev using async await :)
@Rjbcc
@Rjbcc 6 жыл бұрын
I must be missing something very basic here but what is the point of making the first example asynchronous? If we need to create a `Post` before we can process it, and we need to create a `Token` before we can create a `Post`, isn't this a set of synchronous operations? What will actually be done asynchronously? Are we saying we want the entire operation of create/post/process to be async while the app does something else?
@GooksanGom
@GooksanGom 4 жыл бұрын
UI interactions I think
@Rjbcc
@Rjbcc Жыл бұрын
Back to answer my own question 4 years later. Yes the Post example consists of sequential operations that are not executed concurrently, the whole operation can be launched asynchronously inside of a coroutine, and not be thread bound at any IO suspension point. The async part is the whole operation, and the suspending operations allow us to free up threads to do other work instead of blocking on network IO.
@saurabh75prakash
@saurabh75prakash 4 жыл бұрын
This is exactly what I was looking for. Thanks!
@ColinTheShots
@ColinTheShots 7 жыл бұрын
Will the slides be shared? Thanks!
@JetBrainsTV
@JetBrainsTV 7 жыл бұрын
www.slideshare.net/elizarov/introduction-to-coroutines-kotlinconf-2017
@ColinTheShots
@ColinTheShots 7 жыл бұрын
Thanks!
@CarlitoProductions
@CarlitoProductions 7 жыл бұрын
Can you use a coroutine by not passing any arguments, and doing a while loop inside of the suspended coroutine (for example a person messes their information up during a prompt and needs to reset, so the while loop continues until they press yes)?
@pedrod.8839
@pedrod.8839 6 жыл бұрын
Where can I find the talk where he shows how coroutines are compiled in the JVM?
@JetBrainsTV
@JetBrainsTV 6 жыл бұрын
Is this the one you are looking for? kzbin.info/www/bejne/j6PVhnaJnpxle5o
@rckd5903
@rckd5903 6 жыл бұрын
wow, kotlin has async/await too :-D
@xpopcornx1747
@xpopcornx1747 5 жыл бұрын
C# is much more clear. When you call an async function you use await, in kotlin there is no difference between how you call a suspend function and non suspend function so there is no way of telling what the code does, you have to manually go to each function and check if it is a suspend function to know that it is waiting for something.
@MartinNordholts
@MartinNordholts 5 жыл бұрын
XPopCornX This is touched upon in the talk. The solution is to have the IDE mark suspend calls in the left gutter on a line by line basis.
@md.tahmidmozaffar9135
@md.tahmidmozaffar9135 4 жыл бұрын
Very good presentation.
@yakiv1488
@yakiv1488 3 жыл бұрын
Thanks a lot. That's a really good talk!
@TheWitzig
@TheWitzig 7 жыл бұрын
Such a great video! Thank you! :-)
@lloydryandavid7820
@lloydryandavid7820 5 жыл бұрын
Very well explained. Thanks for the video! 👍
@kdbrian.d3v
@kdbrian.d3v 8 ай бұрын
i watched this 6 years later and if am being real its worth 1000 videos. Really laid the basis of coroutines.
@tahirraza2590
@tahirraza2590 Жыл бұрын
A bit old but still related and on-point. Really liked the way he presented the whole thing as a story. The what, they why and the how.
@robchr
@robchr 7 жыл бұрын
So coroutines are just monads where suspend functions are Kleisli arrows, '=' is 'flatMap' and 'await' is 'pure'. Got it ;-)
@methodsignature
@methodsignature 6 жыл бұрын
Us functional casuals needed all the other words in between.
@kc2815
@kc2815 7 жыл бұрын
Wait wait wait... So in the code where he has the two calls to loadImageAsync() and then calls await on the two deferred objects one after the other, is that really asynchronous? Wouldn't the first call suspend until it was completed and then call the second one? Or does the loading happen when the function is invoked and then the await call only makes sure the call completes before moving to the next line?
@henninghoefer
@henninghoefer 6 жыл бұрын
Kevin Colin Both images are loaded asynchronously at virtually the same time, only the await() are blocking and ensure both images are there before combining them.
@crazieeez
@crazieeez 6 жыл бұрын
When you are confuse, the programming language is garbage. Coroutine is garbage.
@АлександрКарачёв-я3э
@АлександрКарачёв-я3э 6 жыл бұрын
so RX Java is garbage too, because everyone is confused firstly)
@AntonDerevyanko
@AntonDerevyanko 6 жыл бұрын
Thanks for clear and understandable talk.
@BradMcHelm
@BradMcHelm 7 жыл бұрын
please check out the flashing icons, giving me epilepsy
@unrealspetznaz
@unrealspetznaz 4 жыл бұрын
really helpful
@mayureshgharat1600
@mayureshgharat1600 2 жыл бұрын
I am wondering how is the launch function at 20:41 different the previous retryIO function. Why does retryIO need to be a suspend function?
@vulnerable_content
@vulnerable_content 3 жыл бұрын
Thank you!
@a0um
@a0um 6 жыл бұрын
I've struggled to hear the speaker even maxing out my phone volume. I found the example contrived: what's the point of making those functions async? I agree the "suspend" keyword isn't the one I would have expected. This is my first exposure to coroutines and I'm gonna leave half way. Still exited about Kotlin though, and I'll be looking for other introductions to coroutines.
@abunapha
@abunapha 5 жыл бұрын
The generated subtitles are hilarious
@JetBrainsTV
@JetBrainsTV 5 жыл бұрын
Any examples to make us smile?
@abunapha
@abunapha 5 жыл бұрын
@@JetBrainsTV 19:24 "lunch curtain builder" Also Kotlin is always "catalan"
@JetBrainsTV
@JetBrainsTV 5 жыл бұрын
@@abunapha "lunch curtain builder" - That's hilarious!
@hagbardceline9866
@hagbardceline9866 6 жыл бұрын
Interesting talk! But i don't really see the improvement from the first - rightfully - criticized approach of having "to many" combinators to "remember" in the promise/future/Rx case when in fact i have the same thing with the so called coroutine builders. This is not really compelling, at least the talk does not make it clear to me why i should trade like 3 combinators with 3 coroutine builders ( i oversimplified this here )
@vangrails
@vangrails 6 жыл бұрын
Maybe the handling of exceptions is easier?
@SpectatorAlius
@SpectatorAlius 3 жыл бұрын
He keeps pronouncing 'coroutine' as 'car routine' -- and I finally guessed why! He must have learned Russian in Moscow or somewhere else nearby with a pronounced акане accent!
@dnkilic
@dnkilic 4 жыл бұрын
More recent one is here; kzbin.info/www/bejne/npOTmZl-i7x2iZI
@typingcat
@typingcat 3 жыл бұрын
Stop starting a lecture video with a useless loud long music sequence.l
@garywzh
@garywzh 7 жыл бұрын
great talk
@miracledoh4020
@miracledoh4020 4 жыл бұрын
comparing coroutine with Thread is pointless, coroutine's java equivalent should be Executor
@kemuri22
@kemuri22 6 жыл бұрын
kinda like apple's gcd
@ybtoo7
@ybtoo7 3 жыл бұрын
Everything is good except for speakers English accent. Its been tough to follow here and there due to lack of clean pronunciation, but can figure out of the context. Should have provided properly generatedsubtitles. Except this rest is wonderful.
@StefanReich
@StefanReich 6 жыл бұрын
Yeah it's a good idea (coroutines). I also started adding them to Java at some point... didn't complete the project yet, but it may be to come. dzone.com/articles/java-can-have-coroutines
@aprofromuk
@aprofromuk 6 жыл бұрын
cheesiest crapiest startest music ever :)
@crazieeez
@crazieeez 6 жыл бұрын
coroutines look like garbage. the syntax is incredibly complicated to try to simplify async operation. Get your naming right and stop with a bunch of non alphabet characters to confuse people. The explanation given in this video is garbage. Author tries to use adjective to express how kotlin coroutines are better than async/await and how much simpler ... I don't buy it. suspend is a dumb name to give to a function for async operation ... suspend means don't run the function.
@rckd5903
@rckd5903 6 жыл бұрын
crazieeez exactly what i thought 😂
@valour.se47
@valour.se47 6 жыл бұрын
Easy man 👨
@davidkerr7
@davidkerr7 6 жыл бұрын
I think it because JavaScript already has Async and wait keywords
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Kotlin Coroutines 101 - Android Conference Talks
24:49
Android Developers
Рет қаралды 138 М.
Event-Driven Architecture (EDA) vs Request/Response (RR)
12:00
Confluent
Рет қаралды 179 М.
Roman Elizarov - Structured concurrency
1:00:01
Hydra
Рет қаралды 26 М.
Building Real-time Apps with Go | Azim Pulat
54:58
Azim Pulat
Рет қаралды 86 М.
Coroutines and Loom behind the scenes by Roman Elizarov
45:22
Kotlin by JetBrains
Рет қаралды 34 М.
10 Kotlin Tricks in 10 ish minutes by Jake Wharton
17:24
Devoxx
Рет қаралды 68 М.
The standard library now has all you need for advanced routing in Go.
13:52
Coroutines: Concurrency in Kotlin
30:22
Dave Leeds
Рет қаралды 20 М.