Book Review golang

Book Review: The Go Programming Language

The Go Programming Language, by Alan A. A. Donovan and Brian Kernighan, is reviewed in this post. Brian Kernighan is well known as the coauthor of The C Programming Language, and that book itself has severed as a standard text for generations of engineers. Go has often been referred to as the 21st Century C and The Go Programming Language may very well be the standard reference text for it.

The Beginning

The book starts out strong with a Tutorial chapter giving you a simple “Hello, World” program and also showing off some of the advantages of using Go. The minimalism is bound to appeal to programmers who have had it with bloated libraries. You can’t declare a variable and not use it in the rest of your Go program. You can’t import a library and not use it in your code. It will simply not compile. You don’t have to argue about the format of your code. For example, the age old battle between:

func main() {
}
//And
func main()
{
}

Is settled by the compiler which accepts only the former and not the latter. Other nuances are settled by tools like gofmt which takes your Go source file and formats it in a standardized manner. So all Go programs follow the same convention, which in turn improves the readability of the code.

The first chapter emphasizes these selling points and does a really good job of giving the readers a taste of what Go is really about: A general purpose language designed for generating static binaries with as little bloat as possible.

Brevity

Experienced programmers are tired of learning about the same concepts like for loops, if-else statements, etc over and over again for different languages. The first chapter sneaks in all this tedious information by encouraging the users to write simple Unix-y programs (as was the case with The C Programming language).

One drawback of this rapid-introduction is the fact that new readers will get completely baffled by syntax. Programs rapidly start using the dot operators and various object oriented programming concepts after two or three examples down the very first chapter. This is important for maintaining speed and brevity of the overall reading experience and is a very conscious choice on the part of the writers.

The book also assumes that readers are familiar with at least one programming language, before they picked up this book. This could be Python, JavaScript, Java, C or any other general purpose language.

Companion Website

The book comes with a companion website. You can directly import the programs given in the book from this website and run it without having to type (or copy paste from your Kindle App). You can even check out the first chapter (which, by the way, is my favorite one) for free on this website and decide if this book is for you or not.

The authors have paid attention to the pains of a programmer trying to learn a new language. Distractions are kept to a minimum with each program’s web link mentioned on top of it. So you can fetch the code, run it, tweak it and build upon it, if you like.

A comprehensive list of errata is also maintained on this website, and you can refer it if you think something’s amiss.

Serious Business

If you are expecting a simple guide for causal scripting, this is not the book for you. The reason is that a lot of ground is covered first and then the details are filled along as we progress towards later chapters.

This book is for people who want to understand the constructs, the nitty-gritty details of how Go works. You will be creating GIFs, writing web servers and  plotting Mandelbrot Sets and much much more, but none of it would make any sense unless you have paid attention to the finer points made  preceding chapters (with the Chapter 1 being somewhat of an exception, as it is meant as an overview of the language).

The majority of the rest of the book focuses on various syntax related details about Go including things control loops, variables, functions, methods, Go routines and much much more. All of this is illustrated by making the reader go through useful programs and not made-up idealistic scenarios.

Even if you wish to skip most chapters from the middle of the book, I would strongly suggest digging through chapter 5 for an understanding of Panic, Error handling and anonymous functions. However, I would strongly suggest going through all the chapters sequentially before we come to the crown-jewel of Go — Concurrency.

Emphasis on Concurrency

Go language is designed, from ground up with concurrency in mind. Most modern processors are multicore and multithreaded but programmers despise the complications they face when writing programs to run on such architecture. With cloud computing heading towards distributed systems, concurrent code will soon be the only well-performing code out there.

The chapter on concurrency is written to beat the fear of concurrent design out of our minds. It is complicated, yes, but not hopeless. The book does a great job of conveying how Go can help you develop the correct mindset from this.

Conclusion

The experience of Kernighan from early UNIX days is still very very viable in the modern age of cloud desktops, GPUs, IOT, cloud and whatever will follow next. He and Donovan have done a great job of imparting this wisdom of application design and UNIX philosophy using a simple, modern language with performance in mind and I have zero hesitation in recommending this book to anyone from a high school student to an senior software engineer with decades of experience.

About the author

Ranvir Singh

Ranvir Singh

I am a tech and science writer with quite a diverse range of interests. A strong believer of the Unix philosophy. Few of the things I am passionate about include system administration, computer hardware and physics.