4 ms·
>too much "if error return error" noise for my taste. I understand that. I was pointing out this is less noise than try-catch-finally (assuming the programmer
by voidlogic 10y ago
>too much "if error return error" noise for my taste.
I understand that. I was pointing out this is less noise than try-catch-finally (assuming the programmer is comparing Go to C++/Java/C#). I don't deny some functional langs have more elegant handling in this respect.
- spullara 10y agoIt isn't less noisy. With exceptions I can choose to have no noise or concentrate all the noise in one part of the method. In Go there is junk all over the method deeply conflating the good path and the exceptional path.
- majewsky 10y agoIf you add exceptions, you trade noise for action-at-a-distance. From my experience, I prefer a little noise over action-at-a-distance.
- h1d 10y agoEverything is already at a distance when you load libraries and bundle up your commonly used functions elsewhere. DRY principle seems not applicable here.
- Noughmad 10y agoNo, it's not less noise, because with exceptions, you can put all you error handling in one place, or wherever is the most appropriate. With go, you are forced to handle it at literally every function call. If you want some data, "if err != nil return err" contains the four most frequently used words in Go code. See https://anvaka.github.io/common-words/#?lang=go https://anvaka.github.io/common-words/#?lang=go . For comparion, try/catch are only 34th and 35th for Java, and even lower for C# and C++.
- dragonwriter 10y ago> With go, you are forced to handle it at literally every function call. Every call that can fail, which isn't quite every function call.