Asynchrony Is Not Concurrency
10 months ago
- #Zig
- #concurrency
- #asynchrony
- The blog post distinguishes between asynchrony, concurrency, and parallelism, providing clear definitions for each.
- Asynchrony is defined as the possibility for tasks to run out of order and still be correct, while concurrency is the ability of a system to progress multiple tasks at a time, and parallelism is the ability to execute more than one task simultaneously at the physical level.
- The post highlights the confusion in common programming lingo where 'concurrency' is often used to describe both asynchrony and concurrency, leading to a lack of understanding and suboptimal software ecosystems.
- Zig's approach to async I/O is highlighted, where asynchrony does not imply concurrency, allowing synchronous and asynchronous code to coexist without requiring code duplication or forcing users into async-only models.
- The post introduces `io.async` and `io.asyncConcurrent` in Zig, explaining how they handle asynchrony and concurrency differently, with `io.asyncConcurrent` ensuring tasks run concurrently when required.
- The author emphasizes the benefits of separating asynchrony from concurrency, such as avoiding library duplication, improving user experience, and preventing deadlocks.
- A live demonstration is promised to showcase Zig's async I/O redesign, including implementations of thread pools, green threads, and non-concurrent Io.