At some time in every developer’s life, they reach a point where they just want things to work. No long workarounds, no trade-off, and no endless stream of rewrites that will keep them awake for hours on end. We recently arrived at this point. Thus started our search for a simple yet effective language that just works.
This is not to say that current fan favorites like PHP and Java are obsolete or no longer useful. Along comes Golang, an open-source programming language by Robert Griesemer, Rob Pike and Ken Thompson from Google in 2007. Then going open-source in 2009, and finally having its first stable release in March 2012.
Why choose Go for your next project?
When it comes to writing web applications, We needed something that was expressive, concise, clean, and efficient. This, in a nutshell, is what Go is. Not only does it compiles quickly to machine code but it also has the convenience of garbage collection and the power of run-time reflection.
However, a fast compile time isn’t its call to fame. That would be its concurrency mechanisms make it easy for developers to write programs that efficiently utilize multicore and networked machines. At the same time maintaining a flexible and modular program construction.
Let’s break things down. Why choose Golang? Why is it that Golang is such a good fit for development? What features make it stand out from the pack? To get to the bottom of this, let’s dive into what makes Go unique.
Simplicity is at the heart of Golang. This means it compiles fast, runs fast and it's also fast to learn. Also to speed things up, there are no type inheritance and classes. This makes it easier for you to develop a product that is ready for the market in record time. Plus its ease of use allows for quick and easy maintenance.
But the performance benefits don’t just end there. As Golang doesn’t have a VM (Virtual Machines) it can compile directly to machine code, if you can exclude Go’s intermediary assembly, which gives it even more of a speed advantage. Throw in cross-platform compatibility and you are good to go.
This is not to say that in a comparison of speed, Go would come first if placed side by side with every other coding language out there. It does, however, have a place in the top 5.
For the uninitiated, concurrency, by simple definition, is when a program is able to decompose into parts that can run independently of each other. This allows for tasks to be executed out of order but the result would remain the same as if they are executed in order.
In other words, it allows for an algorithm or program to run more than one task at a time. This concept is similar to that of parallel processing, but instead, we have many independent jobs doing different things at once rather than executing the same job.
Concurrent programs have always been difficult to write simply because managing independent tasks requires the coordination of multiple resources. With new multi-core processors becoming more powerful and readily available - plus the team behind Go making concurrency one of the main points of its development - This makes Go a very good fit for utilizing all that processing power.
Let’s not forget that using in-built tools like goroutines is quite easy and works great. Plus there are other tools within Go that are targeted at making ample use of concurrency. It is one of the main reasons why Go does so well in writing HTTP servers.
Every good developer needs a good garbage collector. All that grunt work that is very tedious but necessary is done for you without having to mind or focus on it.
Go has a fast garbage collector. It helps with the development of fast running programs by making sure your system’s memory isn’t full of… well, garbage. It vastly improves the performance of any application.
Cross-platform and Easy to Maintain
Regardless of your platform of choice is Windows, Linux, macOS or others. Many of the functions that you might think are difficult or problematic to handle across various platforms are a cake-walk for Golang.
Go has in-built features that specifically take cross-platform compatibility into account. Let’s not forget that Go also has a few features that help with the maintenance of clean code. Go fmt formats the code and helps with its readability. It also has built-in testing functionalities.
All is not roses and sunshine with Golang. After extensive use, We started to notice a few drawbacks with the language. Here is a shortlist:
- Over-simplified: Sometimes a little complexity is a good thing as it allows you to handle more demanding tasks and situations.
- Still has a way to go in its error-handling capabilities
- There is an absence of manual memory management
- Still under-development. As a relatively young language, Go still has a way to go before it can be said to be matured. But with such a large corporation behind it, we don’t see this as a major issue.
- Some other issues include operator overloading, some problems with code duplication and metaprogramming due to the inability to statically check them.
Companies Using Go
As Go(lang) was developed by Google, it is not surprising to note its widespread adoption within the organization. Several Google services such as Youtube use Go. plus dl.google.com the source for Chrome, Earth, Android SDK, and other large Google downloads were rewritten in Go.
Then you have Uber who needed to expand and required that their solution grow accordingly. Hence the implementation of Go into their services such as Geobase.
A more comprehensive list can be found here.
On a side note, we found that using Go(lang) on AWS Lambda was surprisingly easy and yet powerful. It would seem that the use of Go in AWS Lambda is a match made in heaven.
How does it stack up against others?
After using Go we found it hard to go back to using other languages previously familiar to us. This is not because Go is fundamentally better. But due to its ability to work well in the tasks, I needed the most. When it comes to backend and cloud coding, it’s like a heaven-sent language that saves loads of time. This brings us to its strong suit and its use cases.
At this point, I can say my experience with Go(lang) has been an eye-opener and one that was very thrilling. Go surprise me with its flexibility, ease of use and speed with which I could get things done. So my takeaway is this. If you are building your next great project and you want something that can scale with your app’s growth, is secure and easy to manage, you might want to consider Golang.