With finals wrapping up, now is the perfect time as a college student to try GoLang (Go) — Google’s programming language they released in 2009.
I started writing Go a year out of college and couldn’t believe how quickly I picked it up, especially compared to other languages (…Scala). Mainly, I was excited by Go because it was based on C, had simplified syntax and program structure while still scaling to modern development practices, and had an excellent developer community.
So if you have some spare time in between classes and work (or even if you’re done with school and just interested in something new), I’ve compiled the five experiences that I enjoyed the most as I got started in Go.
1. It felt like I already knew it
“It must be familiar, roughly C-like. Programmers working at Google are early in their careers and are most familiar with procedural languages, particularly from the C family.” — Go at Google, Rob Pike
Have you taken a class in C? You likely have, because Computer Science academics worship it. How often did you curse it in operating systems? (every day? no?) It’s wonderful that it’s fast, but wouldn’t it be nice to have something that causes less pain? I constantly thought this and I spent three internships getting paid a good amount to write C and C++ on embedded systems like sensors and night vision goggles. Even a steady paycheck couldn’t mask all of the pain using it.
Go seems to have that in mind. There are still pointers, but you do not have to manage memory. A lot of the “shoot yourself in the foot” scenarios talked about in C/C++ are gone. A comparison of keywords from different languages (which doesn’t give the full story of language complexity, but certainly has some value) shows:
- C++ — 84
- Pascal — 54
- Rust — 52
- Java — 50
- Scala — 39
- Python — 33
- C — 32
- Go — 25 ❤
In fact, the entire Go specification can be printed on 40 pages! There is nothing quite like a languages conversation where you can pull the entire spec out of your backpack. (I promise this isn’t as weird as it sounds…)
But what if C or C++ still gives you nightmares? No need to be afraid — it turns out you’re in great company:
“The three of us [the founders] got together and decided that we hated C++.” — Ken Thompson
2. I was tired of Diva Code
“If a language has too many features, you waste time choosing which ones to use. Then implement, refine, possibly rethink and redo.”
— Simplicity is Complicated, Rob Pike
It is fun to write code without concern for who reads it after. But a lot less fun if you’re on the receiving end of that code — which has happened to me at plenty of jobs. It’s particularly frustrating when you think you already know a language, but then find out that the Programmers Of Old had entirely different ways of programming than you. I’m sure they had loads of fun using reflection in their uncommented metaprogram at the time…
Maybe you’re not about that diva coding style. Fortunately, Go isn’t either.
Gofmt ends the tabs vs spaces argument. Testing and documentation are built into the language. Instead of having arrays, lists, queues, vectors, stacks — there are arrays where size cannot be changed, and slices for a dynamic data set. Instead of a for, while, and do loops — there is only a for loop (that handles while and do cases). Instead of hashmaps, hashtables, collections — there is one map for you to use. Code readability is exponentially improved as you no longer have to translate the specific programmer that came before you.
3. Torture by Absurdly Massive Projects™
“It must work at scale, for large programs with large numbers of dependencies, with large teams of programmers working on them.” — Go at Google, Rob Pike
Have you ever heard the complaint that it takes an intern the entire internship to understand how the project works, and then they go back to school? I’ve experienced projects like that. This can be an outcome of diva programmers, but could be due to language norms too.
It’s never fun to dig down 20 nested folders of various classes and configuration files to try and understand what the code is about. It’s also not very fun to look at 8000 lines of PHP in one file. Reading through the Go project gives a great example of how the source code is broken up into reasonably sized packages that contain files averaging around 500 lines of code. I looked through the net/http, encoding/json, and io packages (three that I often use) and their average file length was 509, 546, and 266 respectively. Additionally, built in testing and documentation really help keep AMP syndrome in check.
This is a big reason for why microservices are taking off right now — they are much easier to understand and maintain. Go’s built in best practices really compliment microservice concepts.
If my internships had their code structured like Go, I imagine I would have been productive in days instead of months!
4. Modern development is easier
“It must be modern. C, C++, and to some extent Java are quite old, designed before the advent of multicore machines, networking, and web application development. There are features of the modern world that are better met by newer approaches, such as built-in concurrency.” — Go at Google, Rob Pike
Tech loves buzzwords, and they seem to be everywhere with all of the changing architecture decisions today. I had a hard time understanding what “everyone” was talking about until I could try them out for myself, and Go made that transition a lot easier (compared to when I was trying to learn it all in Java).
- Open Source First — Go is a very open language, and your go environment is set up to easily track where you are sharing your code. (src/github.com/yourusername/repos) There is even a go get tool to pull down other packages.
- DevOps — Go compiles to a binary, and you can specify the platform. Do you need to run your program on a linux/mac/windows machine? No problem, so you can understand why devops teams around the world embrace the langauge
- Concurrency — I have rarely felt as much joy as when I wrote three characters ‘g’,‘o’,‘space’ and now had a concurrent program. If concurrency makes you a little nervous, but you want to learn it, Go is for you. It is a huge benefit to know that with a quick goroutine you can exponentially increase the performance of your program.
5. Excellent Community
On a scale of 1–10, how much do you enjoy your college group projects? The rush of everyone having interesting ideas when you brainstorm, only followed by no decisions being made, and then either one person does everything or there is a huge rush right before the deadline — inspirational.
Without clear decisions being made for a language, it can end up similar to those doomed projects. “Do all the things!” sounds really great in an open source project. Turns out that’s an anti-pattern for almost all real work.
On top of that, the community is the most welcoming programming groups I have been exposed to. If you join the gopher’s slack channel (which you really should!) you’ll find so many helpful Go programmers. William Kennedy, Dave Cheney, Brian Knox, Luna Duclos, Brian Ketelsen, and Damian Gryski are only a start of the people I’ve seen around willing to help developers of all skill levels. I did a lot of PHP development when I was graduating college and it certainly would have been nice to have a community like Go’s back then!
(tip — I’ve heard that GopherCon is one of the greatest conferences to go to and it’s coming up in July! I haven’t been yet, but I’m hoping to go this year.)
This is the shortest list I could make of why I think someone would enjoy learning Go right out of school. If you want to get started, I think tour.golang.org is the best place to get a feel for the language (and it’s so fun to use!). After that, Dave Cheney’s list is my next favorite place to go. Some cool projects for getting started could be making a wiki site, building an API, or creating a chat bot, just to list some things I’ve thought were cool.
If you have any questions while getting started, or want to talk about various API development tools, The Go Programming Language book, starting a new project, or really whatever else crosses your mind, I’d be glad to help however I can! (hmu on twitter, in the gopher’s slack, or in HH Gophers)