Live data from Hacker News

Thoughts on Go vs. Rust vs. Zig

sinclairtarget.com

311–320 of 599 posts

Re: Thoughts on Go vs. Rust vs. Zig

#311
post #184

Earlier quoted context omitted.

30 years in C/C++ here. Give an example of UB code that you have committed in real life, not from blogs. I am genuinely curious.

> Give an example of UB code that you have committed in real life struct foo { ... atomic_int v; ... }; struct foo x; memset(&x, 0, sizeof(x));

I don't think it's UB if you init the struct before using it atomically from multiple threads.

Re: Thoughts on Go vs. Rust vs. Zig

#312
post #76

I think the Go part is missing a pretty important thing: the easiest concurrency model there is. Goroutines are one of the biggest reasons I even started with Go.

The new (unreleased right now, in the nightly builds) std.Io interface in Zig maps quite nicely to the concurrency constructs in Go. The go keyword maps to std.Io.async to run a function asynchronously. Channels map to the std.Io.Queue data structure. The select keyword maps to the std.Io.select function.

Re: Thoughts on Go vs. Rust vs. Zig

#313
post #214
post #29

> In Rust, creating a mutable global variable is so hard that there are long forum discussions on how to do it. In Zig, you can just create one, no problem. Well, no, creating a mutable global variable is trivial in Rust, it just requires either `unsafe` or using a smart pointer that provides synchronization. That's because Rust programs are re-entrant by default, because Rust provides compile-time thread-safety. If…

> [...] is trivial in Rust [...] it just requires [...] This is a tombstone-quality statement. It's the same framing people tossed around about C++ and Perl and Haskell (also Prolog back in the day). And it's true, insofar as it goes. But languages where "trivial" things "just require" rapidly become "not so trivial" in the aggregate. And Rust has jumped that particular shark. It will never be trivial, period.

[deleted]

Re: Thoughts on Go vs. Rust vs. Zig

#314
post #222
post #214

Earlier quoted context omitted.

> [...] is trivial in Rust [...] it just requires [...] This is a tombstone-quality statement. It's the same framing people tossed around about C++ and Perl and Haskell (also Prolog back in the day). And it's true, insofar as it goes. But languages where "trivial" things "just require" rapidly become "not so trivial" in the aggregate. And Rust has jumped that particular shark. It will never be trivial, period.

> languages where "trivial" things "just require" rapidly become "not so trivial" in the aggregate Sure. And in C and Zig, it's "trivial" to make a global mutable variable, it "just requires" you to flawlessly uphold memory access invariants manually across all possible concurrent states of your program. Stop beating around the bush. Rust is just easier than nearly any other language for writing concurrent programs,…

[deleted]

Re: Thoughts on Go vs. Rust vs. Zig

#316
post #214
post #29

> In Rust, creating a mutable global variable is so hard that there are long forum discussions on how to do it. In Zig, you can just create one, no problem. Well, no, creating a mutable global variable is trivial in Rust, it just requires either `unsafe` or using a smart pointer that provides synchronization. That's because Rust programs are re-entrant by default, because Rust provides compile-time thread-safety. If…

> [...] is trivial in Rust [...] it just requires [...] This is a tombstone-quality statement. It's the same framing people tossed around about C++ and Perl and Haskell (also Prolog back in the day). And it's true, insofar as it goes. But languages where "trivial" things "just require" rapidly become "not so trivial" in the aggregate. And Rust has jumped that particular shark. It will never be trivial, period.

[deleted]

Re: Thoughts on Go vs. Rust vs. Zig

#318
post #272
post #218

Earlier quoted context omitted.

That makes even less sense becasue go errors provide even less info other then a chain of messages. They might as well be lists of strings. You can maybe reassbmle a call stack your self if all of the error handlers are vigalente about wrapping

> That makes even less sense becasue go errors provide even less info other then a chain of messages. That doesn't make sense. Go errors provide exactly whatever information is relevant to the error. The error type is an interface for good reason. The only limiting bound on the information that can be provided is by what the computer can hold at the hardware level. > They might as well be lists of strings. If a strin…

Chill with being condescending if you want a discussion.

The error type in go is literally just a string

type error interface { Error() string }

That's the whole thing.

So i dont know what your talking about then.

The wrapped error is a list of error types. Which all include a string for display. Displaying an error is how you get that information to the user.

If you implement your own error, and check it with some runtime type assertion, you have the same problem you described in python. Its a runtime check, the API your relying on in whatever library can change the error returned and your code won't work anymore. The same fragile situation you say exists in python. Now you have even less information, theres no caller info.

Re: Thoughts on Go vs. Rust vs. Zig

#319
post #222

Earlier quoted context omitted.

> languages where "trivial" things "just require" rapidly become "not so trivial" in the aggregate Sure. And in C and Zig, it's "trivial" to make a global mutable variable, it "just requires" you to flawlessly uphold memory access invariants manually across all possible concurrent states of your program. Stop beating around the bush. Rust is just easier than nearly any other language for writing concurrent programs,…

Is it easier than golang?

https://www.ralfj.de/blog/2025/07/24/memory-safety.html

Go is by default not thread safe. Here the author shows that by looping

    for {
        globalVar = &Ptr { val: &myval }
        globalVar = &Int { val: 42 }
     }
You can create a pointer with value 42 as the type and value are two different words and are not updated atomically

So I guess go is easier to write, but not with the same level of safety

Re: Thoughts on Go vs. Rust vs. Zig

#320
post #222

Earlier quoted context omitted.

> languages where "trivial" things "just require" rapidly become "not so trivial" in the aggregate Sure. And in C and Zig, it's "trivial" to make a global mutable variable, it "just requires" you to flawlessly uphold memory access invariants manually across all possible concurrent states of your program. Stop beating around the bush. Rust is just easier than nearly any other language for writing concurrent programs,…

Rust is a 99% solution to a 1% problem.

It they had not messed up async it would be much better
Post reply on HN