3 ms·
Maybe go just isn’t for you? It really doesn’t need every feature of other languages. The error handling is ideal for me, better than any other language. You ar
by BytesAndGears 2y ago
Maybe go just isn’t for you? It really doesn’t need every feature of other languages. The error handling is ideal for me, better than any other language. You are always explicit, with every function call, about “what could happen if this fails?”
Maybe passing it up the stack is the best way to handle it, but also maybe it’s better to handle it somewhere in the middle.
The thing that always happens with exceptions in API projects I’ve worked on, is that exceptions can come from any level of the stack, then by default it skips everything in the middle, and the controller has default handlers for what to do in case of an exception.
If there are exceptions you didn’t know existed because of some library or just complex code with dozens of possible exceptions? They still end up being handled in your controller. You need to know exactly what exceptions could happen at every level of the stack, and how to handle it, otherwise everything just short circuits.
With the go errors, you only need to know “did this function call work? If not, then what?”
- hedora 2y agoExceptions 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.