Drinkup Notes
We met 2022-12-20 19:00 at CafĆ© Cantona, with no specific Go agenda, for a great exchange of ideas and experiences - too many to capture them in a blog post, so here’s just a fraction of the topics we passed (slightly categorized):
Reading list
- Grokking Functional Programming - a very readable introduction to the topic; more academic angles include the classic Out of the tar pit or Purely Functional Data Structures (always nice to find references to this book in code)
- in 04/2022, a JS version of SICP (1984) came out: SICP JS edition, there’s an open access version, too
- Podman in Action, container tools with a nice Unix backdrop
- the classic, albeit just five year old DDIA
- 100 mistakes in Go and how to avoid them - actionable advice for Go code improvements
Software General
- ISO 28500:2017, aka WARC is how you can capture the web - and there are many libraries and tools around this format, just to name a few: Heritrix, brozzler, webrecorder, warcprox, replayweb.page, and more
If you have wget (1.14 or later) installed, you can already create WARC files yourself:
$ wget -rkc --warc-file golangleipzig.space --warc-cdx https://golangleipzig.space
Since web archiving aims for a complete preservation, the whole HTTP exchange is recorded - which can be analyzed later. The HTTP Archive creates various reports, e.g. a yearly state of the web report.
- Parquet is a great columnar storage format, with a few libraries in Go, too, e.g. from the Apache Arrow project
There’s a new wave of big data and analytics tools written in rust, e.g. the distributed SQL query engine ballista (NY statprog meetup recording), and others
- Did you know? Google BigQuery does not have
MEDIAN
- workaround
Go
- JSON matcher: quamina
Quamina implements a data type that has APIs to create an instance and add multiple Patterns to it, and then query data objects called Events to discover which of the Patterns match the fields in the Event.
- Go generics utils: gogu
Gogu is a versatile, comprehensive, reusable and efficient concurrent-safe utility functions and data structures library taking advantage of the Go generics. It was inspired by other well established and consecrated frameworks like lodash or Apache Commons and some concepts being more closer to the functional programming paradigms.
- Functional options pattern (we talked about that in #13) has some advantages over the still widely used technique of passing config structs to functions.
A Go interface puzzle
Declare an interface where it is used, not where it is implemented. Unless the interface is well discovered.
Via: 1605116543553019905 – join the conversation …
Our take: It’s a - slightly subtle - consequence of structural typing: An interface can be added later, in an ad-hoc style, e.g. to facilitate testing or to establish a protocol of limited scope.
Example: A function only uses client.Do
for HTTP requests. We can create an ad-hoc interface, so we are able to use the default HTTP client from the standard
library or some third-pary library as well (as long at it has a suitable Do
method). We can define a Doer:
type Doer interface {
Do(req *http.Request) (*http.Response, error)
}
and let our function work with this Doer
interface instead of a concrete type.
This interface should be defined where it is used (and not in the net/http
package, for example). On the flipside, sometimes you need central interfaces,
e.g. io.Reader, or a database abstraction
layer, or a filesystem abstraction
layer, and so on. These are well discovered.
In a structural setting, a type expression is a closed entity: it carries with it all the information that is needed to understand its meaning. In a nominal system, we are always working with respect to some global collection of type names and associated deļ¬nitions. This tends to make both deļ¬nitions and proofs more verbose.
More on nominal and structural typing can be found in Chapter 19.3 of Types and programming languages TAPL.
Python
- pip-tools is a small tool for pinning dependencies and predictable builds
- Python in 2022 with gradual typing feels like a static language now - a long way since Static Typing Where Possible, Dynamic Typing When Needed: The End of the Cold War Between Programming Languages (discussed at the time by LtU)
API Design
- Expanding objects - another example in the wild: fatcat API (List of sub-entities to expand in response. For releases, ‘files’, ‘filesets, ‘webcaptures’, ‘container’, and ‘creators’ are valid.)
- Idempotency tool for AWS lambda
Related, from Cloud Native Go (a book we gave away in #30, courtesy of O’Reilly Media), page 168:
Holly Cummins, the worldwide development community practice lead for the IBM Garage, famously said that if cloud native has to be a synonym for anything, it would be idempotent.
Cloud
Running Kubernetes with rootless podman is documented on both kind and minikube but to get it up and running on WSL2 requires some additional tweaks as by default WSL2 uses init daemon, instead of systemd and you have to enable cgroupv2 explicitly. …
- The perennial question: how can you beat cloud infrastructure from a developer experience (and economical) standpoint? For example, how can we create a robust, scalabale queue with less effort than writing e.g. 15 lines in Go (including error handling); (btw, SQS started in 2004); at some places, infra works differently ā¤ļø
Misc
- Culture: Visual Studio Code is designed to fracture
- How to improve as an software engineer? We got some ideas, like keeping a (public) technical journal, but are curious about what you think - so join our meetup to connect and to get notified of upcoming events!
- Airtags and Parcel: DHL “Lost” My AirTag Parcel (but I knew where it was)