January 2017: Interfaces and Protocol Buffers
Meetup #35. Please RSVP at Meetup.
We get started at 6:30 pm.
Sponsors
Venue provided by Startup Edmonton.
Food sponsored by Bellstone Engineering.
Talks
Interfaces in Go
Brett McKay argued that Go is "more UNIX than UNIX" in its design: instead of the UNIX ideal that everything is a file, Go treats everything as an interface. Files are a leaky abstraction — some need ioctls, some can't be seeked, some can't be closed — whereas interfaces describe behaviour, and everything does something. He illustrated the point with flat files, asking which interfaces should actually exist for read, write, open, and close, then built a running example around an online casino. Games like blackjack, craps, and roulette all share the same behaviour — players place bets, the game is played, and results are settled — so he modelled that as a small casino game interface with a simple HTTP croupier implementation. The lesson was to keep interfaces as small as possible, and he pointed to the interfacer vet tool, which warns when you accept a larger interface than you actually use.
Key points:
- UNIX's 'everything is a file' ideal breaks down for sockets, devices, etc.
- Interfaces describe behaviour, and everything does something.
- Design interfaces from the behaviour actually used.
- A casino example: games share bet → play → settle behaviour.
- Small interfaces keep implementations simple and composable.
interfacerflags interfaces larger than necessary.
Protocol Buffers and gRPC in Go
Adam Wolfe Gordon gave an introduction to Protocol Buffers and gRPC in Go. Protocol Buffers are Google's language-neutral serialization format: you define messages in a .proto file and generate idiomatic code for your language. He balanced the trade-offs — broad language support, built-in backward compatibility (fields can always be appended), and a compact binary format, against the facts that the format isn't self-describing and is hard to inspect by hand. gRPC builds on that: an RPC library that serializes messages with Protocol Buffers and uses HTTP/2 as its transport. Its selling points are generated client and server "glue", TLS by default, surprisingly good performance, and cross-language RPC — a Go server talking to a Ruby client, for example.
Key points:
- Protocol Buffers define language-neutral messages that generate code.
- The binary format is fast and small, but not self-describing or easily inspected.
- Backward compatibility comes from appending new fields.
- gRPC is an RPC library that uses protobufs over HTTP/2.
- It generates the client and server boilerplate for you.
- TLS is the default, and cross-language RPC works well.
News
- Go 1.8 Release Candidate 2
- Go 1.8 draft release notes
- The Saga of Go Dependency Management
- Buffalo web development eco-system
Events
- Web Development with Buffalo - Jan 31 at noon MST
- Rapid Web Development with Buffalo and Ponzu - Feb 2 at 11am MST
- Monthly Hack Day - Feb 4
- Edmonton Go Meetup - February
- GopherCon July 12-15