Panel discussion with Go team members
Blake Mizerany’s scheduled talk, “Little Known Tricks in the Go Standard” was made redundant by other talks, which covered all of Blake’s material. Instead, Blake hosted a panel discussion with 4 members of the Go team: Rob Pike, Andrew Gerrand, Brad Fitzpatrick, and Robert Griesemer.
(Ed. note: We’ve paraphrased most of the responses, and we’ve omitted the answers that referenced personal stories or jokes that wouldn’t come through in writing. Watch the video (which will be posted later) if you want to see the full Q&A. Let us know if we’ve missed or mistranscribed anything.)
Q: Rob (Pike), what was the most important thing you learned in C++ that affected Go?
A: Build time matters more than anything else. There are so many other things I could think about, but they’re all “what not to do.” The amount of extra typing you must do is awful. One afternoon, I typed the same function signature 56 times.
Q: Robert (Griesemer), you worked on V8 before coming to the Go team. What have you brought to Go from that experience?
A: I worked mostly on the V8 internals. So, I wasn’t necessarily an expert on JavaScript, just as you can write the JVM without knowing Java. I also didn’t grow up with a C and Unix background, as the rest of the Go team did.
Q: What were the first Go programs you wrote that genuinely surprised you?
A from Andrew Gerrand: Probably the http.HandlerFunc type, which implements the http.Handler interface, but it’s a function type. When I first saw this, it was like “woah, that’s weird.”
A from Rob Pike: http.HandlerFunc was going to be my answer. Another thing was the encoding/xml package, where you just write the struct with tags and encoding/decoding just happens.
A from Brad Fitzpatrick: When there’s a named type that’s not a struct.
A from Robert Griesemer: When I realized you can have a non-nil interface that you assign a nil value to. (Brad Fitzpatrick agreed. Rob Pike: “nil is a value, too!”)
Q: What was the most awkward thing you’ve seen written in Go?
A from Andrew: Some of Brad Fitzpatrick’s tests. And bad concurrent code.
A from Robert: I still see a lot of “if boolVar == true”. And for loop index variables that have long names.
Q: What contribution you made to Go are you most proud of?
A from Brad: net/http. (Rob Pike: “I’d like to thank Brad for the net/http and os/exec packages. I think they’re just marvelous.”)
A from Andrew: map deletion syntax.
Q: What do you wish you hadn’t contributed to Go?
A from Rob: netchan. Also, variable declarations. They could be cleaner and less confusing.
A from Brad: C constants in the os package that are named like C, like os.O_RDONLY.
Q: The implementation of sync.Pool uses all kinds of stuff in the runtime that we don’t have access to (such as garbage collector internals). Why?
A from Rob: It’s the job of the stdlib to give you controlled, clean access to certain things. The behavior of the garbage collector is something that should probably be hidden from user code.
Q: What was awkward about var decls? [Referring to Rob’s statement above.]
A from Rob: Shadowing. Colon-equals syntax is good, but it looks like an assignment (not declaration). There are so many ways one can declare a variable. Also, you can’t declare the same things with “var” that you can with colon-equals, so it’s not clean. It all works pretty well in practice, but there are some corner cases that’d be nice to clean up.
Q: Are there any plans to make the garbage collection in Go pluggable?
A from Rob: It’s open source. If you make a patch to improve it, we’ll accept it. There are no plans to make it pluggable, but we’re always trying to make it better. Note that Go’s garbage collector doesn’t have a lot of flags (like Java’s garbage collector). That’s on purpose.
Q: Why are build tags in comments?
A from Andrew: Because they’re not part of the language, they’re part of the build system. The language is interpreted by 6g, and the comments are interpreted by the go tool.
Q: What is the next thing that Go can do to increase the rate of its growth?
A from Andrew: I’m really excited about Go moving into new spaces. Most people use Go to write servers now, but it’s exciting to see Go being used in the embedded (ARM) space, and Gustavo Niemeyer’s graphics stuff. Also, desktop apps, mobile apps. We want to help improve support in these areas in the coming years.
A from Robert Griesemer: I’m looking forward to a Go compiler written in Go. I think it could be much faster than it is now. (Rob Pike: “Yeah, Go builds are way too slow. [laughter] I mean it.”)
A from Andrew: We have a label in the issue tracker for Go 2, and we use it to label issues that we can’t address yet. We’ll address those issues when the next breaking release comes along. We’re learning from how other languages have made breaking transitions, such as Python 2 to 3. Overall, Go 2 is not top of mind for us right now.
Q: You blogged about the unexpected uptake of Go in the dynamic languages community (as opposed to the C/C++ community). Does that change your plans for the language?
A from Rob: It hasn’t changed the language, but it has changed my own perception of the way you can use it, what’s important, serialization, etc. We had no idea that dynamic language people would adopt Go this much when we designed the language; it happened well after the initial design. Even if we knew about it in advance, I don’t think it would have changed the language design much.
Q: What’s the best thing about your open source contribution process?
A from Rob: Windows support was entirely from open source contributors. It’s a complete vindication of the open source ideas.
Q: Have you looked into embedding Go in C, Rust, etc.?
A from Rob: We’ve thought about it a lot and want it to be possible. The challenge is that Go’s runtime is built in such a way that it must own everything: memory, signals, etc. All of this is dictated by Go’s concurrency model and implementation. E.g., stack switch when switching between C and Go in cgo. Embedding is a tricky thing, but we really want to see it.
A from Robert Griesemer: Also, since we have a garbage collector, we need to track pointers on either side of the language fence.
Q: Brad, how did you design the HTTP keepalive pool?
A from Brad: Someone from the Chrome team wrote a long blog post about their HTTP keepalive support. I read this blog post and heard about the performance benefits they got from this. Adding it to Go took just a few lines, but the Chrome implementation required many more lines of code.
Q: If you could add one thing to the Go stdlib, what would it be?
A from Andrew: A superb, universally cross-platform graphics toolkit that looks amazing.
A from Rob: We have a lot of good tools for static analysis. I’d like to see a good tool for dynamic analysis. I haven’t seen any languages with the kind of tool I want.
A from Brad: Android, iOS, generics. [audience laughter]
A from Robert Griesemer: I’d like the compiler to be a library so I can call it and get an executable that I can invoke from code.
Q: What’s the best way to work around the lack of generics and polymetric polymorphism?
A from Rob: If it’s not performance critical, just use reflection. Otherwise, use Robert Griesemer’s fantastic libraries for source code rewriting, and write a tool to automate the writing of source code. The whole computing community underappreciates the value of programs that write programs. This is a perfect use for them.
Q: What are the plans for Go Oracle?
A from Robert Griesemer: This is really Alan’s work. My contribution is the go/types package, which is essentially complete but probably has some bugs. The first true implementation of this is in Go 1.3’s godoc, which has the Oracle’s functionality built in.
A from Andrew: A lot of people want autocomplete in editors. My main issue is navigating the code I’m working with, and understanding that code. Once I understand the libraries, remembering what to type is not the biggest issue. I’d love tools that help you understand how code fits together in a foreign codebase.
Q: How did interfaces and structural typing come to exist?
A from Rob: In the first or second day, we realized we wanted a pure behavioral type, so you don’t conflate the data and methods.
A from Robert Griesemer: We debated for a while whether you should be able to have concrete methods on an interface. We concluded that not having concrete methods would keep the concept of interfaces orthogonal from the other concepts in the language.
Q: What is your favorite Go keyword?
A from Andrew: notwithstanding
A from Robert Griesemer: go
Q: What is your least favorite Go keyword?
A from Andrew: thetruthofthematter
A from Robert Griesemer: goto
(Ed. note: Don't believe that notwithstanding and thetruthofthematter are real Go keywords? We didn't, at first. grep the Go source to prove it for yourself.)