Re:A million ways to die from a data race in Go
by Someone on Tuesday November 25, 2025 @02:54AM
(#46043399)
> However, are Go programs not supposed to typically avoid sharing mutable data across goroutines in the first place?
C programmers aren’t supposed to access pointers after freeing them, either.
“Easy to do, even in clean-looking code, but you shouldn’t do it” more or less is the definition of a pitfall.
Re:A million ways to die from a data race in Go
by lenkite on Tuesday November 25, 2025 @03:42AM
(#46043708)
There is a LOT of demand for explicit capture clauses. This is one thing that C++ got right and Rust got wrong with all its implicit and magic behaviour.
https://www.reddit.com/r/rust/comments/1odrf9s/explicit_capt...
Re:A million ways to die from a data race in Go
by silisili on Tuesday November 25, 2025 @02:43AM
(#46043313)
Go is a weird one, because it's super easy to learn -if- you're familiar with say, C. If you're not, it still appears to be super easy to learn, but has enough pitfalls to make your day bad. I feel like much of the article falls into the latter camp.
I recently worked with a 'senior' Go engineer. I asked him why he never used pointer receivers, and after explaining what that meant, he said he didn't really understand when to use asterisks or not. But hey, immutability by default is something I guess.
However, are Go programs not supposed to typically avoid sharing mutable data across goroutines in the first place? If only immutable messages are shared between goroutines, it should be way easier to avoid many of these issues. That is of course not always viable, for instance due to performance concerns, but in theory can be done a lot of the time.
I have heard others call for making it easier to track mutability and immutability in Go, similar to what the author writes here.
As for closures having explicit capture lists like in C++, I have heard some Rust developers saying they would also have liked that in Rust. It is more verbose, but can be handy.