3 ms·
> “everything is sequential” abstraction is leaky, Can you explain what details leak? The sequential model was developed for programming because that's a natu
by starcraft2wol 3y ago
> “everything is sequential” abstraction is leaky,
Can you explain what details leak?
The sequential model was developed for programming because that's a natural way to reason about proccesses. `if then else`. `do this, then do that. The "async/await" designers seem to agree, as they attempt to tame async by emulating this behavior.
Note that to do anything other than sequential is extremely complicated to reason about, not because of computers, but because of logic/math. All sorts of concerns like: race conditions, synchronization, dead lock, etc are inherent.
Any approach that does not directly address these issues is the one that's creating a leaky abstraction.
> so you known you need to spawn a new thread if you don't want to wait until the completion.
All functions take "blocking time" to execute. It's a spectrum of how long you want to wait.
- littlestymaar 3y ago> Can you explain what details leak? You answer half of it a few lines later: > All sorts of concerns like: race conditions, synchronization, dead lock, etc are inherent. > Any approach that does not directly address these issues is the one that's creating a leaky abstraction. By writing `await` you're telling your reviewers, coworkers and even your future self than your program stops executing sequentially at this step, and that other concurrent task can do things in the meantime. When using blocking code, the same thing can happen, but this is hidden from you. But in my perspective as a back-end engineer, the biggest issue is related to latency: with annotations you know (and tell others: code is written once but read many time) what takes significant time, with threads and hidden yield point you don't. It looks sequential, but the latency is an observable behiavor that show it's not: the definition of a leaky abstraction. > All functions take "blocking time" to execute. It's a spectrum of how long you want to wait That's technically correct, but keep in mind that the magnitude difference between your typical REST API call and a CPU instruction is roughly the same as the difference between the size of a football field and the distance to the Sun…
- starcraft2wol 3y ago> When using blocking code, the same thing can happen, but this is hidden from you. I'm not convinced. I don't see how it is hidden from you. The blocking code works exactly as written. The mistaken assumption would be that your program will never be premempted or have to wait for resources. > the magnitude difference Rarely is a function call in C a single instruction. They are typically algorithms of non-constant complexity. So yes... but you're also picking the most extreme comparison. What about `fopen` vs `partial_sort`?