3 ms·
Threads + some kind of channel (a la Erlang processes or Go's goroutines) are pretty much direct programmatic representations of CSP. Shared memory does break t
by simiones 6y ago
Threads + some kind of channel (a la Erlang processes or Go's goroutines) are pretty much direct programmatic representations of CSP. Shared memory does break the model to a great extent, but async code is significantly more different.
The main difference is that in CSP (and thread-based models) the thread of execution is explicitly represented as an entity in the code. In async models, the threads of execution are mostly abstracted away and implemented by a runtime scheduler, while communication is done purely by function return values.
Of course, you can typically implement any of these models in terms of each other (e.g. you can easily implement CSP channels in a language which offers mutexes and shared data; or you can implement them with async/await primitives). But the base support in the language and the patterns you'll see emerge in idiomatic code will be different between goroutine/CSP, shared-memory parallelism, and async/await.
- andrekandre 6y agoThreads + some kind of channel (a la Erlang processes or Go's goroutines) are pretty much direct programmatic representations of CSP. sorry if i misinterpreted, but i dont think that is correct that erlang processes exemplify channels/csp afaiu erlang is based on non-sequencial processes more like the actor model, there is no "communicating sequencial" process at the base of it (though you can implement csp in actor languages) afaik here you can see joe armstrong and carl hewitt fundamentally disagree with sir tony haore (csp) and sequential channels as a fundamental construct [1] https://www.youtube.com/watch?v=37wFVVVZlVU&t=720s https://www.youtube.com/watch?v=37wFVVVZlVU&t=720s again, apologies if im arguing something that wasnt implied, it was just something i noticed ^^
- simiones 6y agoThank you for pointing this out, I wasn't aware! I had just assumed that Erlang's message passing was also synchronous...