Book Review: Learning Go by Jon Bodner
Thinking of learning Go in 2023? This book could be a good choice! The focus for Learning Go isn't just how to write programs in Go; it's how to write Go idiomatically.
Join the DZone community and get the full member experience.
Join For FreeYou're looking to upskill with some Go. But which book should you choose in 2023? I've read through as many beginner Go books as I could find to help answer this question. Below is my full review of one of my top picks, Learning Go, by Jon Bodner. Find the full review series at boldlygo.tech.
You can also watch this review on YouTube.
Publication Details
Learning Go: An Idiomatic Approach to Real-World Go Programming 1st edition; by Jon Bodner, 375 pages. Published April 6, 2021 (the third release of 1st edition published May 13, 2022) by O’Reilly Media.
Audience
From the preface of the book (page xiv), “This book is targeted at developers who are looking to pick up a second (or fifth) language. The focus is on people who are new to Go.”
A further emphasis is made on those who wish to learn to write idiomatic Go. “While you can write Go code that looks like Java or Python, you’re going to be unhappy with the result and wonder what all the fuss is about.” This should be no surprise, given the book’s subtitle, An Idiomatic Approach to Real-World Go Programming.
If you are brand new to programming entirely, this may not be the best book for you, as it does assume familiarity with basic programming concepts, including version control, concurrency, and abstraction.
Narrative Style
I’ve always been a fan of the O’Reilly books. Probably the first one I read was the famous Learning Perl, (although the second edition, in my case).
So, reading another O’Reilly book just feels comfortable, like going home for Christmas.
Author Jon Bodner (perhaps with the help of O’Reilly’s editorial staff) has done a great job of writing a book that’s easy to read, direct, and not dry and dull.
The preface hits the nail on the head when it says, “The focus for Learning Go isn’t just how to write programs in Go; it’s how to write Go idiomatically.” I see that theme throughout, as Bodner is consistently pointing out what is considered the “more correct” way of doing things without sounding dogmatic. For example, while talking about numeric literals,
Go allows you to put underscores in the middle of your (integer) literal. This allows you to, for example, group by thousands in base ten (1_234). … You could put an underscore between every digit in your literal (1_2_3_4), but don’t. Use them to improve readability.
Content
I’m impressed by how thoroughly this book covers the topics of Go. Whereas the last two books I reviewed skimmed over huge swaths of the language, notably not even mentioning the common numeric types, this book is complete. Arguably to a fault — it spends two full pages talking about the complex64
and complex128
types! LOL!
It also goes into detail on many of the common “gotchas” that new Go developers experience. Page 32 talks about Unused Variables, for example:
Another Go requirement is that every declared local variable must be read. It is a compile-time error to declare a local variable and not read its value.
This type of detail is essential for newcomers to the language (as evidenced by the repetition by which a variant of this is asked on StackOverflow), yet it’s often overlooked by authors and tutorials.
One challenge when writing a book on a technical topic is the chicken-and-egg problem when presenting topics that depend on and build on each other. This book handles this problem gracefully, and in my preferred way, by introducing the dependent topic, but just enough to understand the topic at hand, then referring you to the later (or sometimes earlier) section of the book where the dependent topic is covered in detail.
This book covers all of the vital topics, including Go modules, how to write tests using the testing
package, and even Generics! It also covers a number of important peripheral topics, such as the pkg.go.dev website, best practices for sentinel errors, and even admonishes the reader to read Effective Go and the Code Review Comments section of the Go wiki, two resources I consistently point newcomers to as well.
I also learned a few things from this book, which is refreshing, considering I’ve already been using Go as my daily programming language for several years.
Accuracy
I haven’t found any outright errors in this book. There are a few outdated bits, but impressively, some of them are even noted in the book itself! While the first release of this book was originally published on March 2, 2021, I got a copy of the third release, published on May 13, 2022, which includes a few notes where information in the book is now outdated.
Physical Characteristics
If you’ve ever read an O’Reilly book, you already know what to expect here. A high-quality, no-frills, black-and-white production. Easy to read, with clear section headings and breakpoints, but without any “fluff” to get in the way. The sparse graphics are simple monochromatic icons that draw attention to specific tips, notes, and cautionary text.
Conclusion
I’m a fan.
I’m only halfway through my stack of six Go books, but I like this one. Even as a long-time Go user, this is a good read.
The only reason I would suggest avoiding this book is if you are an absolute beginner to computer programming.
Published at DZone with permission of Jonathan Hall. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments