
Gopherfest 2015 | Go Proverbs with Rob Pike
About this video
Rob Pike presents Go Proverbs at Gopherfest 2015, a set of pithy aphorisms about Go design such as 'Clear is better than clever' and 'A little copying is better than a little dependency'.
Why it appears in the archive
HN treats it as the canonical source for Go proverbs, quoted in debates about dependencies, concurrency and simplicity.
AI-generated summary and labels from the source dataset; verify important details against the video. Source & credits.
From the Hacker News discussion
Just in case you haven't read the footer text: The proverbs are based on this awesome talk by Rob Spike: [VIDEO] And for new proverb ideas, you can open an issue here: [LINK]
Read original comment ↗Indeed, taken from "Go Proverbs" - [LINK] "Concurrency is not parallelism." > Video: [VIDEO]
Read original comment ↗"For comparison, this Amazon VPC example may be worth checking out" It might be better to compare how to use the module/stack: - Terraform: [LINK] - Pulumi: [LINK] So as a user, can I configure this Pulumi VPC stack before it's instantiated? Or do I have to use the defaults first and then use the CLI to change things? Do these CLI changes then get placed into code, or just into state? Does that mean I'm now in a situation where the code doesn't match the state? Personally I find the Terraform configuration much easier to reason about, I see exactly where resources are declared just by scanning the file. (But I've also used Terraform a lot). Edit: Ah, maybe I have to configure it via this config.py file [1]? I appreciate what Pulumi is trying to accomplish, but that is certainly not a config format I'd like to be using. Maybe you could use HCL or YAML for it? ;) Edit 2: Another last thought, I think a lot of the mindset in Terraform comes from Go, where the proverb "A little copying is better than a little dependency" is pretty well adopted. Before I started writing Go as my main language I didn't appreciate that mindset, but after 5 years with Go I've found it more and more appropriate [2]. [1] [LINK] [2] [LINK] -- [VIDEO]
Read original comment ↗A constructor is just a function though... If I add a new field to a Java class and fail to add its initialization to the constructor, I have the exact same problem because Java initializes the field to its default value when the constructor is called. You are correct that every situation where the struct in Go is initialized "bare" would need to be addressed if a field is added, but Go considers this a feature, not a bug (and, conversely, considers "bare initialization" of structs at dozens of places in your code to be bad practice if that struct could ever grow new fields). If you're bare-initializing structs, you're comfortable using them in a "loosey-goosey" context where zero-initialized fields are permitted (or, better, useful... [VIDEO] ). In Go, the issue of required structure is addressed by wrapping the struct in an interface and then providing a function in the package that can create an instance of the interface. Used in that way, you get something very similar to a Java class (though Go doesn't force you into the "everything is a class" paradigm that Java demands).
Read original comment ↗Vendoring is when you just copy the dependencies into your own source tree, like in a third_party directory. Personally, I'm a big fan of just taking what you need. A little copying is better than a little dependency[1]. [1] [VIDEO]
Read original comment ↗You've also opened yourself up to bugs by allowing the map values to be "false". Using a "set's" value in an if statement doesn't make sense either, compared to if _, exists := something[item]; exists { ... } which is explicit regarding what's actually going on. As Rob said, "Clear is better than clever." [VIDEO] I also don't want to be hunting down whoever creates a map[T]bool and doesn't leave a comment explaining it's a set ;) Hopefully we won't have to worry about it for much longer regardless, since I imagine we'll be using proper sets (with methods) some point in the near future.
Read original comment ↗Agreed. The problem with mutex is that it's often hard to get right, since it's a low-level primitive for serializing access to shared memory, and it does not compose (cannot atomically lock two mutexes). CSP/Actor model simply takes the problem that mutex solves on the low level - concurrency - and makes the whole world concurrent-by-default, so that mutexes are not needed. Note the 1st Go proverb [0]: "Don't communicate by sharing memory, share memory by communicating." [0] [VIDEO]
Read original comment ↗I think manual three-way comparisons are very clear. But so is strings.Compare. For better or worse, copying code is a pretty normal thing to do in Go. See "A little copying is better than a little dependency." [0] [0]: [VIDEO]
Read original comment ↗