Go / Golang - The Google Programming Language

The fact that the name ‘Google’ now stands for much more than just a search engine should be well known. Its product range includes useful web services such as Google Maps, entertainment platforms such as YouTube and Google Music, communication applications such as Gmail, office solutions such as Google Docs, and even hardware such as the smartphone Pixel. In addition, the large corporation has been providing web and software developers with valuable tools for years. Since March 2012, the increasingly popular programming language Go, or Golang, has been part of the Internet service provider's portfolio.

What is Golang?

In September 2007, Google developers Robert Griesemer, Rob Pike and Ken Thompson focused their attention on creating an optimised, simplified programming language – laying the foundation for Go and Golang respectively. What started out as a small-scale project quickly developed into an ambitious undertaking, and Google deliberately encouraged its development by providing the company with the necessary resources. After Go was officially presented as an open source project (BSD license) at the end of 2011, it quickly found a large number of supporters in the community who are still involved in the further development and optimisation of the programming language. The final release of the first stable version (1.0) took place on March 28, 2012. Ever since version 1.1, which followed a year later, Google publishes updates about every six months.

Fact

The Golang mascot and logo – a gopher – was designed by Renée French, whose other creations include Glenda, the Plan 9 bunny. Rob Pike and Ken Thompson also played a major role in the Unix operating system developed by Bell Labs in the 1980s.

The syntax of Golang is strongly oriented towards the basic syntax of the C-family languages, but shows clear influences from the languages Pascal, Modula, and Oberon developed by Niklaus Wirth. Aspects of languages such as Newsqueak and Limbo have also been incorporated, which in turn are inspired by Tony Hoare’s process algebra CSP (communicating sequential processes). Golang is compatible, and had a focus on high translation speed from the beginning. In addition, the Golang programming language has an automatic garbage collection (GC) which ensures optimal management of the available memory resources in the background, which prevents storage problems.

What kind of programming language is Golang?

Although Golang is still relatively young compared to other programming languages, it’s already so mature and stable that it’s used by developers all over the world – even Google uses it. Golang is characterised by simplicity and multi-functionality, which the developers aimed for from the very beginning. One of the main reasons for the development of a new programming language was the dissatisfaction with established languages, which are either efficient in code compilation, fast code execution, or a simple programming process, but never combine all three advantages.

By combining important features from different language families, Golang sets a good example for other programming languages: the Google language combines the ease of programming, which distinguishes interpreted, dynamic language from the efficiency and security of a statically typed, compiled language. In addition, Go's structure aims to provide a short development process that allows you to create large executable files on a single computer in seconds. Some of the key Golang characteristics which achieve this standard are:

  • An expressive but lightweight type system for the optimal classification and differentiation of the various objects (variables, functions, etc.)
  • Concurrency (parallel programming) for faster programme execution
  • Automatic garbage collection (GC) for optimal use of available memory and to avoid memory problems
  • A strict specification of dependencies without complex declaration syntax
  • Platform-independence, which enables the use of developed applications on all common systems

Programming with Golang – an overview of its features

The Go syntax is based on the classic syntax of C, but differs from the programming language developed in 1972 by a number of minor improvements and a significantly reduced scope. When programming with Golang, there are no mandatory round brackets for conditions and loops, and the terminating semicolon typical of the C family is optional. In addition, the validity of identifiers can be regulated by their spelling. For example, if you want an identifier to be active outside of a specific Go package, you need to capitalise the first letter. Below are some other special features of programming with Golang:

  • GOPATH environment as a basis: One of the first official actions when programming with Go is to create the GOPATH directory, including the three subdirectories ‘src’ (go source files),’pkg’, ’GOPATH’, (go package objects), and ‘bin’ (executable commands). Any Go code that is written can be managed via this workspace, including the corresponding dependencies. The location of this obligatory GOPATH directory can be chosen freely.
     
  • Modular structure with GOLANG packages: source files can be organised modularly in Golang using directories called packages. The name of the directory is also the name of the package to which all source files in this directory belong. If functions, types, etc. are to be used across packages, the capitalization of the corresponding identifier mentioned above must be used.
     
  • Uniform, mandatory code formatting: Golang specifies certain conventions for formatting the code, such as exact spacing between elements. So, if you've learned how to programme applications with Golang, you can easily read other developers' code without having to decipher their personal formatting style, as is the case with many other languages. The format does not have to be kept down to the smallest detail by the author – the integrated tool gofmt optimises written Golang code automatically by fixing incorrect formatting.
     
  • Relative imports as standard: All files and packages imported into Golang projects are always relative to the GOPATH/src directory, which makes the import process very easy. Furthermore, Go does not compile imported elements unless they are actually used. In this way, a clean code is guaranteed even if imported components are not used.
     
  • Multiple return values for functions and methods: With Go you can create functions and methods that can return multiple values. This allows Go to clearly separate a valid result from an alternatively specified error in return. In C, for example, written errors are expressed by a negative counter value, while the actual error code is stored separately.

