149. Go! Programming Language

March 24, 2020

We all get stuck in ruts sometimes and now and then learning a new language can help switch things up. Or maybe we have to just learn one so that we can keep our jobs. Either way, there are some cool languages out there, one of which is Go Lang, which is the topic of today’s episode. Dave recently had to learn Go for a job, so he’s here giving the low down. In this show, we find out more about Go’s history and why it’s still a baby in the language landscape. Dave also sheds light on what the Go community is like. While some communities will eat you alive for asking the simplest question, Go’s clique seems to be welcoming to newbies. We also learn more about some of the controversial features of Go, from its hardline approach to inheritance and the way that it handles errors. In Go, it is not possible to implicitly have an error bubble up the stack because you need to find the error as a return value you have to check. This approach, while stringent, is helpful. We also talk about its use of threads and processes, some of its similarities to C, and other guard rails that make it a less ‘shoot yourself in the foot’ language. Go is a language for the people, and we look forward to sharing some of it with you today. Be sure to tune in!


Key Points From This Episode:


  • Some background on the history of Go Lang’s development.
  • Find out some of the similarities between Go Lang and other languages like C.
  • Dave’s experience of the Go Lang community and the learning resources available.
  • How Go deals with linters and stuttering and Dave’s experience with this.
  • Learn about Go’s code compiling and how it’s targeted to the architecture of the machine.
  • Go’s controversial take on inheritance versus composition and error handling.
  • An explanation of Goroutines and what they are typically used for.

Transcript for Episode 149. Go!


[0:00:01.9] MN: Hello and welcome to The Rabbit Hole, the definitive developer’s podcast. Live from the boogie down Bronx. I’m your host, Michael Nunez. Our co-host today.

[0:00:09.7] DA: Dave Anderson.

[0:00:11.5] MN: Today, we’ll be talking about the programming language, Go Lang. I’m going to call it right now. Go Lang is the compiled programming language for the people. I’m just going to do that, that’s what I’m going to do.

[0:00:23.5] DA: That’s the new tag line?

[0:00:24.9] MN: Yeah, programming language for the people, there you go. Dave has had the opportunity to pick up Go and actually been using it for quite some time and we thought it would be a perfect opportunity to talk about this programming language.

[0:00:39.7] DA: Yeah, it’s interesting, it’s like one of those programming languages where everybody who picks it up or like you know, there’s always like one or two people that are like, “Oh my god, this is the coolest program language ever.” You know, maybe it’s like Clojure or something like that.

[0:00:59.2] MN: Yeah, it’s always Clojure.

[0:00:59.6] DA: There’s like Clojure, Go. I don’t know, maybe Haskell.

[0:01:04.8] MN: Elixir couldn’t get that.

[0:01:05.7] DA: Elixir, yeah. But yeah, okay, you see some place that’s hiring for it and the people who are like going for that job are like self-selecting or they don’t know Go but they have to learn it on the job. That’s kind of like, the situation that I found myself in where it’s like, “Hey, we have chosen to use Go as a company to replace some older Python services,” which is like a common migration tab for people who are like, “Okay, we’re using Python and in this case like Python 2,” which is like no longer supported.

It’s like, “Okay, we like the simplicity of Python but we want something that’s like cooler than Python,” which – you know, Python’s the second coolest language for anything so it’s like pretty easy to find first coolest language or something.

[0:01:59.0] MN: Yeah.

[0:02:00.0] DA: Yeah, Go is a fun choice for that.

[0:02:05.4] MN: Awesome. Normally you go from like Java project and then they want to do it in python and then they find out that Python can’t cut it so then goes the next level, it’s the next tier. Before you know it, you’re probably writing in C, like at the last programming like effort for this project.

[0:02:22.2] DA: yeah, right. Go is like yeah, over 9,000. Not like final-form maybe but it’s like pretty close.

[0:02:31.9] MN: Pretty close. I think Go’s relatively new, right? Started in like development for this language started in 2007, announced in 2009 and actually version one was in 2012. It’s like a baby.

