Re:The bigger the interface, the weaker the abstraction
by jiggawatts on Saturday July 29, 2023 @06:59PM
(#36925694)
A diagram that made things click for me is putting different abstractions on a grid showing the different combinations of high level contracts they fulfil.
Every combination of push/pull, read/write, and sync/async can exist and makes sense.
The Go interface is “sync pull read” which is “Readable”.
Then “Reader” is “sync push read”, etc…
Another axis is “single item”, “sequence of items”, or “contiguous array chunks of items”. These are “property”, “iterator”, and “stream” respectively of synchronous. They’re “task”, “asynchronous iterator”, and “async stream” if non-blocking. Etc…
Every combination of push/pull, read/write, and sync/async can exist and makes sense.
The Go interface is “sync pull read” which is “Readable”.
Then “Reader” is “sync push read”, etc…
Another axis is “single item”, “sequence of items”, or “contiguous array chunks of items”. These are “property”, “iterator”, and “stream” respectively of synchronous. They’re “task”, “asynchronous iterator”, and “async stream” if non-blocking. Etc…