At 15:30 in this talk (p13 of this presentation here) Rich Hickey mentions the formalisms available for reasoning about Communicating Sequential Processes. He then goes on to mention that these haven't yet been applied to Clojure's core.async.

The only reference I know of for CSP is Hoare's book. I can see some examples of formalisms to describe CSP here.

Suppose I wanted to do the most basic of CSP as per Rob Pike's presentation in Go (slide 43 of this).

var (
    Web = fakeSearch("web")
    Image = fakeSearch("image")
    Video = fakeSearch("video")

type Search func(query string) Result

func fakeSearch(kind string) Search {
        return func(query string) Result {
              //time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
              return Result(fmt.Sprintf("%s result for %q\n", kind, query))

How would I express this as an Algebraic statement? What benefit would it give me?

Taking a stab at it - I get

(Web → P) Π (Search → Q) Π (Video → R)

Which tells me that the Search process can choose to interact with Web or Video depending on which environment the Search Process chooses to communicate with.


I'm told that you can't do this in pure CSP because of the timer. For an answer I'm happy to assume we'll ignore the timer part of this.


1 Answer 1


As to the question what benefits it would give you, the answer is simplicity.

Modern programming languages are large beasts with complicated semantics, starting with syntax, and not ending with the rules for integer and floating point arithmetic (real languages, as you know, don't work with 'mathematical' integers and reals, but rather with finite approximations). A calculus boils programming languages down to some essentials of interest, in the case of CSP to agents that synchronise on names. This makes thinking about, and proving things to do with synchronisation much easier than doing so using a fully blown programming language. If you are not primarily interested in looking at computation from the point of view communication patterns engendered by synchronisation, then, maybe, CSP is not the right calculus for you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.