[0:02:48.3] DA: Yeah, pretty new. Like Python, Java, like even Ruby have been around since the 90s so it’s a pretty recent thing but like the people who built the language, I mean, there’s some pretty big brained smart people like Rod Pike, Ken Thompson, Rob Griesemer. I’m not like, I don’t follow them all on Twitter or anything but you know, just a cursory glance of the things they’ve done, they’re like expel labs people who have bene involved in things like development of Unix and like development of programming languages like B, the precursor of a C which is like, I didn’t even know that was a thing.

[0:03:32.1] MN: Yeah, but B is a thing.

[0:03:33.3] DA: Of course. I think A is a thing too, I think remember reading it like A was some influence on the development of Python as a language so –

[0:03:42.1] MN: Wow. You got A, B and C.

[0:03:45.0] DA: Right.

[0:03:46.1] MN: My gosh.

[0:03:46.6] DA: I guess that kind of got some things right with C. It’s not people’s favorite languages like pointers always kind of like are pretty scary, I guess.

[0:03:56.1] MN: Yeah, I mean, that’s like, you get that in computer science classes all the time and was a headache for a lot of people myself included.

[0:04:04.3] DA: Right, yeah, just blowing up memory addresses and stuff. But like, Go kind of like takes a lot of things out of C where it’s like, if you love this feature in C, you’ll love this thing, Go even more. It’s like, there was not much about like you know, doing a homework assignment and see that I loved but you know, I kind of get it.

You have some like, core features that are really powerful, in C and Go kind of tries to give you those things in a more friendly and like less foot gunny approach where you know, you won’t shoot yourself in the foot.

[0:04:45.0] MN: Yeah, I’m surprised I still have feet on how to do homework and C and C++. I know one big thing for people who are interested in learning a new programming language would be the community. Like how was it learning Go as a new programming language for you, was the community hostile? You go to a Java forum bro and they will eat you alive if you have like a silly question. Yeah, how was Go for you?

[0:05:14.4] DA: I mean, I think it’s just generally like pretty friendly like people are very enthusiastic and they want to like, grow the community I guess is kind of like an underdog, pretty new in this scene. But you know, someone recommended to me like a video about like concurrency in Go. Concurrency patterns in Go, that’s like one of the things I like is really popular with Go. Like doing things concurrently.

I watched the talk and it was like, “This is actually a really fun talk.” Like I don’t often find myself watching talks for fun but I watched like a couple of hours of talks from different conferences and people are like really excited about it and I found a lot of good resources. Besides the standard ones that I think we’ve talked about before on the show like we’re like reaching for –

Learn X and Y minutes where it’s just like a cheat sheet of all the things and awesome lists. There’s also really good documentation for Go like starting from Effective Go which I guess the echoes of like you know, Effective Java and all of those other things. But really good to review as somebody who like already has a background in programming like what might be considered good coding in Go.

It’s all pretty solid and also, it’s a bit more opinionated for the tooling as well.

[0:06:47.1] MN: Yeah, I think if I recall correctly, I had a project that had like a Go back end and it was pretty scary for me to jump in to add my new feature, you know #fullstack. But I had no idea what I was doing in Go. One thing was for sure is that it was like there was one way you do things and things are extremely opinionated. It will run a linter and everything is fine but like don’t try to go off the beaten path to do your own thing. Go won’t allow it.

[0:07:20.2] DA: Yeah, you’ve got like Go Lang, Go FMT, Go Test, Go Mod, they’re all like kind of built into it. You don’t have to think about it very much. It’s all kind of there and I remember when I first started, I had some like, linter complain about like, was like a stuttering. I had a module that was called ‘job’ and then I had like a thing I’ve defined in that module called job definition and it was like, “Hey, this name is stuttering. Because it’s going to be job.jobdefinition.”

[0:08:01.6] MN: My gosh.

[0:08:03.3] DA: It was like, “No, you can’t have that.” And then so I looked to see how I could disable this lint because I didn’t care. but there’s no way to disable it so I was like, “Fine, you win.”

[0:08:17.4] MN: Yeah bro, stop stuttering, get your speech together.

