5 ms·
> with a convention that you must checktror a non-nil error before using the result. So, you handle the error in the end, or forcefully and intentionally ignor
by bayindirh 3mo ago
> with a convention that you must checktror a non-nil error before using the result.
So, you handle the error in the end, or forcefully and intentionally ignore it. Again, if the code goes boom, it's on the developer, not on Go.
> Rust bakes this into the type system, a function can truly return a result or an error.
Error being a variable or baked into the type system doesn't change the practical result. You must handle the error or purposefully ignore it.
> only Rust actually forces you to handle errors.
When you have two programming languages which makes you handle the error, the word only becomes a little invalid.
Semantics doesn't change the result. You have to acknowledge and act on the error either way.
- resonious 3mo ago> if the code goes boom, it's on the developer This is the same argument C (and Zig!) people have for manual memory management. You can avoid memory problems by being a good developer.
- yoghurtwere 3mo agohttps://www.reddit.com/r/programming/comments/1p0srgs/comment/npld8vh/ https://www.reddit.com/r/programming/comments/1p0srgs/commen...
- stefr- 3mo agoYou pasting this comment link on all the replies clearly shows you don't understand what actually went wrong in this Cloudflare outage. But Rust bad.
- bayindirh 3mo agoWhile I have my opinions on manual memory management, I'll not open that file today (well, it may leak). On the other hand, Go explicitly warns and tries to prevent you from ignoring or not handling possible errors. This is a bit different than a happy C compiler which doesn't warn you about leaking memory.
- madeofpalk 3mo ago> So, you handle the error in the end, or forcefully and intentionally ignore it. Again, if the code goes boom, it's on the developer, not on Go. Except Go doesn’t actually require you to handle the error. You can forget to handle the error, or forget to do a nil check. And Go won’t tell you until it crashes and explodes at runtime. Technically the user’s fault, but good systems protect the users from their own mistakes.
- majormajor 3mo agoIt's not hard to ignore an error in Rust, IME? Especially as someone who's read a lot of code written by newcomers to Rust.
- yoghurtwere 3mo ago.unwrap() https://www.reddit.com/r/programming/comments/1p0srgs/comment/npld8vh/ https://www.reddit.com/r/programming/comments/1p0srgs/commen...
- rowanG077 3mo agoUnwrap is an explicit action. Checking an error is usually just forgotten. No unwrap can enter your code without the dev being accutely aware of it.
- bayindirh 3mo agoYour Go code won't compile if you don't check the error, though.
- rowanG077 3mo agoDid you ever use go? ``` package main import ( "errors" "fmt" ) func getMessage() (string, error) { return "DO NOT INSPECT", errors.New("something went wrong") } func main() { msg, _ := getMessage() // Ignore the error. fmt.Println(msg) } ``` Compiles normally and prints "DO NOT INSPECT"