Programming languages give software developers abstraction from machine code, and at the same time, they restrict them from so-called “bad coding.” Although these restrictions make the code more readable and less error-prone, they may lower the power of the language. Therefore, developers may choose different languages based on the kind of problem they want to solve, and as a result, we see that there is more than one common programming language.
Each powerful programming language introduced a new strength which its predecessors lacked at the time, and this lack of strength was mostly seen by the developers. Although the purpose of inventing these new languages was to solve the problem, the thought process of designing a programming language is very different from the environment in which developers and engineers code. For example, when you want to design a new programming language, you consider aspects like a memory leak, type safety, etc, but the degree to which the syntax may help code readability may not get that much attention. However, as a programmer, code readability is one of the most important aspects of your job. Therefore, programming languages might lack features which are common sense for software engineers and developers.
Golang, like any other language, came along to solve an existing problem, and that problem was build time. Something else that might not be considered as often when designing a programming language is how build time may scale by increasing the code line and the dependency among different parts. Golang or ‘Go’ was primarily invented to reduce the huge amount of build time at Google. That by itself might be the point of distinction between Go and other languages (since the sole reason behind its existence was an engineering problem in large scale), but it does not stop here. Go is designed with engineers in mind in almost every aspect.
Golang syntax is very much like C or C++, and that’s not because its inventors thought it is the best syntax. They choose C because more people are familiar with C syntax. It also has both features of an object-oriented language like defining methods on structs and procedural features like defining functions, to give the developer more flexibility. Object-oriented languages serve a great goal: well designed and structured code. However, in practice, this design needs to predict future changes and required flexibilities, which is not easy before implementation. Therefore, it might not be the best choice if you plan to change the code constantly, which is the case in cloud programming.
Golang is called the language of cloud mainly because it has built-in concurrency. Even though other languages also support concurrency, Go has a slightly different approach here. Concurrency is a need of cloud and distributed programming simply because you do not want your server to get stuck serving one user at a time. Therefore, it is very critical to have concurrency, but it comes at a cost. You need to consider race conditions – if two servers or instances of servers want to access the same resource at the same time, what is going to happen? Languages by design try to help this side effect. For example, Java guarantees memory safety, but Go does not. Go again has a contrasting approach here. In Go, it is developer’s job to consider memory safety, and as a result concurrency in Go is much more efficient than in Java. In other words, “Go enables simple, safe concurrent programming but does not forbid bad programming.”
Last but not least, Go has put more effort than other languages into making the code readable. Visibility of identifier usually depends on where the identifier is defined, not where it is used. Go, once more, has taken a different route. If a field starts with a capital letter it is public and otherwise, it is private, so you do not need to look at where it is defined to find the ‘private’ or ‘public’ identifiers. Moreover, there is no ‘this’ or ‘self’ as a reference, and as a result when you see ‘x’ as an identifier somewhere, you know it is defined there, and if you see ‘d.x’ you know it is part of ‘d.’ Go also comes with gofmt, which is a tool alongside the language and manages the formatting and indentation of the code so developers do not spend time on it. This unifies and increases the readability of the program.
In sum, Go is the language of cloud and was designed considering software engineering common sense. Go is a familiar and modern language which works at scale. It is a fairly young language, and we need more time to see its bloom or failure. Nevertheless, it is going to be the first of its kind to break so many unwritten language design rules.