by macrael · 5y ago · 0 comments
My harebrained idea (obviously we can't change it) is that if nil pointers didn't exist the language would be much better. Require that a pointer always has to point to an address and then people couldn't have built all this infrastructure using nil pointers (something that rightly has to do with reference semantics) to indicate nil values (something that has to do with the meaning of the code)
There are multiple ways to declare a variable, to pass a value to a function, to declare a constant, to create something similar to an enum, to return errors, to check for errors, to handle closing, to synchronize parallel threads of execution, to initialize a struct, to create a list of items. I can probably go on.
What are some examples where Go is simpler than Java, other than its current lack of generics which has always been a known-limitation?
if (ptr == null) {
return nil, fmt.Errorf("bad");
}
val := *ptr
or let value = ptr?
If `?` is unacceptable complexity, how on earth do you deal with functions—or, even worse—control flow keywords?Subtle differences in similar looking code can trip people and increase complexity. Fortunately, go has a good standard library to compensate for some of it.