NateDad
Joined 14 years ago
Joined 14 years ago
But you know what, go is easy to learn, and that's been awesome in my experience. I can (and have) hired people who have never written go, and they're productive in a week or two.
I guess what you can't do by just using the contract name is say that two arguments must be of the same type. Nevermind.
Go's error handling isn't any more error prone that writing if statements for all the rest of your code. if err != nil is no different than if age < 18. Either one is a branch in the code. I can literally count on one hand the number of times in 6 years of full time go development that I've seen people miss writing the if err != nil.
Being explicit is good. Spreading out the logic is good. Cramming a lot of logic into one line is bad.... and that's the sole purpose of try.
Maybe there's another way to make error handling better in Go. I'm not averse to looking into that. But try wasn't it.
You're talking about writing if err != nil being tedious, but what about matching Results from Rust, isn't that tedious? What about writing proper catch blocks in java or C++ or python, isn't that tedious? It's all just logic.
I almost never see code that application developers write using it, and usually if someone is writing that code, it's wrong, and I help them figure out how to avoid it.
Usually you can avoid it by using closures or interfaces.
Many many places are using go here and there. From start ups to big enterprises.
It's rarely all they do, but it's pretty common to have some backend in go.
names = append(names, "Bob")
.... that's really it. Will it have the same backing array as it did before you did append? Maybe, maybe not. Should you care? Absolutely not, and if you do, you're probably doing something wrong.Rob Pike's example code is bad and I would not allow it through a code review. Why? It makes the code lie. It appears as though the writes cannot fail, but in fact they can, and later writes become no-ops. On top of that, it means that you lose the context of which write failed. Did you fail writing the header, the body, or the footer? You can't know anymore.
This is like
try {
doThing()
doThing2()
doThing3()
catch (Exception ex) {
// handle
}
You can't tell what failed. You can't tell what is possible to fail. The handler can't differentiate.
[ my public key: https://keybase.io/natefinch; my proof: https://keybase.io/natefinch/sigs/4vluNroUMrNptUZ0-yf__o_BjbNO7CcrsudVWRG5Xc0 ]