The following article is part of a series of articles about our NerdWallet Internship program. Alex Sanchez shared their experience as an software engineer intern. If you are curious about joining NerdWallet as an intern or full-time employee, please apply for one of our open positions!
The Go (also called “Golang”) programming language was first released by Google in March 2012. It is open-sourced, statically-typed, and compiles into machine code binaries. Similar to C, Go is known for its speed; however, it also enjoys many of the typical features found in other modern languages such as garbage collection and safe memory management. Furthermore, its ease-of-use and simplicity lowers the barrier to entry for large development teams looking to get started with the language. As such, Go is becoming increasingly popular and many believe it will one day be among the most important programming languages in the industry.
Here at NerdWallet, we have traditionally used Python for our backend services. Somewhat recently though, we have begun to incorporate Go into our stack. As a second-time intern, I have gained some experience in both languages.
The rest of this blog post will discuss some interesting things about Go and how it differs from Python:
1. Go is fast!
Like C/C++, Go is a compiled language. Once Go code is compiled into machine code, it can be run directly on the target machine’s processor. In contrast, Python is an interpreted language. Python has its code translated to bytecode, which is then processed by an interpreter program at runtime. This adds “extra steps” that take more time for instructions, originally written in Python bytecode, to be run on actual hardware. As a result, Go is much faster than Python.
2. Concurrency is easier than ever!
Go was specifically built to be used in large-scale server environments and big distributed systems. These both require many processes to be run on many cores. It is no wonder then that Go was designed with a focus on easy-to-use, fast concurrency. Go uses lightweight “goroutines” instead of threads that are managed by the go-runtime. Any function ‘f ’ can be called as a goroutine by simply using ‘go f()’, and the code will begin to run asynchronously. Go even has race condition detection implemented to help catch common concurrency bugs.
3. Go is opinionated!
Python is a very permissive language: it is dynamically-typed, has little-to-no error checks before executing, and allows all kinds of interesting ways to complete standard tasks. On the other hand, Go is much more strict. Not only is Go statically-typed, but it will impose its best practices on you. For instance, public functions must be capitalized and unused imports are compile-time errors! In addition, Go generally tries to make it obvious which approach should be taken for common problems, making the language very straightforward to use. As a result, Python is considered to be more flexible, but a codebase written in Go will likely be less error-prone and more consistent over time.
4. Go has its own built-in testing framework!
While other languages often require a third-party testing framework to create standard unit tests, Go has this feature built in. Developers simply import the “testing” module in their test files to easily create tests for their application. Tests can then be run from the command line by simply using the ‘go test’ command. Tests are kept efficient and clean, and having a readily available built-in testing framework makes programmers more likely to write tests in the first place.
If you would like to read other articles about the Go programming language, try the following:
- Why Use the Go Language for Your Project? — Written by Victor Osadchiy
- Reasons Why Golang is Better Than Other Programming Languages — Written by Juned Ghanchi
- What is Golang Used For? Exciting Features and Advantages — Written by Nadiya Dubyna
To start learning Go, try https://tour.golang.org/welcome/1 – It’s a great intro to the language and all online!