3 ms·
> Blocking code is a leaky abstraction > Asynchronous code does not require the rest of your code to be asynchronous. I can’t say the same for blocking code.
by Joker_vD 2y ago
> Blocking code is a leaky abstraction
> Asynchronous code does not require the rest of your code to be asynchronous. I can’t say the same for blocking code.
Well, you can also say that "file systems are a leaky abstractions. Sector-addressing disk access does not require the rest of your code to access disk sectors directly. I can't say the same for the code that uses files".
First of all, asynchronous code does require the rest of your code to be asynchronous: because, as you've yourself said, blocking code doesn't mesh well with the asynchronous. Second, when your are trying to work with two different levels of abstractions at the same time, of course you will find the presence of the higher-level abstraction (the blocking code, the file system, etc) to be inconvenient: the higher-level abstraction has to make some opinionated choices, or it would not be an abstraction but merely an interface.
So yeah, I guess blocking code is a leaky abstraction, just like file systems, TCP streams, garbage-collected memory, and sequential processor instruction execution. It's still a higher-level abstraction though.