articles, October 30, 2023

Get going with Go

Get going with Go

Advantages, disadvantages and musings

Go, also known as Golang, was first developed by three designers at Google way back in 2007. While it was introduced to the open-source community in 2009, Go only really started gaining traction as a programming language in the past several years as notable software development companies and products like Dropbox, Docker, Google (of course), eBay, Baidu and Spotify have picked it up. Go is supported by Windows, Mac OS X, Linux, BSD, UNIX, and mobile devices via Android and iOS.

We had our first experience with Go at Coherent Solutions when a client purchased a new system that was implemented on Go. They had no expertise with Go in-house, and because we have demonstrated an ability to pick up new languages quickly, they asked for our help with it. Here are some things we have learned about it.

Overview

Unhappy with the complexity of C++, Go’s designers were looking to create a systems programming language that would be:

  • An imperative, compiled, statically-typed language
  • Scalable to large systems, like Java or C++
  • Clean and light on keywords syntax

Type inheritance is intentionally absent from Go. Instead of introducing an embedding mechanism, programmers can embed type with a struct or interface. Go also supports the duck typing concept. There is no need to specify interfaces, which are supported by the type. So, if a type contains interface methods, Go will implement this interface.

Advantages of Go

  1. Performance     As a compiled language, Go is ten times faster than Python or Ruby.  And although it is still a little bit slower than 
    C++ or  Java, Go still has plenty of opportunity to improve performance as its compilers mature…  And although it is still a little bit slower than C++ or Java, Go still has plenty of opportunity to improve performance as its compilers mature.

  2. Development speed and ease    Go was created to be easy-to-learn, with simplified syntax. It is much faster to create programs in Go than in C++ which requires manual memory management, for instance. Plus, Go’s standard library is rather comprehensive and covers all base scenarios. Beyond that, there are many third-party libraries. You can also use several popular IDE’s (IntelliJ IDEA, Eclipse IDE) with additional plugins to develop on Go.

  3. Concurrency   It is easy to create asynchronous code using Go. There is a supporting list of synchronization mechanisms, including goroutines and channels. The goroutines concept is one of the greatest Go features. A goroutine is a lightweight, “green” thread that only requires several kilobytes of memory.  You can easily create thousands of them. Channels are used to organize communication between goroutines.

  4. Garbage collection    Unlike C++, but like Java or .NET, Go has automatic garbage collection which relieves developers of having to deal with memory deallocation. GC also decreases the probability of some categories of bugs. The 1.5 version of Go has a GC latency well below ten milliseconds.

  5. Static, strong typing   With this you can detect and correct a lot of errors in the source code during compilation.

  6. Static linking  Go runtime and all libraries are included in Go applications. This means less flexibility, but more durability. There is no need to worry about any dependencies when deploying Go applications.

  7. Cross platform   Go supports cross compilation on most popular platforms.

  8. Supports unit testing   A built-in testing package provides support for automated testing.

Disadvantages of Go

  1. Small developer community  As of now, the developer community is not as large as those for competitive technologies like Python, Ruby and Node.js.

  2. Lack of official support  There is no official support from a resource-rich company or vendor.

  3. Lack of generics  Developers of Go have noted that generics could be added in future versions. For now, there are workarounds that allow you to emulate generics.

  4. Lack of exceptions  This was intentional. Instead of an exception mechanism, you get error codes from functions.

Conclusion

Based on the pros and cons we have discovered with Go, it makes sense to use it in these kinds of applications:

  • Performance-critical, scalable backend components
  • High load websites or web services with simple business logic
  • High-performance components for Android and, in the future, iOS
  • Education – a good, easy introduction to learning a programming language

Go’s popularity has grown over the last several years, with many more companies trying it in a variety of interesting applications and services in 2015. According to a RedMonk rating, Go moved up from number 17 to number 15 in the first 7 months of 2015. This ranking is based on language popularity on GitHub and Stack Overflow. On the negative side, Go fell from number 46 to below 50 between December, 2014 and August, 2015 on the TIOBE rating. The difference is that TIOBE builds their ratings on  search requests

Go applications

  1. Written in Go, Docker is used by eBay, Baidu, Yandex and Spotify. This platform runs distributed applications, isolated from each other. An application is packed into a Docker container with all its dependencies and executed by the Docker engine. Instead of requiring a separate virtual machine for each container, Docker uses Linux kernel isolation functionality, rendering containers lightweight and without any virtual machine overhead. Microsoft announced support of Docker containers in the next version of its Windows server and Microsoft Azure. IBM also announced a strategic partnership with Docker on their cloud and on-premise solutions.

  2. Google has begun using Go for many projects, including its download server, dl.google.com.

  3. Dropbox migrated performance-critical backend components from Python to Go – about 200,000 lines of Go code.

  4. Yandex rewrote the server API of their browser from C++ and Python to Go.

  5. IoT is a cloud-based message queue service and multi-language platform that runs parallel tasks at a massive scale. Based on Docker, it is written in Go.

  6. Revel is a highly productive web framework for the Go language.

  7. Syncthing is an open-source file synchronization client/server application written in Go.

Share article

Get a Free Consultation with Our Experts!

Simply fill out our contact form below, and we will reach out to you within 1 business day to schedule a free 1-hour consultation covering platform selection, budgeting, and project timelines.

This field is required. Maximum 100 characters.
This field is required. Maximum 100 characters.
This field is required.
Only digits are applicable.
Maximum 2000 characters.
* Required field

An error occurred sending your message.
Try again or contact us via webinforequest@coherentsolutions.com.

Message sent!

Here's what happens next:

  1. Our sales rep will contact you within 1 day to discuss your case in more detail.
  2. Next, we will arrange a free 1-hour consultation with our experts on platform selection, budgeting, and timelines.
  3. After that, we’ll need 1-2 weeks to prepare a proposal, covering solutions, team requirements, cost & time estimates.
  4. Once approved, we will launch your project within 1-2 weeks.