More than 10 years ago, Marc Andreessen penned his famous quote “software is eating the world” in his article “Why Software Is Eating the World”.
If we think about it, at the present day, the idea that “every company needs to become a software company” is considered almost a cliché. From lifts to home appliances to cars to airliners to smartphones, modern civilisation is powered by software. But to create the software you need to write a code.
Programming languages rise and fall in popularity over the years, depending on their complexity, how well they perform and how their adoption is affected by big shifts in technology.
If we were to commence a conversation about a programming language, most certainly 3 languages would take the stage: Phyton, Java and Javascript. After all, they are the most popular programming languages according to the survey made by Stack Overflow.
Notwithstanding that there are hundreds of languages for a developer to choose from, there is a programming language that has exploded in popularity, and it's used in huge open source projects, like Kubernetes, HUGO, Docker, Prometheus and Terraform, which is Go Language (aka Golang).
In this article, I will be explaining more about this language. What is Go exactly? How does it compare to other programming languages? What problems does it solve? What is their Unique Selling Proposition?
Nevertheless, before you make any hasty assessment about it, bear with me a bit and let’s first take a quick overview of this programming language. After we will see the advantages and disadvantages regarding Golang and if you should use this language on your next project.
If you are not new to this language you can go ahead and skip to the boon and bane of Golang. ;)
- What is Golang?
- Benefits of using Golang?
- Disadvantages of using Golang?
- Differences between Phyton and Golang?
- Should you use Golang on your next project?
What is Go (aka Golang)?
As it is written on their site: Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
In 2007, 3 engineers from Google (Robert Griesemer, Rob Pike, and Ken Thompson) frustrated by some of C++’s inefficiencies and overcomplicated nature, designed the Go language, which would work better for Google’s workflows.
Their goal was to build an improved C++ that was much easier to use (Go is very similar to C’s disciplined syntax) while at the same time having some of Python’s simplicity and Javascript’s useful features.
In layman’s terms, Go was created to simplify the process of software development, particularly for complex architecture and processes.
Benefits of using Go?
Let’s be honest with each other, experience suggests that a programming language is good if it helps us write programs which are:
- easy to read
- easy to understand
- and easy to modify
And Go checks out all of those boxes!
Coming from a company like Syone, the fact that Go is an open-source project is simply the icing on the cake. Nevertheless, Go is expressive, concise, clean, and efficient. At least that is their USPs.
However, I’ve realized that there are a bunch of mixed feelings regarding Go in the developer community.
After talking with some of my colleagues at Syone, who are currently using Go in their projects, I noticed that the most common comment was “in the beginning, I wasn’t enjoying it but now is slowly growing on me”
What I truly noticed is that some people love Go for the same reasons some people hate Go. What seems right for one individual, may not work with the others.
This is not a surprise.
Getting a bit philosophical now, but as you may know, we still live in a society where the mindset is conventional. You pick what works for you. Undeniably, being able to see it from different viewpoints only enriches your understanding.
Hence, that is exactly what we will do here. Enrich our knowledge regarding Go by looking at it from different viewpoints.
What I will state here will be merely the benefits that our developers here at Syone experience by programming in Go.
Go is Fast
Quick compilation and fast execution. One of the main reasons why Go was developed was with the objective of achieving compilation efficiency. Golang is a compiled language, which means the code written is directly translated into processor-understandable formats with rapid build times. Nevertheless, it is important to mention that this also means that the error messages that the compiler generates are not always the most useful. Especially when the error is a syntax error.
Easy to learn
Go is not only fast and efficient for computers, but it is also fast for humans to learn. It was designed to create the simplest code. Also, since it only has a slightly different syntax and keywords, it is very clean as well as very easy to read for any developer. Go offers beautiful, straightforward code, thus “it is easy to write”.
Garbage Collection
Since Go has automated garbage collection, it manages all your memory for you, and it does it in an exceptional way, allowing you to focus on other things. However, it is worth mentioning that for some developers here at Syone, garbage collector in Go is actually a detriment rather than a benefit.
Static Typing
Golang is a statically typed language, but with a feel like dynamic typing. Static typing allows developers to code more efficiently by making it easier to work with relational databases. It also helps developers to catch type mismatches sooner at compile time and it reduces the likelihood of errors. Moreover, by making static typing feel more like dynamic, what Golang manages to achieve is the removal of the old trade-off between the higher productivity of languages like Python, and the increased safety of languages like Java. It is noteworthy that the compiler has a good ability to infer the types of variables without the programmer needing to specify them manually. That actually makes life a lot easier when you need to make changes to variable types. And this is the reason why Go looks like a dynamic typing language even though it is a static typing language.
Compile Binaries Statically
Another great aspect about Go is that it allows you to compile go code into a statically linked binary. Moreover, Go also offers the possibility of cross-compile, this basically means that from an architecture/platform you can generate a binary for another environment. A good example would be to compile a binary that would run on a Linux server from a Windows machine.
Power of the Community (aka Power of Open Source)
If I can just put in my two cents' worth, I think this is the best benefit of Go Language. Have you heard the old African adage “It takes a village to raise a child”? Well, the fact that a project is powered by the community (i.e. open source) it normally means that it has the best chance of growing into a successful ecosystem. This is exactly what is happening with Golang, and the best example I can give is regarding Generics.
As it is stated in Go’s blog, for many years all the developers lambasted about the lack of Generics in the language. This was a huge obnoxious hurdle to get over when coming from other languages like Java. Nonetheless, amid so many criticisms, on January 12th of this year, Go published an article on their blog stating that they will be bringing Generics to Go. What this shows is that, even though Go is a relatively young language and is powered by Google, the community still has a big weight in it, and this language will definitely improve a lot with the inputs of the public, consequently becoming one of the best programming languages.
Disadvantages of using Go?
Despite its growing popularity, Go is far from being a perfect programming language. It definitely has a lot of areas to improve. There are 4 aspects that I believe it’s important to have in mind when talking about Golang.
Young Language
Right off the bat the most obvious disadvantage it’s that even though Go was launched more than 10 years ago, it’s still a relatively young language with not many libraries or information. In other languages, for instance Java, there is a support of a vast collection of built-in functions and existing libraries. In some cases Go developers may have to write the libraries themselves, and since it’s a “new” language there isn’t much information, help, books or online courses around it.
Error Handling
After speaking with Syone’s developers who are currently using Go in their projects, I noticed that the general run of things is that they have sort of bad opinion on its error handling model. As matter of a fact, Golang Error Handling has been an apple of discord because of its unique and unconventional approach. In Go, all errors are values, which results in a fair amount of functions ending up returning an error. And for developers who have experience with other languages, these completely different error handling patterns turns out to be quite obnoxious to learn.
Go has no exceptions
Golang doesn't have a direct way to create exceptions, however, it is possible to create the same behaviour by using the "panic()" and "recover()" functions. This can be a disadvantage, especially if the way you program depends on this organisational model. Nevertheless, we can consider a small disadvantage because you can implement all the behaviours you need. For example, in Python the exceptions are "first-class citizen" while in Go you can replicate the behaviour if you want. But let's not get ahead of ourselves. We will do a comparison between these 2 programming languages soon.
Simple is better (But calma, not always)
Lastly but not least, I would like to talk about how sometimes simple is not always better. Based on the results of my research, one can postulate that yes, Go is simple, but it is obnoxious. Developers don’t need to learn a lot of keywords. Learning the language is easy and quite fast. Nonetheless, sometimes developers lack some features that they have in Phyton, Java and C/C++ and, consequently, they need to code workarounds. Which basically results in writing more code. Therefore, simple ends up being more complicated.
Differences between Golang and Phyton?
The reason why I’ve decided to compare Go to Phyton is simply that at the present moment Python is the most popular programming language. However, this comparison is quite difficult and unfair because we are comparing a mature language with a relatively young language.
Go has only been around for more than 10 years and it is still in the process of building a substantial ecosystem and community. On the other hand, Python is the leading language in machine learning, data analysis and web development. All things considered, as magnanimous as I am, I decided to create an infographic comparing some aspects of Go vs Python.
Fig 1. Difference between Go and Python
Should you use Golang on your next project?
Before we jump straight into this question, I would like to share with you some examples of companies that are currently using Go, as well as share with you the reason why Syone decided to use Go in one of our projects.
First and foremost, let’s talk about why it was decided to use Go in Syone's project with the leading consumer electronics retail company in Portugal. Not beating around the bush, it was due to the limitations of the previous language, Perl. This programming language presented some difficulty when managing dependencies and managing dynamic typing. And in turn of events, Go was the programming language that could solve those issues.
Just like the developers here at Syone, developers around the world decide to work with traditional programming languages because they are more mature and well established. Be that as it may, it is undeniable that Go offers an incredible easy adoption and it is becoming more obvious that Go is a marvellous programming language. And we already see major companies transitioning to Go, for instance:
- Apple
- Dropbox
- BBC
- The New York Times
- The Economist
- Soundcloud
- Twitch
- Uber
- Among many others...
If you would like to check out all the companies that are using Go around the world, just follow this link: https://github.com/golang/go/wiki/GoUsers
Now the million-dollar question, should you use Go in your next project?
Well… In my humble opinion... it depends.
I am hubristic about this language. There is a panoply of benefits that Go can bring to your project and even though this language has a lot to grow, I truly believe that Go has the potential to become the most popular programming language in the world. Of course, there are languages that are more mature, more elegant, and more expressive. There are languages that “do” types better. There are languages that offer more interactive development.
But honestly, there’s no single perfect language. You want to use the best tool for the particular project at hand.
As it was already stated above, Go is simple and it takes a lot of design cues from the Unix Philosophy (which basically is: do one thing well, keep it simple and have a standard way to communicate). This is what makes Go great, and thanks to the simplicity and this Unix philosophy it allows these big companies to use Golang on large projects.
I actually read a nice rule of thumb on WillowTree Apps blog, where they explain really well if you should or not use Go in your next project:
“Consider this rule of thumb when deciding whether to use Go:
If you’re working with bytes, Go might be a good choice.
If you’re working with data, Go might not be a good choice.”
Now if you ask me, I think you should definitely go and use Go in your next project.