</>CodexBash
All articles
Programming

Async and await

What async and await mean across languages: the problem of waiting, callbacks and futures, how await suspends a function without blocking a thread, the same example in JavaScript, Python, C# and Kotlin, running work concurrently, error handling, and the mistakes that make async code slow or broken.

CodexBash, , 5 min read

Most programs spend much of their time waiting: for a database, a web API, a file, a timer. If waiting blocks the only thread, nothing else can happen; if every wait gets its own thread, memory runs out at a few thousand concurrent operations. Async and await is the language feature, now found in JavaScript, Python, C#, Rust, Kotlin (as suspend functions), Swift and more, that lets you write code which waits efficiently while still reading top to bottom like ordinary code. This article explains the idea once, then shows how it looks in several languages.

Sign in to read the rest

The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.