Chapter 8 of The Anatomy of Go is now available. It discusses channels, timers, concurrency, goroutine creation and lifecycle, runtime startup, preemption, scheduling, I/O handling, the system monitor... and a bunch of other things.
The book is now complete at 873 pages, and early access will be closing soon after the editing phase, (which may add a few more pages).
As usual, here is an excerpt:
If your are interested in why VictoriaLogs is so efficient and fast, then take a look into these slides about VictoriaLogs architecture internals -
https://t.co/kR0KxEFwzo
Enums are good. I wish Go supported "real" enums. But union types are not, at least IMO.
At the very least, I do not want union types in a TypeScript-ish form:
func F(x int | string | []byte | io.Reader) { ... }
This function accepts many unrelated shapes of input.
Inside the function, you must figure out which one you got.
It's never good to be too convenient. It loosens the language in a way that makes APIs harder to reason about.
If Go somehow were to add union types, a more Go-ish version would be:
type ParseResult[T] union {
Ok(T)
Err(error)
}
type Shape union {
Circle(radius float64)
Rect(width, height float64)
}
That is closer to an enum with payloads, or a sum type or tagged union or Rust-style enums. It keeps the set of cases closed and explicit.
Go does not need "any value can be A or B or C" union types. Go would benefit from "this domain value has one of these known variants" sum types.
You cannot pass values like in TypeScript:
f(123)
f("hello")
You need to pass explicit variants instead, assuming Input is a tagged union:
f(Input.Number(123))
f(Input.Text("hello"))
More verbose but safer and stricter.
See more at
https://t.co/yQFrIj3DVP
https://t.co/Y1G1TaE9Zd
hot take: Go would be the greatest programming language on earth if it had enums and union types. they simplified their way into having to do really weird stuff just to represent reality.
you should still probably use it though.
"We weren't gambling on a new technology — we were promoting one we'd already been operating in production against our own workload, and that consistently outperformed Loki in our side-by-side testing on the kinds of queries we and our users actually run."
Something is seriously wrong with how people contribute to open source these days.
People submit AI-generated code they clearly don't understand. When reviewers comment, they feed it back to the AI and submit again. The loop never ends.
Low-effort PR requires extremely high effort to review. That math is never fair.
You think this is how you build a reputation in open source? No, no, and no. You're just burning out maintainers.
---
Use AI to understand the codebase instead. Ask it to explain things. Build your own judgment. It's ok to use AI as a tool for coding, but make sure you filter out any AI slop before submitting.
You gain the skills. You gain the reputation. The project actually benefits.
Is it that hard?
@HSVSphere@JustDeezGuy Because you don't need that level of concurrency abstraction most of the time. context, waitgroup, errgroup, clear ownership patterns cover many common cases well
@raghavan_srini Agreed, though most backend systems people build aren't mission-critical at that level. Go ofc can, it just shifts responsibility to developers or to higher-level tooling
Go is not bad at concurrency. A more factual take is Go is excellent at making concurrency cheap, explicit, and approachable (and approachable, and approachable), especially for common backend patterns.
But Go gives you relatively low-level primitives, a lot of correctness around cancellation, task lifetimes, cleanup, error propagation, and backpressure is left to us, the programmer.
So the fair comparison is not "Go vs JVM, who wins?" It is: Go optimizes for simple pragmatic concurrency, the modern JVM ecosystem has stronger tools for structured and resource-safe concurrency. Which one is better depends on how complex the concurrency problem is. This is just a "depends on the problem" discussion.
Generally developers think of Go as being great for concurrency. Its not. JVM approaches are vastly superior. And even some of the best in the whole industry when you include virtual threads, structured concurrency & Effects.
Chapter 8 of The Anatomy of Go is ready for review. It goes into concurrency, the Go scheduler, threads, the system monitor thread, goroutine preemption, what happens at startup, how channels work, how the select statement works, and how timers work behind the scenes, a lot and a lot, with visual explanations.
This is the final chapter, it is near the end of the journey.
Who's the biggest Victoria-stack bull in my feed that wants to say why they love it?
I'm yolo porting from Prom/Loki etc in a project because I saw some nice numbers in the past and want to try it out but want to hear some people that are excited by it geuinely