2 ms·
async took off when multicore processors came out and C had no first class way of running in parallel, so we bolted on threading libraries that are second class
by jackhalford 3y ago
async took off when multicore processors came out and C had no first class way of running in parallel, so we bolted on threading libraries that are second class. Take a look at zig’s approach to concurrency, it’s so first class you can write your own event loop without an OS, i.e you could use the language’s async to write an OS.
- Sharlin 3y agoAsync doesn’t really have much to do with multicore. Indeed the most used async environment on the planet (JavaScript) is (used to be) strictly single-threaded. Async is all about keeping the CPU busy even though the stuff it does involves latencies thousands or millions of times longer than CPU timescales – and about abstractions that allow you to pretend you’re writing normal synchronous code when the reality is anything but. This mostly just involves chopping up the code and turning it into a state machine. Async is almost useless when you’re not incredibly I/O bound. But many people these days are because the web ate the world. C did and does have a poor almost-anything story but it doesn’t and didn’t really matter because C hasn’t been relevant on the web since 1995 or so.
- jcranmer 3y ago> Async is almost useless when you’re not incredibly I/O bound. I'm not sure that's true. The async/await model is about representing a state machine in imperative code. Not all state machines can be written imperatively, but when they can be, it is often clearer than writing the state machine manually. I/O is the most common scenario for such state machines, but I can see a few other OS scenarios where you might want to use async/await instead (e.g., process management is probably better represented with async/await).
- jackhalford 3y ago> async doesn’t have much to do with mumticore It does, once you have async you can multiplex n coroutines on m cpu cores, meaning you can throw libthread out of the window. > C hasn’t been relevant on the web since 1995 Do you know nginx, a core web technology is written in C? Linux is also C. Don’t forget that at the end ov every web request are syscalls and hardware.