3 ms·
I really didn't mean to make this about Zig vs Rust. That was a mistake. My real point is that Zig is also a great language, even when you care about safety. T
by hansvm 1y ago
I really didn't mean to make this about Zig vs Rust. That was a mistake. My real point is that Zig is also a great language, even when you care about safety.
That said, the things you asked about:
1. I suppose you might get away with linting all of shadow_reuse, shadow_same, and shadow_unrelated. Would that sufficiently disable the feature?
2. The biggest problems with overusing `anyhow` to circumvent the language's error system are performance and type safety. Perf is probably fine enough for most applications (though, we _are_ talking about systems programming, and this is yet another way in which allocation-free Rust is hard to actually do), but not being able to match on the returned error makes appropriately handling errors clunkier than it should be, leading to devs instead bubbling things up the call stack even more than normal or "handling" the error by ignoring any context and using some cudgel like killing connections regardless of what the underlying error was.
3. Rice's Theorem is only tangentially related. Your goal, and one that Rust also strives for, is to make it so that changes to the type signature of a function require compatible changes at call sites, which you can often handle syntactically. Rust allows `let _ = foo()` to also silence errors, and where Zig normally allows `_ = foo()` to silence unhandled return values it additionally requires `try`, `catch`, or `return` (or similar control flow). You have options like `_ = foo() catch {}` or `_ = foo() catch @panic("WTF")` if you really do want to silence the error, but you'll never be caught off-guard by an error being added to a function's return type.
- tialaramex 1y agoWell, merely warning won't disable the feature. You could `forbid` these lints, and then require clippy for CI or something, the same way many people require unit tests pass in CI. I'd be very surprised if you find all three problematic. The problems you described feel like shadow_unrelated You are absolutely right that anyhow doesn't do what you want for a no-alloc situation like a kernel driver or some ESP32 firmware - however it won't compile without an allocator, so, seems like you'd be shifting that problem hard left, the programmer who adds anyhow to their no allocator firmware can't build it. Yes, I see now what Zig has here is literally a syntax check and so Rice doesn't apply because in Zig the function which returns an error is syntactically different and so Zig can say hey, this is an error function and those are different. I prefer the situation in Rust, but this is an important difference albeit one I don't agree with.