Google I/O 2012 - Go Concurrency Patterns
Google for Developers9 HN recommenders · recommended in 9 months, 2012–2025
talk · intermediate · evergreen · 2012–2025 on HN
Rob Pike's Google I/O 2012 talk shows how goroutines and channels solve tricky concurrency problems with simple Go code. It features a playful goroutine demo with gophers passing messages and a search engine example.
The canonical recommendation for learning Go concurrency, praised as entertaining and clarifying when to use channels versus mutexes.
Up next
12 mo on HNLexical Scanning in Go - Rob Pike
GoogleFOSSSydney
13 HN recommender · 2012–2025
1 mo on HNTMS Bicycle, stable without gyros or trail (TMS=two-mass-skate)
Arend Schwab
2 HN recommender · 2013–2019
3 mo on HNOrigins of Go Concurrency style by Rob Pike
jasonofthel33t
3 HN recommender · 2013–2025
2 mo on HNHow Analog Color TV Works: The Beginnings
Technology Connections
2 HN recommender · 2019–2026
2 mo on HNPitfall: A Classic Game Postmortem
GDC Festival of Gaming
2 HN recommender · 2021–2024
4 mo on HNSQLite: The Database at the Edge of the Network with Dr. Richard Hipp
Method
4 HN recommender · 2017–2024
3 mo on HNOculus Connect 2: Live Coding Session with John Carmack
Meta VR
3 HN recommender · 2016–2023
3 mo on HNTWiST #46 with David Heinemeier Hansson
ThisWeekinStartups
3 HN recommender · 2010–2014
11 mo on HNCppCon 2015: Andrei Alexandrescu “std::allocator...”
CppCon
7 HN recommender · 2017–2025
10 mo on HNCppCon 2017: Matt Kulukundis “Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step”
CppCon
9 HN recommender · 2018–2026
9 mo on HNRustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West
Rust Programming Language
9 HN recommender · 2018–2023
10 mo on HNCppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
CppCon
13 HN recommender · 2016–2024
12 comments from Hacker News
For those who don't know who Rob Pike is, he's pretty awesome, helped create UTF-8 among other things, and now works on Go. link He has given some really great Go talks which are available on youtube, about an hour each: Origins of Go Concurrency Style - link Lexical Scanning in Go - link Go Concurrency Patterns (One of my favorites) - ▶ this video
Great talk by Rob Pike: ▶ this video "Go Concurrency Patterns" with cute little gophers playing Chinese whispers with megaphones
Not quite. Erlang uses the Actor model which delivers messages asynchronously to named processes. In Go, messages are passed between goroutines via channels, which provide a synchronization mechanism (when un-buffered). The ability to synchronize allow one to setup a "rhythm" to computation that the Actor model is explicitly not designed to do. Also, note that a process must know its consumer in the Actor model, but goroutines do not need to know their consumer in the CSP model. Channels can even be passed around to other goroutines! Each have their own pros and cons. You can see some of the legends who invented different methods of concurrency here: link There's also a nice talk Rob Pike gave that illustrated some very useful concurrency patterns that can be built using the CSP model: ▶ this video
This is true, that's exactly what exceptions are. One could argue (I would) that this is a very powerful part of Python, but the indeterminate nature of the exception (where is it coming from, how is it defined, what should I provide to my client) makes it easier to catch exceptions as they percolate upward, but more difficult to correctly know how to handle them (especially as the permutations approach infinity as underlying libraries get upgraded). Golang actually has a back-channel communication path that is somewhat similar as a second channel of communications. (Actually they're called channels!) They're a first-class and extremely powerful feature of the language. You can even run a for loop over them, block or not block while waiting for an incoming message, etc. Here's a great video that talks about use cases and the patterns in using them, and they pair great with goroutines (and you don't have to sprinkle async before every function, either): ▶ this video
Rob Pike did a number of interesting talks on concurrency in Go. If you search "Go concurrency" on YouTube there are more good talks. Go Concurrency Patterns ▶ this video Concurrency Is Not Parallelism link
In my experience with Android apps, I've almost never had to use the NDK. When I did have to use the NDK, it wasn't because I wanted to code in C/C++---it was because there were strong, open-source libraries written in C/C++ that I wanted to use in an app (Though, I have no experience making games on Android). If you want to check out Go, then the Go Tour [1] and the various talks by Rob Pike [2] [3] / Sameer Ajmani [4] are great resources. The Go Tour stands on its own as an interest-building resource; the several programming exercises it has you do are fun and challenging. [1]: link [2]: ▶ this video [3]: link [4]: link
Great explanation in document form of these patterns. Also very succinct and easy to reference. For those that would rather read this in presentation form: link And for those that would rather watch a video presentation: ▶ this video
You're responding to: > Clojurescript is the browser language I always > wanted. JS seems like such a hack. You're getting downvoted for reading into someone's enthusiastic personal endorsement and then ending it with the tiring "Tell me something good about <thing I refuse to read or understand on my own time but I'll partake in discussion anyways>...". Start with Rob Pike's "Go Concurrency Patterns" ( ▶ this video )
I'm a fan of Go, but this is not a very good talk. The first half is unnecessary trolling, and the second half is based on some code snippets taken from Rob Pike's "Go Concurrency Patterns", but in this case badly presented. So I prefer the original: ▶ this video
In one word: channels. They might be theoretically equivalent to some degree, but in practice they are quite different, and I find reasoning about both concurrency and parallelism using goroutines and channels much more natural. Also see this talk by Rob Pike on the origins of Go's concurrency model here: link See also this article by Russ Cox about CSP: link And Rob Pike's latest talk about concurrency patterns at Google IO last week: ▶ this video
All implementations of in-process thread multiplexing is sort of like a garbage collector. You have a resource, you manage the allocation of a resource to something that consume it, etc. A lot of house keeping and some overhead code that needs to execute before any work is done (each time). In my mind, it makes sense to have a single, well tested, and abstracted implementation that all other systems can use. You can see a need for this at least in the Android space: RxJava, Kotlin coroutines, etc. Also, in a user-managed thread multiplexing system you can't guarantee "fair" scheduling. If you have some DOS bugs in your server you can lock up an entire serving thread. A language-level multiplexing system will not have these same kinds of edge cases. There are many places this sort of thing becomes helpful. We could also see concurrent processing utilities that could be very helpful. See this for more info on how this could lead to cleaner programs: ▶ this video
Go was built as a language to make communicating sequential processes[1] first-class citizens. Thus the ubiquity of channels and goroutines. No locks, no condition variables, no callbacks[2]. Writing a bunch of code using locks and callbacks in Go goes against the grain of the language. [1] link [2] ▶ this video