[0:08:23.3] DA: Really deep cut, you know?

[0:08:24.3] MN: Come on man. That’s amazing though, I imagine when you wrote that method like, you didn’t like think twice, job definition, that’s fine, that’s going to run the method I wanted to do and it’s like, “No, we don’t want that.”

[0:08:37.9] DA: Yeah, right. We have higher standards than you.

[0:08:42.9] MN: So, stop that right now. Change that definition, there you go, that’s crazy though, I didn’t know that linter went that far. I knew it was like they were spaces and stuff involved but like, checking out stuttering is like well, it’s pretty cool.

[0:08:57.7] DA: Go Format will also like, fix your spacing and I love that good stuff like you know, prettier and other awesome tools like Black for Python. But like, another thing that I don’t believe is configurable but you know, in the great like tabs versus spaces debate which I think we like kind of had one time and we kind of settled there, right?

It was like, “Okay, we generally like spaces.” But Go is like, “No, you’re using tabs now.”

[0:09:30.2] MN: Oh my gosh, that’s crazy!

[0:09:33.8] DA: Because it’s just you know, I guess more efficient and –

[0:09:37.5] MN: Wait, is tab less like bites taken because it’s a character and not like a space character?

[0:09:44.7] DA: I guess so.

[0:09:46.2] MN: Wow. Come on Go. What’s wrong with you?

[0:09:50.2] DA: More configurable. I don’t know. It’s a thing.

[0:09:54.4] MN: Yeah, I think this actually leads into a very interesting topic because Go compiles into machine code, right? Which is probably why it uses tabs because tabs is probably a character that takes less memory than like two spaces and it’s like, “No. That’s for you to look at as a person but computers don’t care. We’re going to change its tabs to make it easier,” I guess.

[0:10:22.0] DA: I don’t know.

[0:10:22.9] MN: It’s really interesting.

[0:10:24.5] DA: I mean, it’s compiled to machine code so like all those spaces and stuff, you know, doesn’t matter if it’s a space or a tab, it’s only going away in the end. because it’s not like you know, Python where, it’s a wide space significant like they use curly brackets because you know, if you love curly brackets in C then you’ll love them in Go.

[0:10:43.7] MN: Yeah.

[0:10:46.9] DA: I didn’t realize that like C, it’s actually compiled to the target architecture of your machine. So, if like if I compiled the code on a Mac then it’s targeted to a Mac versus a windows machine or whatever.

[0:11:04.9] MN: On a Unix machine, maybe even, what about like IOT devices also like what compile into those things?

[0:11:12.1] DA: Yeah, I guess so. I haven’t messed with that much but you know, it is something that like is a bit different like coming from a Java background where that’s like compiled to by code that you can kind of like plop wherever you need to plop it and it will largely work or something like Python where you don’t have to worry about hitting compile, it’s just kind of like, figured out on the fly.

[0:11:37.9] MN: Yeah. Java uses like the JVM and Python probably has like the interpreter that would run the app on the Python layer essentially.

[0:11:46.1] DA: Right. Also, kind of having some kind of virtual machine too but like, little more loosely goosey. Yeah, I thought you know, it’s compiled so it’s going to be slow. But it’s actually pretty fast, you don’t even really think about it. It’s more of the Docker builds that kill me and then let Go of stuff like you know Docker is just brutal sometimes.

[0:12:10.9] MN: I mean Docker is brutal for anyone who uses it for anything in this case. If you’re using a Docker right now, I’m sorry and I imagine that you are probably not listening to this are you are running a Docker instance because that would be crazy and your computer will be frying.

[0:12:28.2] DA: Oh yeah, thankfully I stopped Docker before we started recording otherwise my battery would be gone now.

[0:12:34.2] MN: Exactly. You would hear the fans revving up, my laptop would go to space. It’s it would be crazy. It would be crazy.

[0:12:42.6] DA: Yeah, we are doing like you were before, we are doing a remote recording and Mike was using the Zoom background feature, wow. So, the fans it would be in outer space.

