I'm now inclined to believe that a basically free way to avoid bugs and make things like code review easier and more productive is worth the minor cost of people having to break out of old ruts.
I'm now inclined to believe that a basically free way to avoid bugs and make things like code review easier and more productive is worth the minor cost of people having to break out of old ruts.
> I get lost trying to figure what
> the happy path behavior is.
The happy path is idiomatically at indent level 0. if x, err := doSomething(); err != nil {
} if err := doSomething(); err != nil {
return fmt.Errorf("something failed: %v", err)
}
Or, x, err := doSomething()
if err != nil {
return fmt.Errorf("something failed: %v", err)
}
log.Print(x)The approach I'd like would be a lightweight assert-style failure mode where the compiler would treat any function which returns an error as being followed an implied `if err != nil { panic("Unhandled error") }` unless the error is checked on the next statement. That'd allow you to handle things which you expect to fail regularly while preventing the litany of bugs in C programs caused by forgetting to check return codes on things which rarely fail.
People have been using standard code formatters in Eclipse/IntellIj for what decades now ?
If that were true, the frictional problems I mentioned would not be the rule in every other language. Even something like Python, where PEP-8 has been recommended strongly by the community for many years and has widely available validators and automatic reformatters, still has perpetual low-level debates about this.
In languages like C, where there are multiple well-established conventions, you can still find bitter arguments going on over things like optional braces because there are still tons of bad programmers out there who think it's preferable to ship massive bugs every few years than type two extra characters.