From Python to Go: One Programmer’s Learning Path

Alfredo Deza
Anchore Engineering

--

If you know how to operate a blender, you can probably figure out a food processor. Plug it in, add some ingredients in, remember to secure the cap, and turn it on at the desired speed.

Programming languages follow a similar learning pattern. If you know how to assign variables and loop over a list of items in one language, it isn’t that different to do the same operation in other languages. Programmers can apply most of the concepts in the same way.

Ready, Set, Go

In March, after years of doing mostly Python, I was tasked to dive deep into Go (also known as Golang), a programming language that I had never worked with before. Jumping into new things and learning usually excites me, but this was a trickier situation. There was a deadline involved, a large amount of work, and the programming language has concepts that I have never been exposed to before.

At first sight, both are very similar. For example, this is how you would do a loop in Python:

for item in [“one”, “two”, “three”]:    print(f”I’m processing: {item}”)

And this is how you do it in Golang (omitting imports and function declarations for brevity):

for _, item := range []string{“one”, “two”, “three”} {  fmt.Printf(“I’m processing: %s\n”, item)}

I’m used to operating household blenders, and this food processor is for an industrial kitchen of the future. In fact, I had to fix this example three times before writing about it because I still managed to get it wrong.

The learning process is a hard one. It takes a fair amount of determination and not getting discouraged. Sprinkle that with deadlines and lots to do in the backlog, and it can be intimidating. Luckily for me, I was able to pair the whole time with Alex Goodman, who has an infinite amount of patience and would point out at rough corners of the language.

After the first couple of weeks, it was apparent that using my plain text editor was not going to work well. A good friend suggested I try out an actual IDE (Integrated Development Environment) to help me out. An IDE is a great way to get suggestions and catch errors as you type, which I couldn’t get with a plain text editor.

I wasn’t looking forward to adding “learn how to use an IDE” to the pile of things I had to figure out. Still, I’m glad to say I was proved wrong, and using an IDE significantly accelerated my knowledge (who wants to be corrected on the same mistake all day long?) and efficiency.

Another positive side-effect of the IDE is that Alex and I were both using VS Code. By using the same IDE, we were able to have a few pair programming sessions using the Live Share extension. This extension allows both programmers to be in the same IDE session and code simultaneously.

Embracing the unknown and not letting previous ideas or concepts block the learning process are good strategies that helped me pass the initial knowledge shock. Asking around to knowledgeable people was also great and helped me go faster (pun intended).

Online Resources

There are a few resources that have helped me along the way. Although this list is not comprehensive (and I still have lots to learn), it helped me improve my understanding of Golang:

Go Playground: For trying out different things about Go, online, without any sort of setup. Sharing code snippets included.

The Go Blog: For examples and explanations on different aspects of the language. For example, I bookmarked the section on modules.

Go by Example: Want more examples? This is it!

The asterisk and the ampersand: Coming from Python, I had lots of trouble using `*` and `&`. This article explains it really well.

And finally, VSCode support for Golang with the LiveShare Extension.

--

--