[0:12:54.7] MN: Yeah, I had the outer space picture and I was going outer space. I think if we want to ignite another fight as we did before with tabs versus spaces, how does Go Lang deal with the composition versus inheritance? Is that a thing that is debatable in Go?

[0:13:13.8] DA: Like a lot of things in Go, I think they designed the language so that there are as few ways for you to shoot yourself in the foot as possible. So, they made a pretty strong stance against inheritance at all. So, there is really not any classes per say you just define interfaces. You can compose things with those inter like compose structures of data or struts. It sounds like very C.

[0:13:49.1] MN: Yeah it sounds pretty C.

[0:13:51.8] DA: But, yeah. So, you can’t do inheritance at all.

[0:13:55.6] MN: Is that even built into the language?

[0:13:57.9] DA: Yeah, not even an option.

[0:13:59.6] MN: Wow.

[0:14:00.3] DA: But using interfaces is pretty powerful and if you apply some design patterns with that then you can get pretty far without having inheritance. And it’s generally easier to test and reason about and sometimes you end up in a place where you have some duplicated code but that’s okay.

[0:14:22.1] MN: That’s okay. Yeah you try it later.

[0:14:24.9] DA: Right like another foot gun that is like a little bit controversial that Go took a hard stance against is how they handle errors. So, in most languages you can just throw an error and then you know just move on with your life, right? You don’t have to worry about what’s happening with that.

[0:14:47.7] MN: Yeah and Go if you throw an error there’s like the machine fry like what’s happening?

[0:14:53.6] DA: So, like in Python you can just throw an error and it could bubble up however many layers of a stack. Like it can go all the way to the top of the stack and you know crash if you don’t like to catch the error.

In Go it is actually not possible to implicitly have an error bubble up the stack because you actually need to find basically the error as a return value that you have to check. So every single time you call a function that returns a value or return error you are going to have a value and an error as a two pole that you unpack and you have to check the error to make sure it went okay and then you can proceed. So, there is bit of boiler plate around that but it is very explicit.

[0:15:48.8] MN: Interesting. So, there is like I guess also some strict ruling on how you handle errors as you mentioned before. You can’t just throw it and let the top of the stack give you out of bounds exception or some craziness for example. When you have an error like you have to – if your method can return an error then you have to deal with it right then and there.

[0:16:13.0] DA: Yeah, you can ignore it also. But like you just – the program has to be correct and that’s all it is. You can still cause the system to die if you call a panic. But that’s going to be a really explicit choice from you. And you know, returning an error is not going to cause that to happen.

[0:16:37.1] MN: Right, ignoring errors that is what I do every day in life. Just let it go.

[0:16:42.1] DA: Just catch them and pass.

[0:16:43.3] MN: Just catch them. Throw it away. Don’t worry about it. Life goes on. I know there is a thing called Go routines and I think that people who use Go often say that Goroutines are awesome. Do you know what is a Goroutine?

[0:16:59.1] DA: So basically, a Goroutine is a concurrency primitive. So, like in Java you would have a thread and manage those threads in a thread pool and if they are sharing memory, you’d have locks and mutex and things like that. Those are all concurrency primitives in Go like if you want to do something in an asynchronous way then you have a key word ‘Go.’ Literally just Go and then you call any function and then that function goes off into its own happy place and executes asynchronously.

[0:17:42.2] MN: Oh, wow and this could be applied to any function that you write if you put Go in front of it then it knows that that function runs asynchronous?

[0:17:52.9] DA: Yeah and it is going to take care of managing the memory as well for that and it will also manage the pooling of threads and processes and things like that. So, in Python if you want to do lots of processing, you have the global interpreter lock in the one thread. So, you can actually hit one instruction at a time. So, you would often scale up to be multiple processes. But you’d always have to be very explicit about that or use a framework that would do that for you. Whereas in Go, it is going to use both threads and processes and manage that like for you so you don’t have to think about it.

[0:18:43.1] MN: That sounds amazing. I think as you mentioned before if you love this feature in C, you’ll love this in Go. It’s probably one of those examples of that where memory management is like handled for you and you run these Goroutines.

