Talks
Celsius: Types Are Cool
@nathany refactored a small temperature-conversion program step by step to introduce Go's approach to object-oriented programming. Starting from plain float64 values and formatted output, the talk added user-defined types (Celsius and Fahrenheit), explicit type conversion, and the compiler's protection against mixing types. It then turned the conversion function into a method with an explicit receiver, contrasted static dispatch with the dynamic dispatch interfaces use, and finished by implementing String() to satisfy fmt.Stringer — including the classic %v/String() stack-overflow trap. A second example, "Almanac", applied the same ideas to Environment Canada weather data using structs, slices, composite literals, and for range loops.
Key points:
- Define your own named types instead of using
float64directly. - Type conversion is explicit; the compiler stops you mixing Celsius and Fahrenheit.
- Methods attach behavior to a type through an explicit receiver.
- Adding
String()implicitly satisfiesfmt.Stringer(duck typing). - Beware
%vinsideString(): it recurses until the stack overflows. - You can only add methods to concrete types you own, in the same package.
- Methods can be defined on a slice type, as the Almanac example showed.
This talk is suitable for programmers new to the Go language.
Concurrency Is Not Parallelism
Rob Pike's talk explains that concurrency is a way of structuring a program so independent tasks can be composed, while parallelism is about executing those tasks simultaneously. The accompanying example is a complete load balancer (balance.go) in which 100 requester goroutines send Request values — each carrying a function to run and a channel to reply on — to a Balancer. The balancer keeps a pool of 10 workers in a container/heap ordered by pending task count, dispatching each request to the least-loaded worker through a select on incoming work and completed-worker notifications, and printing the average and variance of the queue lengths as it goes. It is a compact demonstration of goroutines, channels, interfaces, and composition.
Key points:
- Concurrency is about structure; parallelism is about execution.
- Communicate between goroutines with channels, not shared memory.
- Each
Requestbundles the work with the channel to reply on. - Implement
container/heap's interface to track per-worker load. selectmultiplexes new work and completion events.- Dispatching to the least-loaded worker keeps load balanced.
- Requester and worker counts are set by simple constants.
@rob_pike (video, slides, code)
The load balancer code will be available to examine, run and discuss after the video. The example is fairly advanced, but the principals can be understood by all.
Popcorn and beverages to be provided. Pizza provided by Jobber.
News & Events
- GopherCasts
- Baby Gopher
- Go Newsletter 2013 wrap-up
- GopherCon April 24-26 in Denver $299 USD
- dotGo October 10 in Paris 79 €
- Google Developer Group Edmonton February 4 at 8pm
- Edmonton Go Meetup - February (propose a talk)