Advantages and uses of Golang

Many of Golang's primary strengths have already been discussed in this article. Because of its simplicity, the Google language offers developers much more ease in their work compared to many other programming languages. Those who have internalized the basics will benefit from the simple operation and numerous automatisms, which save a considerable amount of time. Thanks to these tools, such as the independently acting gofmt for automatic code optimisation, Go also provides the perfect answer to the ever-complex tasks that have to be mastered in software development. In addition, Golang code is always formatted in the same way, which makes it much easier to read and work with collaboratively in a team.

To display this video, third-party cookies are required. You can access and change your cookie settings here.

Another strength of Golang programming is the good performance of the programming language. The execution speed of Go applications is generally superior compared to other compiler languages. The compilation speed roughly corresponds to that of Java. However, while many Java applications are based on the Spring framework, and therefore take some time to respond to HTTP requests during the startup process, Golang services use the existing implementations of the standard library, which speeds up the startup process considerably.

As a result, it’s not surprising that Golang has so far been used primarily in the enterprise and server environment, where the stability and performance of services play an important role. The young programming language is in demand, particularly in the case of container-based virtualization , which isn’t least due to the fact that Docker, as probably the most prominent example among the container platforms, is based on Go.

In what ways are other programming languages ahead of the game?

With all the praise for Google’s modern programming language, it should not be forgotten that it also has some minor weaknesses. These are primarily due to the simplicity of Golang, which on the one hand is its greatest strength, but on the other hand also means that it lacks certain facets that some developers appreciate in other programming languages.

First and foremost, the lack of generic types (i.e. data types with the possibility of specifying individual type parameters) in the standard library is a factor which should be mentioned. Those who advocate type-safe programming and the use of generics in Java, for example, would have to put up without a similar feature in Go – although the Go team has not ruled out the implementation of generic types in future versions. The abandonment of classes, inheritance, and constructors is also something that many developers would need to get accustomed to. Another Golang feature is the automatic blanking of non-active import files, which many find impractical. Other languages score here due to the possibility of ‘commenting out’ corresponding components, so that they are retained in the programme code – despite inactivity.

To display this video, third-party cookies are required. You can access and change your cookie settings here.

Another disadvantage of Golang compared to old-school languages such as C, C++ and so on lies in the new history of the language. It has a much smaller arsenal of standard and importable packages. There are also fewer manuals, tutorials, etc. for Go on the net than for other, better established programming languages.

An overview of the pros and cons of Golang

Pros Cons
Multi-platform No generic types
Simplified syntax Only partially object-oriented
Automatic storage management (garbage collection) Support for IDEs could be expanded (integrated development environments)
Uniform code formatting Comparatively spare supply of third-party libraries and third-party packages
Easy import process Difficult shift from classic, object-oriented languages such as Java and C++
Multiple return values for functions and methods possible Relatively few experts and tutorials (as of yet)
Automated code correction (gofmt)  
Concurrency  
Extensive standard library (especially for http and network tasks)  

Summary: who should learn Golang?

This article has examined the basics and special features of the open source programming language, which perhaps raises the question: who should actually make the effort to learn programming with Golang? As is so often the case, there’s no general answer to this question, because Go has not been developed as a substitute for all programming languages used to date, but as a possible alternative. Thanks to its efficiency and outstanding performance, which is also reflected in the programmed applications, it’s an interesting choice especially for the business and server sector. The more code that needs to be written and compiled, the more powerful these benefits will be.

For novice programmers, the learning process with Golang is often easier – you’ll benefit from the simplicity of a modern language. Since there are not yet very many Go experts, familiarizing yourself with the Golang programming language might just yield great opportunities – be it in a job application for a developer position, or in starting up a new project.

To display this video, third-party cookies are required. You can access and change your cookie settings here.
In order to provide you with the best online experience this website uses cookies. By using our website, you agree to our use of cookies. More Info.
Manage cookies