6 Reasons Why the Go Language Is Growing So Quickly

Go is a programming language that’s less than a decade old. It has rapidly grown in popularity for optimization tasks that require lower level system access. In 2017, it was the fastest growing language in the world, because it can handle many of the same tasks as C or C++. As those languages have declined in popularity due to their complexity and confusing syntax, Go is increasingly filling the gap left behind. Go ranks highly on Stack Exchange’s developer survey of “Most Loved Languages,” and the TIOBE Index lists it as the 17th most popular language in the world as of August 2018.

If you’re a programmer who likes to work close to the chip, with code that compiles direct to binary, Go is an interesting language to add to your arsenal. It’s also not very difficult to learn, especially if you come from other other languages popular for server, networking, or standalone command line apps. It simplifies a lot of the administrative burden of coding, making high-performance possible without burying the developer in hard-to-maintain code.

Go comes from developers at Google, and Google uses it in many of their projects, including optimizing downloads and streaming YouTube videos. It arose in 2009 when, frustrated with having to maintain hundreds of lines of C++ code at dl.google.com, a group of developers wrote a new language that could accomplish the same tasks more efficiently.

The C family of languages heavily influenced Go’s development, as did declarations and packages from the Pascal/Modula/Oberon family of languages. Ultimately, though Go is an entirely new language, and it implements its own syntax and special features like concurrency, as we’ll see. The guiding principle behind the development of Go was reducing the workload on programmers who need to code at lower levels. Go is not designed to create GUI applications. Instead, it is all about optimization, capacity, and network coordination.

For those programmers who have experience working in the C family of languages, this philosophy comes as a breath of fresh air. Much of modern systems programming involves a high amount of administrative overhead, self-auditing, and repetition. Go attempts to reduce the amount of clutter and back-and-forth that a programmer must go through to accomplish a task. For instance, everything is declared once, instead of having forward declarations and header files. The syntax is highly simplified and declaration and initialization are straightforward. Although Go is statically typed, there is no type hierarchy to make for confusing relationship declaration. Go code is shorter and more comprehensible than its predecessors.

Go is a general-purpose replacement for C++ for systems tasks, but more importantly, it is exceptional for building scalable input-output systems. This is because Go introduces features like routines and channels to replace the hundreds of lines of C++ code that manage threads, callbacks, and state machines. It’s designed to be fast and allow for multitasking with concurrent processing. It can even replace PHP (a less thread-friendly language) in web servers, database handlers, and other middleman applications.

One major strength of Go is it runs as a compiled application, without an interpreter or framework standing in between. This means that Go compiles directly to binary machine code and runs directly. This makes Go faster, but it also means you don’t have to agree on and install the same interpreter on all machines. Go just works.

Unlike other direct-compile languages, however, Go supports added features for system cleanup. With garbage collection included, you don’t need to remember to free up pointers or think about dangling pointers. All that gets done automatically.

In Go, you’ll need to declare types for all variables and function arguments at compile time. This increases the security of the language and points out errors early in the programming process. Especially for projects with many developers over a long period of time, static typing makes functions and libraries easier to understand.

Go forces developers to handle basic errors themselves rather than rely on a try catch block or other standard exception logic solutions. When you write in Go, you have to plan ahead for failure scenarios and think critically about what your program needs.

Concurrency and parallelism aren’t the same thing. Parallel processing involves multiple processor cores working on different problems at the same time. Concurrency involves breaking multiple computations up into smaller chunks and scheduling them for concurrent work on a single processor. This means that various threads get broken up and processed in small bits over time.

With the rise of microservices and the need for multiple database connections, message queues, and memory caches simultaneously, concurrent processing becomes increasingly important. Parallel and concurrent processing are not mutually exclusive, and in fact, Go is well-positioned to be the go-to language for data centers adding cores and looking for increased systems efficiency with multi-threading.

A Goroutine is a lightweight thread. When initialized it has a stack of 4KB, smaller and faster to initialize than typical threads. Routines are also not mapped one-to-one with OS threads, and a single routine can run across multiple OS threads. This enables hundreds of thousands of routines to run concurrently and in parallel. The Go runtime scheduler manages and schedules all these threads for execution.

Google places a premium on code that’s easy to understand because they have thousands of developers who need to be able to share and understand each others’ code. Go intentionally leaves out a lot of features for the sake of simplicity. There are no classes in Go, for example, only packages. There’s also no inheritance, constructors, annotations, or generics. Go is as simple to read as Ruby or Python, but it competes with C/C++ in terms of efficiency. It’s also built to be backward compatible, and the syntax has remained stable since launch.

Although it doesn’t make sense for every application, Go has a compelling philosophy behind it. It’s an exciting leap forward in systems programming, and it will likely play an important role in the microservices-driven and cloud-native future. With Google behind it, expect Go to continue to mature and grow its open source community, adding more features and resources over the coming years.

Originally published at Intertech Blog.

A leading software development consulting firm with a unique blend of consulting, training, and mentoring.