3 ms·
Exceptions are a terrible idea. However, I strongly prefer rust error handling to Go. go: (res, err) := foo() if err != nil return err (res,
by hedora 2y ago
Exceptions are a terrible idea.
However, I strongly prefer rust error handling to Go.
go:
(res, err) := foo()
if err != nil
return err
(res, err) := bar(res)
if err != …
Equivalent rust:
let res = bar(foo)?)?;
I think go should add the ? sigil or something equivalently terse.
Ignoring all the extra keystrokes, I write “if err == nil” about 1% of the time, and then spend 30 minutes debugging it. That typo is not possible in idiomatic rust.
- qaq 2y ago99% of people who never written go will know what the go version does
- wavemode 2y agoThen... look it up? If someone saw "go funcName()" for the first time, would they know how it worked without looking it up?
- qaq 2y agoProb not but I would still argue go is way easier to read than Rust for someone who does not know either.
- cowl 2y agoand 99% of the people will learn the ? shortcut in fraction second. it's just like every other operator ffs. are you dumbfounded everytime you see the channel operators (->) ? noone takes a second thought to them after the first couple of seconds when they encounter them the first time.
- searealist 2y agoequivalent exceptions: let res = bar(foo()); (I think you meant: let res = bar(foo()?)?;
- johnisgood 2y agoI don't want ")?)?;" in Go. I prefer readable syntax rather than symbol soup. In Rust, there are cases where I have seen at least 8 consecutive symbols. Not a fan of that.
- wwweston 2y ago> Exceptions are a terrible idea. I hear people say this frequently, but don't ever hear people actually state the case. My experience is that particularly for web back-end exceptions have been incredibly useful, but I'm interested in the counter view.
- lamp_book 2y agoThis would drive me nuts to write as a Scala dev, but I can see merit to the philosophy. Go basically lowers the ceiling to raise the floor. Meanwhile Scala can let you glimpse the heavens but has no problem showing you the deepest, darkest pits of hell.