The pleasure of writing Go

Published on 12.09.2021

These are some just random thoughts about writing Go, the post has not been reviewed.

As a developer, I had always to deal with programming languages such as C and C++. Writing programs (especially programs designed for Web) was not an easy task. In addition to the tricky memory pointers arithmetic, you have to setup your own library manager to manage external dependencies.

HTTP server is not included in C++, neither in C. With Go, stdlib, the set of standard libraries included by default, has its own HTTP server and the first attempt to run it I was impressed. Go server is stable and does not require any particular configuration. An HTTP server for C++ probably requires some hours of “what library should I use” and you have to take carefully this choice since not every library is production-ready.

You might notice that even Node.js and Python have their own HTTP servers and you do not need to mess around to run them. However, the main difference between Python/Node.js and Go is how you write the code you’re going to execute.

In Python, everything must be indented with 4 spaces. It was a great idea…. or not? I think probably it was one of the worst idea to apply in the development industry. Not even TABS! It’s literally impossible to have a consistent indentation, especially when you have more than 2 nested loops/functions/switch. Better to clarify: it was not easy for me, a beginner developer that studied C/C++ for most of his career. Fortunately, Python and Go removes colons by default at the end of every expression. To quote someone, “Semi-colons are for compilers, not for human!”.

Some features of Python (some tricky codes, such as swapping false to true and true to false) are fun to play around with but, as most programmers will agree, they often make the code harder to understand when reading someone else’s work. Go forces you to stick to the basics. This makes it very easy to read anyone’s code and immediately understand what’s going on.

Regarding Node.js I can not even express how many GBs it takes to manage, install and update dependencies. Node.js is really huge and I do comprehend the Javascript syntax, with the consequence of having an headache. Go is light, fast and managed the dependencies in the way I want, as smooth as possible, without warnings.

Go is extremely fast. The performance is similar to that of C++. For our use case, Go is typically 10 times faster than Python, and 40 times faster than Node.js (although for Fakturo we could even reach 50 times faster than run-time executed programming language).

Go is typically better for people who already know how to code and want to add another programming language to their arsenal. As Go FAQ reports, it was created based on existing problems Google engineers had. It was built to be better by comparison to many other languages. No weird conversions about types at run-time, no tricky pointer arithmetic, no leaks. You could easily kill one half of 0day industry with these features (joking, but I would like to expand this discourse – drop me an e-mail if you want to discuss about it).

Go has a cleaner linguistic structure with a more tight arrangement of libraries. It’s useful for coders who need to turn out to be more useful with a less swollen linguistic structure. Also, it is worked to increase to colossal tasks, any semblance of which Google was trepidatiously looking back in the noughties when they were fostering this language.

Definitely, if you wish to write an elegant software for 2021, with modern and minimalist ideas, you must choose Go. I promise, you won’t regret it.