Best practices for writing high-performance Go code

Written by
mbergoon
Link to Post

https://golangweekly.com/issues/253

#253 — March 14, 2019

Read on the Web

Golang Weekly

New: Be sure to check out our first Go developer interview at the bottom of this issue. We spoke to Ron Evans (of Gobot) about why Go is well suited for hardware and microcontroller use ๐Ÿ™‚

Tracerr: Go Errors with Stack Trace & Source Fragments — An interesting experiment in making Go error output more informative. More examples here.

ztrue

The State of Caching in Go — Spoiler: The results are not great. This post talks about why various cache algorithms don’t work well in Go and what they are going to do about it.

Dgraph

Designing a Package Manager from the Ground Up – CircleCI Orbs — CircleCI recently launched a package manager just for CI: CircleCI orbs. If you’re using orbs today and want to understand how to get the most from them, or if you’re thinking about designing your own package management system, this post is for you.

CircleCI sponsor

Best Practices for Writing High-Performance Go Code — We first linked this a year ago and while it remains an ‘in progress’ document, there’s plenty to enjoy and contributions are welcomed if you can flesh it out.

Damian Gryski

Managing Go Module Deprecation — An introduction to modcop, a new CLI tool that inspects go.mod files for deprecated versions.

Myles McDonnell

MongoDB Go Driver 1.0.0: The Official MongoDB Driver1.0 is finally here after a long process which began with Considering the Community Effects of Introducing an Official MongoDB Go Driver in January 2018.

MongoDB, Inc.

💻 Jobs

Senior Backend Developer (Copenhagen) — Vivino <3 Go. 99.9% of requests are served by our Go backend. We have many ongoing projects and are looking for strong developers.

Vivino

Find A Job Through Vettery — Vettery specializes in dev roles and is completely free for job seekers.

Vettery

📘 Articles & Tutorials

Common Traps, Gotchas, and Common Mistakes for New Go Devs

Kyle Quest

An Approach to Dependency Injection in Go using Higher Order Functions

Stein Fletcher

A Brief Introduction to gRPC in Go — A quick tutorial that touches all the main bits of creating a gRPC client and server app with a reasonable amount of explanation.

Kamil Lelonek

📈Data-Driven Guide to Engineering Leadership — Get actionable insights from 7 million commits and 85,000+ engineers, to increase your software teams velocity. Free Guide.

GitPrime sponsor

How Goroutines Work in TinyGoTinyGo (a microcontroller-aimed compiler) has to take a different approach to the standard Go runtime.

Ayke van Laëthem

The Ups of Downs of Porting 50k Lines of C++ to Go — An old story that’s doing the rounds again ๐Ÿ™‚ “In business terms, the project was a success,” but… “I feel the outcome was suboptimal, in the sense that I wrote two to three times as much code as would have been needed in a language with parametric polymorphism.”

logicchains

Rewriting the Sharding Layer of Uber’s Schemaless Datastore — How Uber rewrote and migrated their fleet of worker nodes from Python to Go without disrupting active service.

Jesper Lindstrøm Nielsen and Anders Johnsen (Uber)

Using Go as the Infrastructure Language at NodeSource — A brief enumeration of the benefits Nodesource gained with Go which could probably apply to your infrastructure, too.

NodeSource

🔧 Tools & Code

go-asciibot: An ASCII Robot Generator — More cute than useful, perhaps.

Matthias Kadenbach

BigQueue: An Embedded, Fast, Persistent Queue in Pure Go — Uses memory mapped files under the hood. Linux, Darwin (macOS) and BSD-only for now.

grandecola

Slim: Space-Efficient Data Structures for Go — An attempt at creating a library of ‘surprisingly space-efficient’ data types, though it’s just a trie structure for now.

openacid

Introducing Kraken, an Open Source Peer-to-Peer Docker Registry — Yes, it’s built in Go! GitHub repo.

Cody Gibb, Evelyn Liu, and Yiran Wang
(Uber Engineering)

go-tflite: Go Binding for TensorFlow Lite — Very early days for this.

Yasuhrio Matsumoto

Go Inside a Big Nerd Ranch Bootcamp: Free Online Session 4/24

Big Nerd Ranch sponsor

Pion WebRTC: A Pure Go Implementation of The WebRTC Native API

Sean DuBois

go-bsdiff: Pure Go bsdiff and bspatch Libraries and CLI Tools — For binary patching and diffing.

Gabriel Ochsenhofer

Weaver: A Modern HTTP Reverse Proxy with Dynamic Sharding Strategies

GO-JEK Tech


💬 A Q&A with…
Ron Evans
of the TinyGo, Gobot and GoCV projects

Ron Evans is a Go developer who’s best known for his work on Gobot, a popular library for controlling robotics/IoT devices from Go, and GoCV, a way to use OpenCV from Go.

He has recently become involved with the TinyGo project, an effort to build a Go compiler that can suitably target small scale devices, such as microcontrollers and popular microcontroller boards, and WebAssembly. We caught up with him to ask a few questions about this work.

You’re well known for your work on Gobot. What got you into working with hardware with Go?

I’ve been using open source software/hardware like Arduino for quite a while, but I got serious in around 2009 with a series of Ruby powered blimps. When I discovered Go, the minimalism of the language and the way concurrency is treated as a first-class construct were appealing, and with Go being a compiled language it seemed a better fit for embedded Linux where resources are more limited.

What inspired your work on TinyGo?

I discovered the project last year (probably from your newsletter!) and it excited me because executing Go directly on microcontrollers seemed the last place that Go code couldn’t run. I contacted the project founder Ayke Van Laatham and started to contribute. TinyGo has evolved quickly from an interesting experiment into a real “thing” and we’re treating it that way with good development and governance practices. Contributors welcome (particularly on areas around our pain points with Go)!

Why do you feel Go is particularly well suited for low level working with hardware?

We’re seeing high-level interpreted languages running on microcontrollers like Python and JavaScript, so it certainly seemed possible as Go is a true compiler, and the language itself is very minimal. The big leap that Ayke made was combining the Go compiler libraries with the LLVM compiler backend. The result of this is such highly optimized and fast code, that one of our demos is running a Go program on an 8-bit processor with 8K of RAM.

Ron Evans is a technologist for hire at The Hybrid Group.

Article Tags:
Article Categories:
golang

Leave a Reply