[0:18:56.8] DA: Well yeah, I mean I think that is like the one thing in C that is really painful and it is the memory management aspect because it is not garbage collected. You have to do Malex and collect the memory back and worry about if the pointer that you have is actually pointing to the right thing that makes sense. So, Go is garbage collected, so it has a lot more modern like comfort of not having to think about like grabbing so many bites for a string or for an integer or whatever.

But most things by in default in Go are going to be values instead of pointers, more like references. So, like in Python most things are objects which are tracked by reference. So, you really just like passing references around everywhere. If an object or whatever it is, modified then that is going to carry over and mutate everywhere. There is some complexity around that with pooling of constants and values like integers and strings and whatever that you know it could be so you know talk but like –

[0:20:14.6] MN: Yeah that’s a tall think.

[0:20:15.8] DA: But the main thing is that when I pass something that looks like an object by default it is going to copy all the values over, which nudges you more in the direction of like memory safety even though it could be a bit of an overhead to copy something that’s really deeply nested. But it is more safe if you give a copy of all that memory to your asynchronous process than if you share memory. Because if you share memory you have to worry about mutexes and locks and all that stuff.

[0:20:54.8] MN: Yeah, I guess just like Go is one less shooting of the foot to be able to maintain all of that for you. But as they do that you as the developer has to keep up with best practices so that you don’t like end up copying multiple nested objects and whatnot.

[0:21:15.2] DA: Right.

[0:21:16.3] MN: When you’re building something. So, Python has the snake and Ruby has the big red gem.

[0:21:24.6] DA: Oh, big money.

[0:21:25.6] MN: Yeah, the big money. Go has a gopher, is that derived from anything or?

[0:21:33.1] DA: I have no idea. I mean it’s really cute. I don’t often see people with like big red gems or snakes like plush snakes that they are hanging out with because they really love Ruby or Python. But I started like following like the Go Lang sub-Reddit and people love that gopher like everybody has this little plushy gophers and it’s so cute.

[0:22:00.5] MN: Yeah, he is a pretty cute little gopher. I always thought that part of the reason why there was the gopher is because of the way you assign variables is like the colon equals that looks like the eyes of the gopher and the teeth afterwards. It’s like you are constantly writing the gopher on your code, which is pretty dope.

[0:22:19.5] DA: Oh man. I didn’t think about that but now I feel like I am going to see that like they just did a PR or a big change for Python to amp this operator. The colon and equals but they are calling it like a walrus, maybe they are trying to avoid the copyright infringement or something.

[0:22:38.3] MN: Yeah because that looks like a walrus too with the big teeth and the equal sign maybe. And that is a thing.

[0:22:44.6] DA: I like that idea of being a gopher that is popping around your code.

[0:22:47.9] MN: Yeah so, it’s just all over the place being the signs and different variables and boop-boop-boop gophers everywhere.

[0:22:54.5] DA: It’s just very busy.

[0:22:55.6] MN: Yes so if you are out there and you are listening to this thinking about a programming language to learn, it seems like Go has a lot of I am going to say like guard rails to keep best practices in a compiled machine co-programming language that sounds pretty good. I mean like I said before it is the compiled programming language of the people. So, I got to spread that around.

[0:23:19.9] DA: What does that make C?

[0:23:22.8] MN: I mean I don’t – it is your worst nightmare? I don’t know though.

[0:23:26.3] DA: That is not for the people.

[0:23:27.5] MN: It’s not for the people. It is definitely not for the people unlike Go. Go is for the people. Cool, there you go.


[0:23:33.0] MN: Follow us now on Twitter @radiofreerabbit so we can keep the conversation going. Like what you hear? Give us a five-star review and help developers like you find their way into The Rabbit Hole and never miss an episode, subscribe now however you listen to your favorite podcast. On behalf of our producer extraordinaire, William Jeffries and my amazing co-host, Dave Anderson and me, your host, Michael Nunez, thanks for listening to The Rabbit Hole.


Links and Resources:

The Rabbit Hole on Twitter

The Go Programming Language


Haskell Language


Rob Pike

Robert Griesemer