2020-05-21

In recent years, one language in particular has grown a lot: GoLang, or simply Go. After all, what excites a developer more than a new language? S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶ ̶J̶a̶v̶a̶s̶c̶r̶i̶p̶t̶ ̶F̶r̶a̶m̶e̶w̶o̶r̶k̶s̶
I started studying Go due to Kubernetes projects at Getup Cloud and later at QueroQuitar thanks to the great encouragement I had there to learn new things. Anyone who loves programming is always excited about new frameworks, solutions, libs, OSs, etc…
That’s how, together with Guilherme Caruso , we decided to create Gommunity . By the way, if you’re just starting out, his Goschool series was made especially for you.
There are good articles explaining Go on the internet and on Gommunity, so in this article we’ll talk a bit about the current moment and why you should learn a new language.
We can’t add more cache to the processor to increase performance, as cache has physical limits: the larger the cache, the slower it gets. Adding more cores to the processor also has its cost. Moreover, this can’t scale forever.
If we can’t rely on hardware improvements, the only path will be more efficient software to increase performance. But unfortunately, modern programming languages are not very efficient. E̶x̶c̶e̶p̶t̶ ̶P̶H̶P̶,̶ ̶t̶h̶a̶t̶ ̶o̶n̶e̶ ̶i̶s̶ ̶s̶u̶p̶e̶r̶ ̶p̶e̶r̶f̶o̶r̶m̶a̶n̶t̶.̶

Without the possibility of expecting hardware to scale forever, the software we develop and the programming languages we use must easily support concurrency and must be scalable with the increasing number of cores.
However, most modern programming languages (like Java, Python, etc.) are from the single-threaded environment of the 90s. Most of these programming languages support multi-threading. But the real problem comes with concurrent execution, threading-locking, race conditions, and deadlocks. These problems make it difficult to create a multi-threaded system/application in these languages.
On the other hand, Go was released in 2009 when multi-core processors were already available. That’s why Go is built with the intention of maintaining concurrency. Go has goroutines instead of threads. They consume almost 2 KB of heap memory. So you can run millions of goroutines at any time.

A considerable benefit of using C, C++ over other modern higher-level languages like JavaScript/Python is their performance. Because C/C++ are compiled and not interpreted.
Processors understand binaries. Usually, when you build an application using Java or other JVM-based languages and compile your project, it compiles human-readable code into bytecode that can be understood by the JVM or other virtual machines running on the underlying OS. During execution, the VM interprets these bytecodes and converts them into binaries that processors can understand.
Human-readable code -> VMs -> Processor
However, C/C++ does not run on VMs and this removes a step from the execution cycle and increases performance. It compiles human-readable code directly into binaries.
Human-readable code -> Processor
However, freeing and allocating variables in these languages is a pain. While most programming languages handle object allocation and removal using Garbage Collector or Reference Counting algorithms.
Go brings the best of both worlds. Like lower-level languages such as C/C++, Go is a compiled language. This means performance is almost closer to lower-level languages. It also uses garbage collection to allocate and remove objects. Therefore, no more malloc() and free() statements.
With a simple and lean syntax, Go is delightful to program in.
The Go designers at Google thought about this when they created the language. Since Google has a very large codebase and thousands of developers were working on that same codebase, the code should be simple to understand for other developers and a block of code should have minimal side effects on another block of code. This makes the code easily maintainable and easy to modify. Go intentionally leaves out many features of modern OOP languages.
The above changes make Go very different from other languages and make programming in Go different from other languages. You may not like some of the points above. But, it’s not like you can’t code your solution without the above features.
Those who know me have already seen me grumbling about having to write for to filter.
Do I miss the ternary operator? Yes :(
Unlike other new languages like Swift , Go’s syntax is very stable. It has remained the same since the initial public release 1.0 in 2012. This makes it backward compatible.
Although Go is very different from other object-oriented languages, it’s still the same thing. Go provides high performance like C/C++, super efficient concurrency handling like Java, and fun code like Python/JavaScript/Kotlin.
If you have no plans to learn Go, I’ll still say that the hardware limit pushes us, software developers, to write super efficient code. Developers need to understand the hardware and optimize the program accordingly.
My next project will be developing a solution in Go for my Raspberry Pi 4, I’ll tell you about it here soon. In the meantime, see you soon, future little marmot who read this text.