Re:The search for easier safe systems programming
by gwd on Wednesday May 08, 2024 @06:48AM
(#40296474)
I love Go, but it certainly doesn't have the safety guarantees that Rust has. You're not going to have a memory leak or use-after-free, due to the garbage collector, but you have nil pointer dereferences and data races.
[ Parent
| on HN ]
Re:The search for easier safe systems programming
by binary132 on Wednesday May 08, 2024 @08:29AM
(#40297266)
Also, data races in Go are trivially addressed using the common pipeline / CSP pattern, since channels are serializing. Of course, it doesn’t eliminate the possibility of doing stupid concurrency things, and you could of course argue that giving users trivially easy concurrency primitives encourages stupid concurrency, but I think it is fair to say that in most cases, Go idioms and primitives make race-free concurrency pretty easy. You have to go out of your way to write racy Go, and there’s nothing really preventing people from going out of their way to write unsafe Rust, either.
Re:The search for easier safe systems programming
by angra_mainyu on Wednesday May 08, 2024 @07:42AM
(#40296864)
Strange, I've worked on complex projects in the distributed space with Go and it's very easy to catch these things with `-race` and linters.
Re:The search for easier safe systems programming
by binary132 on Wednesday May 08, 2024 @08:14AM
(#40297131)
nil dereference isn’t unsafe.
Re:The search for easier safe systems programming
by imtringued on Thursday May 09, 2024 @02:54AM
(#40305919)
It's undefined behaviour, which is even worse!
Re:The search for easier safe systems programming
by binary132 on Thursday May 09, 2024 @10:34PM
(#40314975)
Nope. Nil deref in Go is checked, and simply panics, just like array access out of bounds.
Re:The search for easier safe systems programming
by usrnm on Wednesday May 08, 2024 @07:13AM
(#40296650)
I have seen more leaks in the golang project I currently work on than in most C++ codebases I've worked with in my career. It's trivial to leak stuff in golang, and much more difficult to make sure that you don't
Re:The search for easier safe systems programming
by binary132 on Wednesday May 08, 2024 @08:10AM
(#40297090)
Ok? Is it not trivial to leak in unsafe rust? Managed memory is safety.
Re:The search for easier safe systems programming
by pdimitar on Wednesday May 08, 2024 @07:14AM
(#40296653)
And it's trivially easy to ignore an error.
Also channels and WaitGroups are easy to misuse (well, that's why there's also an ErrGroup now).
I'd make Golang my 100% go-to language if it got rid of several footguns.
Though let's be real, that's absolutely certain to never happen, they take their backwards compatibility extremely seriously. So we'll have to keep relying on checkers and linters that alleviate some of the pains somewhat.
Re:The search for easier safe systems programming
by angra_mainyu on Wednesday May 08, 2024 @07:44AM
(#40296883)
I'm not aware of any serious Go project without linting and tests.
In fact, most projects I've worked on won't even merge a PR with ignored errors.
Also, `go test -race` is a Go feature, there's nothing wrong with using it.