Why Do I Love the Go Programming Language as a C++ Dev?
Last months I have been writing a lot of Go, and I have to admit it — I am in love. What is so great about the language? Let’s see.
Golang Is Array-Centric⌗
If you are good with arrays, you are good with Go (kind of). The default way to do anything is to use a dynamic array, not a list. A Go slice is very similar to std::vector.
It’s Still Very Fast⌗
Yes, Go does have garbage collection. If I need something real-time, or something very performance-critical, I will always choose C or C++. However, Go is faster than a lot of other general purpose languages.
Distribution and Tooling⌗
Do you want to build a command-line tool or GUI that your team, or maybe other teams, will use? Tools like these are often written in Python or C#, but how do you quickly distribute a Python tool? Just send the .py file? Well, then everybody has to have a Python environment. What if the user of a tool is an artist? You can compile Python to an .exe, but the file size will be huge. Go compiles to an executable just like that, and it works on any platform. If you build a tool with Go, you can easily redistribute the .exe across the team.
Go is still fast. If you build a tool, Go will handle it nicely. Things like validating a mesh with a graph, generating a normal map, iterating over files, and performing checks – it all works flawlessly in Go.
Very Productive⌗
This language is so fast to write, I like prototyping with it. Many C++ developers choose Python as their second language. It is a great option too, but Go is more similar to C. I personally find writing it much more enjoyable than Python. The downside, however, is the lack of packages. Go has a big ecosystem, but it cannot compete with Python in this regard. Python has a package for everything.
Go Has Pointers!⌗
They are limited, but it’s a nice feature. You cannot perform pointer arithmetics, but you can decide whether to pass things by reference or by value.
Fast Build Times⌗
For the most part, it doesn’t really matter. C++ has long build times, but most C++ developers have powerful machines. However, Go’s fast build times are great when you build in the cloud. Even on a weak VPS, a project can build in just a couple of seconds to a minute. It’s great!
The Power of Simplicity⌗
Go is minimal. There is something beautiful about it. It really fits the coding style I have been enjoying lately – keeping abstractions to a minimum while still solving the problem. Sometimes, before implementing another Curiously Recurring Template Pattern, or creating virtual functions, it’s good to ask yourself: Maybe this should be just two functions? Sometimes it’s just okay to change the code later. Avoiding over-engineering is beautiful. Sometimes, when there are layers upon layers of abstraction, it’s hard to realize what the code is truly doing.
I Like C⌗
It’s just cool. Go is similar to C, but it’s much faster to write. It is slower to execute, but that is ok for a lot of software.
Summary⌗
Go is a really nice second language for me. If I need to code a tool quickly, I will do it in Go. A website? Go. Go, Go, Go. I like Go. You get the point.