Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@i @mint
> is if err != nil { return nil, err } any better?
Yes. Guard clauses are better than indeterminate levels of nesting. Anyone who has personally encountered "callback hell" can tell you this was true in chodejs (before it came up with one of the dumbest possible ways of doing CSP), same with anyone that had to deal with single-point-of-return languages after Dijkstra wrote that anyone that puts multiple returns in a single function has cooties.
> what happens when you forget to copy paste it once, and no one notices for 6 years?
If you're copying and pasting much, you're doing it wrong. At any rate, pointing out that Go has infelicities doesn't mean anything; any language has infelicities. But some languages are nice and you can write code that you are happy with, and some languages suck and the code looks ugly even if it was written by people that are fluent.
To expand on your point about how we could all get by with COBOL, COBOL does that "ADD 1 TO X YIELDING Y" bullshit and that is verbose and ugly: it's not a matter of engineering discipline, the language is a pain in the ass, and full of boilerplate. All the engineering discipline in the world doesn't make COBOL a nicer language than, say, Forth or even FORTRAN.