That the name “Google” goes beyond a simple search engine has been known for a long time. Its product catalog covers web services such as Google Maps, entertainment platforms such as YouTube or Google Music, communication applications such as Gmail, office solutions such as Google Docs and hardware with the company’s Pixel smartphone. Not content with this, the company has been supplying software tools for the satisfaction of programmers and web developers for some years . Since 2012, the increasingly popular Go programming language, widely known as Golang (Go Programming Language), also has a place in the Silicon Valley company’s extensive portfolio.
What is Golang?
In September 2007, three Google staff programmers, Robert Griesemer, Rob Pike, and Ken Thompson, presented their ideas for a streamlined, simpler programming language, laying the foundation for Go. What began as a modest project soon became an ambitious project whose development was promoted by Google , which provided all the necessary resources for it. Since it was officially published as an open source project with a BSD license at the end of 2011, Go has not found it difficult to surround itself with a large community that to this day has not stopped actively collaborating in its continuous software development services and optimization. The first stable version (1.0) was published on March 28, 2012 and since version 1.1 (a year later) Google publishes updates every half year.
Golang’s syntax has many similarities with the basic syntax of C family languages , but shows a strong influence from the Pascal, Modula and Oberon languages , developed by Niklaus Wirth. He also reveals aspects of languages such as Newsqueak and Limbo , which in turn draw inspiration from CSP (Communicating Sequential Processes) by Tony Hoares. Golang is a compiled language, although from the beginning great importance has been placed on high translation speed. The language also has an automatic garbage collector (Gargabe Collection or GC), which helps efficiently manage available memory and thus reduces space problems.
What makes Golang so special
Although Golang, compared to other languages, is still relatively young, it is so mature and stable at the same time that developers around the world – including Google – have already succumbed to its possibilities. Its main virtues are simplicity and multifunctionality , aspects that its authors have pursued from the beginning. The main motivation that has guided its development has to do precisely with the dissatisfaction resulting from the offer available at the time, composed of languages that stood out for being very efficient when compiling code, for executing it quickly or for being easily programmed, but never for all three. advantages at the same time.
By combining the best of each family, Golang is ahead of the rest, constituting a good model to follow. The language developed by Google combines the ease of programming of interpreted and dynamic languages and the efficiency and security of a statically typed compiled language. Added to this is that the structure of Go obeys the purpose of shortening the development process so that it also allows large executable files to be created on a single computer in a short time. Some of the distinctive characteristics with which this level of quality can be achieved are the following:
- A lightweight but expressive type system that allows you to classify and differentiate objects (variables, functions, etc.)
- Concurrency (simultaneous calculations), which allows faster execution of programs
- The aforementioned garbage collector to rationally use memory and avoid space problems
- Strict dependency specification without complex declaration syntax
- Multiplatform , to use applications developed on any system
Programming with Golang: is it as easy as they say?
The Go syntax has a lot in common with the classic C syntax, although it differs from this language, developed in 1972, by a series of small improvements and a smaller volume . Among these changes, it is worth mentioning that when programming with Go, parentheses in conditions and loops are no longer necessary, and the closing semicolon typical of C languages is optional . Likewise, Go allows you to regulate the validity of identifiers (for variables, functions, etc.) by writing (upper or lower case): if an identifier has to remain active outside of a Go package, you only have to write the initial in capital letter.
Other quirks of programming with Golang are listed below :
- GOPATH environment variable as a basis: one of the first mandatory steps when programming with Golang is to create the GOPATH directory along with the three subdirectories “ src ” (Go source files), “ pkg ” (Go package objects or package objects) and “ bin ” (executable commands). It is in this space, which can be freely located, where the mandatory code with its dependencies is managed.
- Modular development with GOLANG packages : Source files are organized into directories that are identified as packages . The directory name is identical to the name of the package to which the source files contained in this directory belong. If there are functions or types that must be used beyond their package, capital letters are used.
- Uniform and predefined code format : Golang prescribes certain conventions for code formatting, such as the exact spacing between elements. This makes it very easy, once you have learned to program applications with Golang, to read other developers’ code without having to decipher their personal style, as happens with other languages. However, it is not necessary to pay excessive attention to all the details, since the integrated gofmt tool optimizes the written code automatically, correcting any formatting errors.
- Relative imports by default : all files and packages that are imported into Golang projects (own or third-party) are always relative to the GOPATH/src directory, which simplifies the import process . Additionally, Go does not compile elements it imports if they are not used. This ensures that the code is kept clean in case the imported elements are unused or no longer used.
- Multiple return values for functions and methods: With Go you can create functions and methods that can return several different values. This way, Go can return a valid result and an alternatively specified error clearly separated. In C, however, writing errors are displayed with a negative numerical value, while the error code is stored separately.
Advantages and application of Golang
Many of Golang’s main strengths have already been mentioned. Thanks to its simplicity, Google’s language offers programmers much more convenience than other languages. Once you understand the basic theory, it is easy to take advantage of its ease of use and the numerous automated mechanisms that result in considerable time savings. With these tools, including the aforementioned autonomous code optimization with gofmt, Go provides the ideal answer to the increasingly demanding tasks of the custom software development company. Added to this is the fact that Golang code always has the same format, which greatly facilitates its readability and, above all, teamwork .
Another notable aspect of programming with Golang is its good performance . The execution speed of Go applications scores well when compared to other compiler languages. Its compilation speed is roughly comparable to that of Java, for example, but, while many Java applications are based on the Spring framework and this means that when they start up they need a certain amount of time to be able to respond to HTTP requests, Golang services take less time to complete. start because they use the available implementations of the standard library .
Consequently, it is not surprising that Golang has so far found application mainly in companies and in the server environment, areas where the stability and performance of services play a particularly important role. It is above all in container-based virtualization that there is special demand for this young programming language, which is also related to the fact that Docker, the most prominent representative of container platforms, is based on Go.
The other side of Go Programming Language: how do other languages surpass it?
With all the praise that this modern language deserves, it is also appropriate to highlight some of its weaknesses. These are mainly due to its simplicity , which although on the one hand represents its greatest advantage, on the other contributes to the lack of some facets that many programmers greatly appreciate in other languages.
The most relevant is probably the absence of generic types (data types that allow individual type parameters to be indicated) in the standard library. Proponents of typed programming and those accustomed to the use of Generics in Java have searched in vain for a similar quality in Go until now, although the Go team does not exclude the implementation of generic types in a future version. Many programmers would also have to get used to not using classes, inheritances, and constructors. A not always desired Go feature is the automatic hiding of non-active imported files . Other languages have the advantage of extracting the components in question from comments so that they remain in the code despite their inactivity.
Finally, another disadvantage of Golang compared to robust veterans like C, C++, etc., lies in its relatively short history. This gives you a much smaller arsenal of packages implemented by default and ready for import. Furthermore, the number of manuals available on the Internet for Go is even smaller than what can be found for the more established languages.
Conclusion: who should learn to work with Golang?
Once the fundamentals and peculiarities of this free programming language have been analyzed, a question logically arises: who should make the effort to learn to write with Golang? Naturally, it is not possible to give a universal answer, since Go has not been developed with the aim of replacing all known languages, but rather to establish itself as an alternative . Thanks to its efficiency and extraordinary performance , aspects that are also reflected in the applications that are programmed with it, Go is an interesting option especially in the custom software development services and server fields . The more code that needs to be written and compiled, the clearer its advantages are.
For programming learners, the learning process is much easier, taking advantage of the simplicity of this language, which can at the same time be frustrating for the most experienced due to its similarities with C or Java. But if the inconveniences linked to switching from one to the other are overcome, “old” programmers might also be able to appreciate its virtues. As the market for Go experts is not yet very large, knowing the Google language still represents a great opportunity, both at work, when applying for a position as a programmer, and privately, in order to develop your own idea.