Home > Uncategorized > Go Sieve

Go Sieve

The newly announced Go language set the Internet abuzz this week. I’m not going to write extensively about it, partly because I haven’t had much time to examine it in detail, and partly because other people have already written a lot about it. It is interesting to note that CHP and Go share a common heritage in Hoare and Roscoe’s CSP (Communicating Sequential Processes). I will be mentioning CSP in a couple of posts next week; CSP is a process calculus used to describe message-passing concurrent systems.

CSP inspired occam, which in turn became occam-pi (using ideas from the pi-calculus), which is still under active development. occam and occam-pi also inspired various libraries for CSP-style concurrency, such as JCSP, C++CSP, PyCSP, and many more including CHP. But CSP also inspired Newsqueak, and Rob Pike went on from that to work on Limbo and now Go which retain the CSP influence. It’s certainly nice to see other people looking at message-passing concurrency.

I did get time to glance at Go’s tutorial, and saw that they have an example for generating prime numbers using a process pipeline which uses the exact same design as my CHP primes example. So you can compare the CHP version to the Go version if you wish. (I took the design from the JCSP version; I wonder if the Go developers did too.)

Categories: Uncategorized Tags:
  1. Anh Hai Trinh
    November 16, 2009 at 7:58 pm

    I’ve implemented the faithful Eratosthenes sieve here , still using CSP and Go. It is optimized and massively faster than the one given in the tutorial.

    It is still however, slower than Haskell’s fastest implementation: ONeilPrimes from . But that is unfair comparison because that one use cons’ed list instead of channels.

    Now if you rewrite your sieve to be faithfully Eratosthenes (and still using CSP channels) then we can compare speed!

  2. Anh Hai Trinh
    November 16, 2009 at 8:00 pm

    Links didn’t like being inside angle brackets. Here they are:


    and faithful Haskell implementations:


  1. November 16, 2009 at 3:42 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: