Johanan Liebermann

Software Developer

Programming in Go—First Impressions

Posted on Oct 17, 2016

Recently I started experimenting with Go, and I want to share my thoughts and experiences with the language so far.

Go is a relatively new programming language. Since its announcement in 2009 by Google it’s been gaining a lot of traction.

Among the trending programming languages these days, Go is quite unique. On one hand, it is relatively easy to learn, its syntax resembles interpreted languages at times and it offers features like garbage collection and memory safety. On the other hand, it compiles directly to machine code. This makes it a viable replacement for languages like C, C++ and also Java (which compiles to bytecode but is still considered a high-performance language).

Another interesting fact is that go is not an object-oriented language, although it does support object-oriented style of programming. So, for example, you can define your own types and methods:

package main

import "fmt"

type car struct {
    color string
    running bool
}

func (c *car) start() {
    c.running = true
}

func main() {
    my_car := car{"blue", false}
    fmt.Println("My car is", my_car.color)

    if my_car.running {
        fmt.Println("My car is running")
    } else {
        fmt.Println("My car is not running")
    }

    my_car.start()
    if my_car.running {
        fmt.Println("My car is running")
    } else {
        fmt.Println("My car is not running")
    }
}

// Output:
// My car is blue
// My car is not running
// My car is running

However, Go doesn’t have inheritance and lacks other features which languages like Python, Java or C++ have.

Go’s designers wanted to create a modern language that’s easy to learn and easy to work with, without sacrificing performance. For this ambitious task, Google has brought on board computer science giants like Ken Thompson and Rob Pike. Judging by Go’s popularity these days, it seems they’ve done a good job at that.

A huge part of Go’s popularity can be attributed to Docker, similarly to how the Rails framework has boosted the popularity of Ruby. Docker is a platform for software containers that has been gaining a huge amount of traction since its release in 2013 as an open-source project. Docker itself is written in Go, and most of the software in the Docker ecosystem (Kubernetes, etcd, flannel) is written in Go as well. In addition, the excellent open-source tools developed by HashiCorp are written almost entirely in Go, which adds to Go’s popularity as tools like Terraform, Consul and Vault are very widely used these days.

To conclude, Go can be a useful language to learn these days, and is a must if you’re planning on developing around the Docker ecosystem. However, its low-level nature, combined with a relatively easy development process, makes it very useful for many modern tools. Therefore, even though Go’s main use case is server applications, we’re starting to see a variety of new applications that are all written in Go, including GUI applications. This trend is, in my opinion, likely to continue, and even if I’m wrong—you should still give Go a try, if only to experience a unique and interesting programming language.

comments powered by Disqus