Go is a programming language developed at Google, it appeared in 2009. Go is a minimalist, statically typed, compiled language. It compiles to native code for most of the major OS platforms.
Of the two things, I enjoy the most about being a Software Engineer are, coding, and learning. I try to learn new programming languages at a rate of 1 every one or two years. My method for learning is by actually using the language in practical projects. Three years ago, I was looking for a new language to learn, my decision was between ruby and go. Without any special reason, I decided to learn Go. Chapi is my first Go Github project. It was a very simple web framework and it was useful for me to learn the syntax and basics on how to use the language.
After almost three years of using it, I’m very happy with the decision. I know there are very nice languages out there these days. I must say, using Go over these years, helped me to be a more productive programmer. Go is a general purpose language so you can implement anything you like with it. I use it for implementing CLI’s for automation, and microservices (REST, RPC)
Go gained a good traction among the infrastructure developers/providers. There are great tools that many people are already using or planning to use written in go. Some examples are, Kubernetes, Etcd, and Docker.
Here I’ll describe characteristics of the language, which make it a good choice for implementing different types of solutions.
The go community is very welcoming. Go is an open source language, and even I noticed the design decisions go through a strict process, everyone is encouraged to take part. I had the opportunity of being at a meeting with the Go Team, they were open to suggestions and listened feedback people provided.
When I started using Go, it was different to what I was used to. I wouldn’t say that as it is bad, It was different in a good way. Go supports Object-oriented and functional programming, which is common these days. I worked with programming languages such Java before, and defining Objects, Interfaces and how you implement them is not different from other languages. But Go is a little different.
Go has only enough features for you to implement your solution. Many languages have much more features than what you need, and you may end up using things you shouldn’t because they are available.
Go is a strongly typed language, but that doesn’t slow you down when writing a program. Go supports type inference, It means that you can omit to declare the type in many situations. That makes you feel like you are using a more dynamic loosely typed language.
var myString = "Hello world!" // Go infers the type of "myString" as String. var myInt int = myString // This is a compilation error. You cannot assign a string to an int
Go doesn’t support classical inheritance. For example,
A extends B, or
B is a subclass of A. Go supports «extending» an Object(Struct) by aggregation, which I found is a much more flexible and easy to reason about.
In Go you don’t have to implement interfaces explicitly for example in Java you must say
A implements B. In Go, if you have an interface an Object implements it, by having the same interface methods. So, you can use any Object as an interface implementation, without having to implement it explicitly.
Go has the first-class support of concurrency primitives. It is important to think about the world and the problems we solve as concurrency problems. This is a very interesting talk from one of the Go creators, Rob Pike, Concurrency is not Parallelism talking about that. Concurrency and parallelism have been difficult subjects for programmers to grasp. That because, most of the programming languages, didn’t support concurrency primitives from the beginning. Concurrency support in languages such Java was added later, and many of us don’t even think about using those features, even they are useful.
An example I found for what is a simplified way of solving concurrent problems, is Node’s concurrency model. Node uses a single processor thread. It is so easy to use, that you don’t even have to know you are working on multiple tasks concurrently. Node’s concurrency model has proven to be enough for many applications, it is easy to use, and has a good performance for some types of operations. The problem is, there isn’t an easy way of using the full power of a modern multi-core processor. Modern languages such as Go, take into account modern computers capabilities. That’s is important if we want to implement effective and efficient solutions.
Tooling is one of the things about Go I enjoy the most. There are common tasks you want to do when working with a programming language, besides compiling and running. For example, unit testing, formatting, linting, and dependency management.
Go is opinionated, and it provides its own tools for the tasks I mentioned above. It has saved me a lot of time, by not having to discuss and decide among dozens of tools for doing those tasks. And the good thing is, the majority of the community is happy with using the integrated Go tooling. That means constant feedback and improvements.
Go is a modern easy to use programming language. Designed by smart people at Google, aiming to solve some of the Googles’s problems. Go is good for solving most of the software problems we may have. The language has a vibrant open source community working on very interesting projects. Go provides not only a nice language syntax but most of the tools you need to feel and be productive when working in it.