A Go developer and a Rust developer meet in a chatroom • The Applied Go Weekly Newsletter 2024-04-28
Your weekly source of Go news, tips, and projects
A Go developer and a Rust developer meet in a chatroom...
This could be the start of a lame joke about Go vs Rust, but it actually happened — except that the two "developers" were LLM-based bots, one written in Go, the other in Rust.
How can you tell the two were bots? They were polite to each other.
Now that's the lame joke you were looking for. You're welcome. On a more serious note, the making-of of these bots is captured in an article in the More Articles section.
But first, let me take a selfie present the featured articles to you.
The Two Reasons I Prefer Passing Struct Pointers Around
Maybe you remember the recent blog series that showed how returning copies of a struct (or another type of significant size) is more performant than returning a mere pointer to the data? Well, performance is not everything. Preslav Rachev reminds us that pointers and values have distinct semantics. Performance should only be a distant second criterion.
The Two Reasons I Prefer Passing Struct Pointers Around · Preslav Rachev
What’s New in Go 1.22: cmp.Or
Carlana Johnson has provided a number of contributions to Go 1.22, including cmp.Or
.
What’s New in Go 1.22: cmp.Or · The Ethically-Trained Programmer
From Ground Zero to Production: Go's Journey at Google
Go did not spring into existence from a C-level directive at Google. Rather, it was created by a small team and had to gain popularity within Google, just like it had to outside Google.
From Ground Zero to Production: Go's Journey at Google - Yves Junqueira's blog
Podcast corner
Only one podcast episode captured this week.
So what?
After all, this section is named "podcast corner", not "podcasts corner". (I'm good at nitpicking on grammar if it helps me find silly excuses.)
And the Cup O' Go team surely will have released their new episode a few hours after this newsletter went to press, as usual!
Go Time
This week's Go Time panel goes into the third round of discussing Go's cryptographic packages. (Featuring Neal.Fun's password game.)
Mini-Essay: Efficient tools with Go and unikernels
Last week, I wrote about Unikraft, a unikernel development system. I have been made aware of another one, Nanos. Nanos comes with a build and orchestration tool, OPS. (Both are developed by NanoVMs.)
What's so fascinating about unikernels?
They combine the best of containers and VMs, such as short boot times, small images, or high security.
Moreover, because unikernels run only a single process, the can remove the boundary between kernel space and user space. System calls become faster, and as a result, apps perform much better on a unikernel than on a standard operating system.
Combine this advantage with a feature that unikernel hosting services typically offer: scale to zero. If a unikernel handles no requests, it can shut down completely. Why wasting energy and resources on running an app that does nothing? Just power them down.
Which brings me to internal tools and services. I daresay many companies pay a lot for VMs idling in the cloud because these VMs run low-traffic, low-demand services, yet the web servers, database systems, and various caches and microservices keep humming regardless of whether there's actual work to do.
Resources and energy wasted for zilch.
What if apps are designed and written from the start to minimize startup time? Running on a unikernel, they could wake up when a request comes in, process the request, and exit, just like a Function As A Service (FaaS — think "AWS Lambda").
If an app cannot be designed as a FaaS, it could at least power down after a certain idle time. The first request sent to a powered-down instance would take a bit longer, but subsequent requests while the app is running observe no performance penalty.
Go apps fit extraordinarily well into these scenarios. Go CLI apps can have short boot times as well and therefore don't add much to the (also short) boot times of a unikernel. Go apps need no bytecode interpreter or any kind of application VM in order to run.
Go + unikernels + scale-to-zero look like a dream team.
Why aren't unikernels more popular? (Or is it just me)?
Quote of the week: The next 20 years
I’ve used mainly Ruby for 20 years now. But for the next 20+ years I think Go is for me.
– Derek Sievers on his /now
page (archived copy of the version from 2024-04-25)
More articles, videos, talks
Tokens for LLMs: Byte Pair Encoding in Go
LLMs don't process text ,they process tokens. The most commonly used algorithm for turning text into tokens is Byte Pair Encoding (BPE). Eli Bendersky demonstrates how BPE works by implementing BPE in Go.
Go or Rust? Just Listen to the Bots
So you cannot decide whether to use Go or Rust? Stop asking the Go or Rust communities, or any of the wisecrackers at Youtube. Instead, ask to LLM bots to query each other about their favorite language.
Golang PGO builds using GitHub Actions
How DoltHub uses GitHub Actions for their releases, and how they integrated PGO (profile-guided optimization) into the process.
A Complete Guide to Oauth2 in Golang
A step-by-step how-to guide for implementing authentication with the standard
net/http
server andgolang.org/x/oauth2
.
Go gRPC servers with Bazel in one command
Bazel's strength lies in managing multi-language systems. This sample scenario assumes only Bazel to be installed. Even the Go toolchain is downloaded by Bazel.
xgo trace: a powerful visualization tool in go | Blogs of xhd2015
xgo
is a set of tools for mocking and tracing, primarily made to avoid extracting interfaces for mocking purposes only. Its trace tool comes with a nice Web UI for visualizing traces.
Fundamentals of I/O in Go: Part 3 | by Andrei Boar | Apr, 2024 | Medium
Andrei Boar concludes his 3-part series on I/O fundamentals with an into to buffered I/O.
Efficient store and query labels using compressed btree roaring bitmaps
How Geofrey Ernest implemented a label indexing strategy for his time-series database
requiemdb
.
Conf42's Go 2024 conference took place on April 25th. Transcripts of the talks are available on the website, and the videos are accessible through a (free) subscription.
Projects
Libraries
GitHub - sahib/timeq: A fast file-based priority queue
A fast priority queue where the priority keys can be timestamps (hence the name) or other keys that increase monotonically and produce a low rate of duplicates.
GitHub - francescoalemanno/GoES: GoES: Evolution strategy for black box optimization in pure Go.
The purpose of this package is not quite within my realm of expertise, so let me cite the author: "The GoES package implements an Evolutionary Algorithm (EA) for optimization problems. It employs a diagonal variant of the Covariance Matrix Adaptation - Evolution Strategy (CMA-ES) algorithm, known for its efficiency and robustness in various optimization tasks."
GitHub - jnarcher/sweeper: Play minesweeper in your terminal
In an earlier issue, we have seen a minesweeper implemented with Fyne, now here is one for the terminal. Waiting for more implemetations targeting UIs, frameworks, or apps not particularly suited for games.
Tools and applications
GitHub - creativecreature/pulse: like a fitness tracker for your coding sessions
Fitness watches are so yesteryear. Try this fitness dashboard for your coding activities!
If a full Redis is overkill, try Dare-DB (WIP).
GitHub - dnaeon/makefile-graph: Turn your Makefile into a graph
Makefiles can become unwieldy very quickly. This tool helps untangling the mess by turning dependencies into graphs.
If you want to know what your (unstripped) Go binary is made of,
go-size-analyzer
generates an interactive map of your binary.
Completely unrelated to Go
Your terminal setup can affect productivity
Don't settle with default terminal setups. Start with tweaking the prompt and theme, add aliases, line up useful cli tools, and finally, get some shell plugins.
How I setup my terminal for max productivity
C or Rust? Maybe you'd want to use Go
This is a quite lengthy article about C vs Rust, but Go is briefly mentioned as well, and it gets away quite well:
Systems languages are overused; C vs Rust is a false choice, because compiled languages like Go are often a much better all-around answer economically. Go in particular has decent enough performance that is sufficient for the vast majority of use cases, will be safe, and has good access to low-level systems APIs.
C isn’t a Hangover; Rust isn’t a Hangover Cure | by John Viega | Apr, 2024 | Medium
Invariants are invariant, until they aren't
Code can become wrong without changing a single bit of the source. Just let someone change some specs in a different part of the project without notifying you.
The problem with invariants is that they change over time – Surfing Complexity
Are restrictive copyleft licences more permissive than permissive licenses?
Go is released under a BSD 3-clause license, and many Go projects seem to follow suit and use open-source licenses labeled as "permissive". But are the GNU copyleft licenses really less permissive? It depends on the perspective.
Copyleft does not impose restrictions, but it does impose obligations. The obligations exist to guarantee rights to the users of the software – in other words, to ensure freedoms. In this respect copyleft licenses are more free than permissive licenses.
Copyleft licenses are not “restrictive”
And how do you achieve highest customer satisfaction?
Now that's customer service:
A Random Act of Kindness | Karan Sharma
Happy coding! ʕ◔ϖ◔ʔ
Questions or feedback? Drop me a line. I'd love to hear from you.
Best from Munich, Christoph
Not a subscriber yet?
If you read this newsletter issue online, or if someone forwarded the newsletter to you, subscribe for regular updates to get every new issue earlier than the online version, and more reliable than an occasional forwarding.
Find the subscription form at the end of this page.
How I can help
If you're looking for more useful content around Go, here are some ways I can help you become a better Gopher (or a Gopher at all):
On AppliedGo.net, I blog about Go projects, algorithms and data structures in Go, and other fun stuff.
Or visit the AppliedGo.com blog and learn about language specifics, Go updates, and programming-related stuff.
My AppliedGo YouTube channel hosts quick tip and crash course videos that help you get more productive and creative with Go.
Enroll in my Go course for developers that stands out for its intense use of animated graphics for explaining abstract concepts in an intuitive way. Numerous short and concise lectures allow you to schedule your learning flow as you like.
Christoph Berger IT Products and Services
Dachauer Straße 29
Bergkirchen
Germany