Modeling Data Concurrency w/ Asynchronous I/O in Zig - RedisConf 2020

Channel:Redis · Length:49:19 · Published:2020-06-18 · Views:10936

Watch on YouTube

Summary

Zig creator Andrew Kelley's RedisConf 2020 talk on modeling data flow with asynchronous I/O in Zig. It explains how Zig's async/await avoids function coloring, and Loris Cro demonstrates OkRedis, a zero-allocation Redis client.

Why HN recommends it

HN recommends it as the clearest explanation of how Zig achieves colorless async/await.

I highly recommend watching Andrew Kelley's video — HN, 2021

Programming language design · C, C++, Rust, Go & systems languages

Subtitles (excerpt)

hello there i am andrew kelly the creator of the zig programming language and i am here to talk to you today about how zig lets you express the inherent concurrency of the problems that you're trying to solve with code using async await uh let's jump right into it so what's async await it's uh besides buzzwords i'll tell you exactly what it is it's language level syntax that lets you start multiple operations at the same time and then selectively wait until some number of them are completed before continuing on with the data so if i were to sort of show it visually you can think of your software as a pipeline and you can think of each of these little shapes as little operations that you need to do in order to process data and then you're going to end up with your final result here represented by this scroll so in terms of redis for example any one of these little shapes could be a redis query uh or maybe it's you know a different database query or maybe it's a external api fetch or maybe its recon configuration file or maybe it's using a third-party api point is this is basically what every uh what all software is doing some form of this you know the arrows are just the little processing in between and then you end up with your result so this is the way i like

On Hacker News

I really can't agree with this premise after seeing how Zig implements color-less async/await: [LINK] I highly recommend watching Andrew Kelley's video (linked in that article) on this topic: [VIDEO] — kbd, 2021-04
I recently wrote an IO abstraction over io_uring using Zig's async/await. Here's how you would do a write()/fsync()/read() with this ( [LINK] ): const offset: u64 = 0; const bytes_written = try io.write(fd, buffer_write[0..], offset); try io.fsync(fd); const bytes_read = try io.read(fd, buffer_read[0..], offset); Other sync functions can use this asynchronous IO completion code in a synchronous s… — jorangreef, 2021-02
There is an interesting approach in Zig to explicitly kick call frames to achieve colorless asyncness. [VIDEO] — bvrmn, 2020-05
> Code that's meant to be pinned (and may behave incorrectly if not pinned) looks no different from any other code. Same goes for async/await. The decision to keep you running on the same native thread is up to the scheduler. > Java isn't positioned as a high-level, high-abstraction language and that's not, IME, the user community it has. I beg to differ. It aims to be a good compromise between p… — pron, 2020-05

Related videos