Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Golang Concurrency

Alex Wheeler
November 16, 2017
87

Golang Concurrency

Alex Wheeler

November 16, 2017
Tweet

Transcript

  1. Background • Developed at Google • Born out of frustration

    • 1. efficient compilation • 2. efficient execution • 3. ease of programming
  2. Background • make programming fun again • feel of dynamic

    language with type safety • run-time that supports GC, concurrency • lightweight flexible type system
  3. BUT FIRST… • Concurrency != Parallelism • Concurrency is about

    dealing with lots of things at once. • Parallelism is about doing lots of things at once
  4. goroutine • lightweight thread managed by the go runtime •

    little memory (~2kb stack space), can spawn millions if you want • go f() starts function f in a new groutine
  5. • “Don't communicate by sharing memory; share memory by communicating.”

    - Golang • Communicating Sequential Processes - Tony Hoare
  6. <- channels <- • typed structure through which you can

    send/receive values using the channel operator • first class values • block by default