Skip to content
0:00 / 0:00

#coroutines#kotlin#asynchronous

KotlinConf 2017 - Introduction to Coroutines by Roman Elizarov

JetBrains

236K subscribers • 29 videos on Hallway

YouTube
  • Recommended by 6 people: 6 in engineering communities.
  • Presented by Roman Elizarov
  • Made by the vendor. The company whose product it covers made or sponsored it.

Intermediate. Assumes working knowledge.

133K views8 years ago6 recommendations

Programming languagesSystems programmingKotlinConcurrency and parallelism

Roman Elizarov introduces Kotlin coroutines, explaining how they simplify asynchronous programming compared to threads and callbacks.

We live in an asynchronous era of concurrency. Modern front-end and mobile applications provide real-time feedback and communication, server-side applications and services handle thousands of online users while integrating dozens of micro-services. Old-school monolithic applications with thread-based concurrency are going out of fashion, and asynchronous styles of programming with callbacks, futures, reactive streams and coroutines are gaining popularity. Kotlin is a modern and pragmatic JVM language that is developed by JetBrains with a strong emphasis on Java interoperability. Due to its strong Java interop, any Java asynchronous library can be used in Kotlin. You can even use JVM-based byte-code-instrumenting coroutine implementations like Quasar and JavaFlow. So, why has Kotlin introduced coroutines as a first-class language feature and how are Kotlin coroutines different from the generate/yield and async/await coroutines in C#, Python, JS and other languages? What makes using coroutines in Kotlin different from using threads? This talk answers those questions and gives a gentle introduction to the world of Kotlin coroutines with live examples. You'll learn how to launch and wait for coroutine completion, what are Kotlin suspending functions and how to wrap your favorite asynchronous library into them, turning your asynchronous "callback hell" into an easy-to-read synchronous-like code. You'll see how you can write scalable applications with Kotlin coroutines to handle lots of concurrent actions (connections, users, conversations, animations, etc.) at once. Roman Elizarov is a professional software developer with more than 16 years experience. He started his career at Devexperts, where he designed and developed high-performance trading software for leading brokerage firms and market data delivery services that routinely handle millions of events per second. He is an expert in Java and JVM, particularly in real-time data processing, algorithms and performance optimizations for modern architectures. Roman currently works on the Kotlin language at JetBrains. Having worked on very large systems comprising of many modules written in different languages, he has a dream of a single language that can be used to write all parts of a very large distributed system, to share and reuse data models and algorithms without friction. Kotlin with JVM and JS backends and the upcoming native compiler is the ideal candidate to realize this dream. In 2000 Roman had graduated from St. Petersburg ITMO. He now teaches a course on concurrent and distributed programming in ITMO. During his undergraduate study, he participated at ACM International Collegiate Programming Contest (ICPC). Since 1997 and until now Roman serves as a Chief Judge of Northeastern European Regional Programming Contest (NEERC) of ACM ICPC.

Why it's here

6 people recommend this

What people say. Highly recommended as the definitive introduction to understanding how Kotlin coroutines work under the hood.

u/sex_and_cannabisin r/Kotlin • Recommends

On “Trying to understand Coroutines”

This is the answer: link to this video JetBrains guy who clearly helped define the feature stepping you through threads -> async -> promises -> co-routines. It's an awesome vidoe.

u/emanguyin r/Kotlin • Recommends

On “Learning by doing; wrote a yelp API client to dive head first into Kotlin”

Looks good so far! I'd recommend checking out the Fuel HTTP library for future work on this as well as changing your async code from using CompletableFuture to using Kotlin Coroutines since they write so similarly to blocking code. Here are links to resources for these libraries: * Fuel: https://github.com/kittinunf/Fuel * Kotlin Coroutines library on GitHub: https://github.com/Kotlin/kotlinx.coroutines * Coroutines walkthrough from that GitHub: https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md * Coroutines talk from KotlinConf 2017 (this one just talks about how Coroutines compare to other async libraries): link to this video

u/aqutirin r/Kotlin • Recommends

On “Learning Kotlin Coroutines”

