4 ms·
> It illustrates decisively that a language that doesn't hide async behavior balkanizes libraries into (at least) two camps for everyone's detriment. That arti
by dnomad 8y ago
> It illustrates decisively that a language that doesn't hide async behavior balkanizes libraries into (at least) two camps for everyone's detriment.
That article simply begs the question. Or rather, I think the author has missed the point. Advocates of Futures-based APIs for example don't regard the balkanization as a bad thing. That's the point -- asynchronous functions really are different, they really do accept and return different types of values in the form of callbacks and futures.
Threading and shared memory don't solve anything, btw. These are implementation details. This is not about implementation so much as it's about expressing contracts between modules. Go channels are, frankly, rather useless but still, to my point, they don't try to hide asynchronous behavior. Go could've gone whole hog and provided yield and subsumption but I think they wisely realized that concurrency at scale requires shared nothing message passing. Or rather the essential insight of CSP (and Actors, and PPP and so many other models) is that reifying events and the flow of events is a good thing.
(Though I've heard it proposed that this is just because the limited human mind is "event oriented". Super intelligent martians and AIs would use Dataflow[1] languages to talk about the illusion of time. They might see the world as a giant spreadsheet.)
> Making the programmer deal with async nature (even with await, yield, etc) adds additional unnecessary details for the programmer to worry about and makes the program harder to reason about.
Again, I think it's kind of wacky to think that the async nature is "unnecessary" or accidental for the programmer. The solution the programmer is trying to model is asynchronous. The whole point is to allow the end User to do stuff while you talk to the database or process multiple trades at the same time. You can't wish this asynchronous nature of the problem away because its asynchronous nature, rather than being an unnecessary detail, is the problem. A lot of very smart people have spent a lot of time trying to "solve" concurrency by making it invisible. All failed. The issues around concurrency are a problem that must be addressed head on.
Types are the abstraction that let us be very precise for describing how a system can change. Using the type system to bring the problems of concurrency to the forefront so that they can reasoned about and enforced by the compiler is absolutely absolutely a good thing. People don't like this though because concurrent APIs are "viral". One asynchronous function now requires all callers to either block or become asynchronous themselves. But this was always the case anyways. As Morpheus would say, "How would this be different from any other day?"
[1] https://en.wikipedia.org/wiki/Dataflow_programming https://en.wikipedia.org/wiki/Dataflow_programming
- ioquatix 8y ago> asynchronous functions really are different, they really do accept and return different types of values in the form of callbacks and futures. I'd argue that all code at some level is asynchronous. Once you start considering how the CPU executes code, and how OSes schedule threads/processes, it's not all that different. Yet, for some reason, we call that code synchronous.