Concurrency Is Not Parallelism by Rob Pike


The world is not object-orientated, rather parallel.
Things in the world are happening simultaneously, yet the computing tools we have are not good at expressing that kind of world view.

Go is a concurrent language: can execute things concurrently and has the means to communicate between things that are executing concurrently.
Also has a select switch which is a multiway concurrent control switch.

Concurrency and Parallelism are not the same thing (and concurrency is actually better)

Concurrency is a way to build things: concurrency it is the composition of independently executing things (typically functions, but not necessarily).
Generally expressed as interacting processes (not 'process' in Linux sense), rather threads, coroutines, abstract concept.

Parallelism is the simultaneous execution of multiple things (possibly related but maybe not).

Concurrency is about dealing with a lot of things at once (structure), and parallelism is about doing a lot of things at once (execution).

Related but separate ideas.

In order to make concurrency work, have to add communication.

Tony Hoare 1978 paper Communicating Sequential Processes essentially makes all key points (truly one of greatest paper in computer science).


Example of Gopher moving books to incinerate: then two gophers with messaging, eventually two gophers, two piles of books and two incinerators.
Design is structured concurrently (way to think about problem), but not necessarily parallel because gophers don't have to work at the same time.

If expand to three gophers, will work faster. But fastest version will include a gopher to clean up the pile of books, even though doing more work.

Additional gophers more work but run faster: concurrent composition of better managed pieces can actually run faster.

Observation: improved the performance of the program by adding a concurrent procedure to an existing design.

Key: think about how to break the problem down into independent components that can separate and compose to solve entire problem.

Problem is analogous to web serving architecture.

Goroutines, Channels, Select and Closures

Can think of goroutines as a little like threads, but actually different. In the same address space, but much cheaper than threads.

Channels are a little like pipes in the shell (but have types and other properties). Used to communicate between goroutines.

Select lets you control program behaviour by listening to multiple channels at once and deciding who is ready to communicate.

Routine to create thousands of goroutines in a Go program.

Closures are also included in the language.


Concurrency is powerful. Concurrency is not parallelism. Concurrency enables parallelism.