Try going through coroutines proposal https://github.com/Kotlin/KEEP/blob/master/proposals/coroutines.md iit also contain a handful of useful links at the end, including introduction here -> link to this video

u/spork_kingin r/Kotlin • Recommends

On “Best resources on kotlin coroutines?”

I use the coroutines guide quite a bit and find that really helpful. Roman Elizarov (coroutines project lead) gave two talks at KotlinConf 2017 on coroutines. Spend 2 hours to watch these and you'll have a better understanding of what they do and how they work under the covers. I thought I understood them before attending these sessions, and I really learned a lot. Totally changed my understanding. * Part 1: Introduction to Coroutines. * Part 2: Deep Dives into Coroutines on JVM. The #coroutines channel on Kotlin Slack is active and helpful. Project members and heavy users hang out there and provide useful advice when asked.

u/cuttersladein r/Kotlin • Recommends

On “If I execute 2 suspending functions, are they executed in parallel or one after the other ?”

As /u/hpernpeintner said, sequential, one after the other, just as it looks in your code. This presentation really cleared up a lot of the questions and misunderstandings I had about coroutines: [video

u/dstibbein r/Kotlin • Recommends

On “Learning Kotlin Coroutines”

Try this talk from Roman Elizarov: link to this video Edit: was supposed to be a reaction on the article.

u/runmarathonin r/scala • Mentions

What are your thoughts on Kotlin's Coroutine? What are your thoughts on Kotlin Coroutine to handle Future's callback hell? Instead of using an EitherT pattern to mitigate the problem, they opted to incorporate concurrency into the language with 'suspend'. Instead of : `def methodName(): FutureUnit` They keep the original method signature without higher kinds like so: `suspend def methodName(): Unit` This has advantages especially when refactoring over a large code base, but it isn't functional programming. I wonder what other Scala programmers think of this approach of baking in Futures in the language.

u/Rush_B_Blyatin r/Kotlin • Mentions

On “Google's "Android Basics with Compose"”

It sounds dumb, but treat Kotlin like a less verbose Java. There's some nice syntactic sugar that makes Kotlin so great, and there's a couple of new additions, like `?.let`, but those come in time. Kotlin's development was created, at the very least, alongside Android. A lot of the principles that are used in Android are now used in Kotlin Multiplatform, a device-agnostic framework. While I'd recommend using Google's course, they're not the most legible when it comes to documentation, nor the most up to date, ironically. Here's a list of resources you might find useful: * freeCodeCamp.org - Learn Kotlin Programming - Full Course for Beginners * [Roman Elizarov - Introduction to Corout…

u/redditsoaddictingin r/Kotlin • Mentions

On “Kotlin Coroutines vs C# async/await”

I found this talk goes over it well. Kotlin took a different approach to coroutines and the talk explains how.

u/Fiskepuddingin r/Kotlin • Mentions

On “Coroutine books or resources”

Under the hood: https://github.com/Kotlin/KEEP/blob/master/proposals/coroutines.md . For a more kind introduction, i like chapter 7 and 8 of https://www.amazon.com/Programming-Android-Kotlin-Structured-Concurrency/dp/1492063002 . Despite being an android book, those chapters are not android specific and give a good introduction. Other resources are all blog posts on medium by Roman Elizarov, and his Kotlinconf talks on coroutines. https://elizarov.medium.com/structured-concurrency-722d765aa952 link to this video There are many more by Roman, so just google his name and coroutines.

u/CheapError5327in r/Kotlin • Mentions

On “Coroutines without runBlocking”

[video was a really nice talk about coroutines, don't remember how outdated it is, but the concepts still are the same

u/sex_and_cannabisin r/Kotlin • Mentions

On “Some of my favourite Kotlin/Android libraries, and why I like them”

This is worth the 45 mins: link to this video JetBrains guy who clearly helped define the feature stepping you through threads -> async -> promises -> co-routines. It's an awesome video.

u/Dodging12in r/Kotlin • Mentions

On “Kotlin in Action Second Edition available for pre-order on Amazon”

I actually just realized I meant Martin Moskala when I was talking about the book . Roman has a couple of good talks on coroutines that I enjoyed though. link to this video link to this video There's also a playlist of all of his stuff: link to this video