3 ms·
> there could be better primitives for communication than a byte stream. Why can't I just send another process a chunk of memory? shm APIs have made this possi
by PaulDavisThe1st 4y ago
> there could be better primitives for communication than a byte stream. Why can't I just send another process a chunk of memory?
shm APIs have made this possible for decades.
> the posix byte stream API is bizarrely based on a flat buffer instead of a ring buffer, which is just the obviously wrong data structure IMO.
so obviously wrong that the terabytes of existing POSIX-compatible code is broken, or limited, or something?
> Too much of the threading API is preempted threads, when cooperative scheduling (aka yielding) is so much easier to implement and understand.
if you want/need co-routines use them, and leave threads for the domains of programming where preemption is a critical part of the model.
ps. this sounds a bit more personally critical than I intend. I'm only trying to point out flaws that I see with these 3 points, not trying to suggest anything about you as the person who made them.
- Cpoll 4y ago> so obviously wrong that the terabytes of existing POSIX-compatible code is broken, or limited, or something? You could say the same thing about the terabytes of existing Javascript code, and most people will agree that Javascript has more than its share of "obviously wrong".
- vitiral 4y ago> so obviously wrong that the terabytes of existing POSIX-compatible code is broken, or limited, or something? it is just a really annoying API for a byte stream when what you typical want to do with a byte stream is: * read some number of bytes (lines, a parser, etc), incrementing the ring tail as you go. * have the buffer asynchronously be filled, incrementing the (volatile) head as it goes You might be able to just execute a single syscall "fill till eof" and the kernel would just keep your buffer full (through interrupts) without any other calls at all (although you would have to wait if the buffer became empty Similar mechanisms could be done for interprocess communication.