88 points by tosh 6 days ago
CSP provided the basis for the occam programming language designed for the Transputers:
Edit: The CS course I did in the 1980s had a Concurrent Programming course that covered CSP and another one of my favourites: Petri Nets
Edit2: Go also has concurrency features influenced by CSP:
I like petri nets so much.
Whenever CSP comes around on Hacker News, I feel the need to suggest people look a bit into Milner's CCS as well.
The end goals of both languages are mostly the same, but while CSP aims at being a "powerful" language, CCS strives for simplicity. You can see how both approaches have their pros and cons.
Yes! CCS feels like “the” concurrent equivalent of the lambda calculus (although really there’s a huge family of similar simple process calculi that are all essentially the same). CSP feels very large and untidy in comparison.
The whole book: http://www.usingcsp.com/
Thanks for sharing
Ha - nice to see this - myself and a few others built a transputer compatible VM - http://www.transterpreter.org/ and used it to run occam2 and derivatives on various machines, and robots including the cell processor in the PS3.
This brings back happy memories for me. In the late 80s, I wrote thousands of lines of Occam for a Meiko Computing Surface made from Inmos T800 Transputers. Among the parallel algorithms I implemented was Lamport's algorithm for finding shortest paths in a graph.
Sounds really interesting!
Can you write more about the programming experience? Particularly the handling parallel processes and communication, but also general observations.
CSP formed the basis for a good chunk of my graduate work.
One concept we explored was using CSP as a 'formal backbone' that handled communication/parallelism in complex systems while allowing stand-alone 'business logic' to co-exist without the need for the same level of rigour.
If you're reasoning about a concurrency problem, doing a quick CSP spec on the back of an envelope is a great way to 'check your math.'
Steve Schneider's book is a very approachable text on the subject: https://www.amazon.ca/Concurrent-Real-time-Systems-CSP-Appro...
That book has been made availabel for free as a PDF.
I find this concept really remarkable and extraordinary. When I first encountered it I was still programming in Java and to my surprise there is an implementation of it in Java, see:
I really enjoyed playing with this library. Somehow the basic abstractions and the mental model to use it felt much easier in general than the threading model. It reminded me of go channels for some extent. It is also a very powerful concept. It even allows to emulate the actor model. Sadly it is not actively developed any more.
"It reminded me of go channels for some extent."
Go channels explicitly drew from CSP for inspiration, but it is not exactly the CSP in the paper.
That said, almost everything that draws from CSP for inspiration has at least a small difference from the paper, if you analyze it closely enough. Often major differences. The idea seems robust enough to those variations that it's not a problem, though.
How is it robust if Go is pretty much the only widely used CSP implementation in existence. And Go itself is constantly fighting CSP deficiencies, trying to abstract it away and move closer to actors. Still not getting there, because actors cannot be properly implemented on top of CSP and CSP alone cannot be used for anything real world related.
If anyone wants to learn something from CSP, learn why it doesn't work.
"pretty much the only widely used CSP implementation in existence"
The history of programming shows a lot of evidence that good ideas can take decades from initial proposal to even being in a B-list language like Go, let alone being "widely used" to the degree I think you are, so I put only modest credence in it being not terribly widely used yet.
"And Go itself is constantly fighting CSP deficiencies, trying to abstract it away and move closer to actors."
Having programmed in Erlang for a long time, I don't find this to be true. I've certainly got quite a few things that look like actors, but quite a lot of things that definitely aren't, too.
"CSP alone cannot be used for anything real world related"
Which probably goes back to why everyone tends to tweak it a bit. (I have further quibbles with that characterization, but not important enough to go into.) And Go doesn't offer "CSP alone", but rather CSP grafted on to the side of a standard structured programming model, something we do know can be used for real-world work, so it all seems to work out pretty well.
Could you be a bit more specific? Why do you think it doesn't work? Why do you think actors are better? And why can't actors be properly implemented on top of CSP?
I touched on this in my MSc thesis , see section 2.6 and 3.4.1. The original CSP can only work if you stay on a single machine. You can have channels in a distributed setting but you need to make the reading capability of a channel limited to a single consumer. If there are multiple possible readers at the same time it gets impossible to know where to send each message and in a distributed setting there's no way of solving that, short of solving distributed consensus. Cloud Haskell  section 4 touches this as well.
>Go is pretty much the only widely used CSP implementation in existence.
Clojure’s core.async is another arguably widely used implementation (it pays my bills).
I took CSP as a basis for learning how distributed and concurrent protocols work, and then did Erlang to see that into reality. Great thing to learn