The languages I'm used to don't even have `nil`.
> "nil" is a perfectly valid value for a pointer to have.
So, just like C and Java. I don't see the difference.
> You can write methods like this: (snippet)
Oh, now I get it: `nil` itself isn't a value. `nil` is syntactic sugar that expands into a nil value. (In other words, confusingly enough, `nil` and “nil value” are different things!) This is unlike Java, where `null` itself is a value.
It would be very helpful if people described things precisely.
> All languages have this sort of wart in them, where two or more perfectly sensible decisions interact to create something that isn't sensible at first glance.
This means that at least one of the two (or more) decisions was less sensible than it originally seemed. Good design decisions don't introduce warts into a system.
func (o *Object) ReturnSomething() int
to func ReturnSomething(o *Object) int
In the first case, it may "seem" that a nil Object would be invalid, but in the second case it's obviously valid, and makes complete sense. It may be described as a "wart", but it makes complete sense to me. The issue is, in my opinion, that people drag their own expectations into programming languages as they learn them.But dynamic dispatch on "what type of object do I not have?" is still a damn weird thing to want.
It the types don't match, the operands are not considered equal. Type and value have to match for two interface values to be equal. How does that not make sense?
For mismatched dynamic types you can't meaningfully compare the values in the general case, so of course you need to consider types.
Because people expect == to compare values, not types. Nobody has ever questioned this behavior in Java and C#.
So as Vendan says, it is just part of the language. All languages have this sort of wart in them, where two or more perfectly sensible decisions interact to create something that isn't sensible at first glance.
(I'm still in favor of going back in time and changing Go to have non-nillable values, but that ship has certainly sailed.)