It's kinda the equivalent of making a new language (nowadays) and not defining what encoding your native strings use. Of course it's going to cause problems. Except the timer issue has been around much longer than the standardization on utf-8.
But personally I don't agree with the decision - it adds surprises when you try to convert times to other types and then compare things. Or convert to something else and then back to a time instance. I've watched things like this become the source of bugs many, many times - this will only make that worse, since now a "time" is two values but you can really only access one of them (the one that's equivalent to wall-clock, which is causing the problems). And they're particularly painful bugs, because the cause lies in implicit conversions and behavior. That seems to run counter to the "minimal surprises" that Go seems to prioritize.
But, I could easily see looking back in 2 years and realizing you were right.
That code-corpus-analysis is pretty neat, I hadn't looked through in detail before. Thanks for pointing it out!
---
Sorta as an aside, it seems the proposal can lead to:
t1 = time.Now()
...
t2 = time.Now()
diff = t2.Sub(t1)
t1.Add(diff) != t2
Times are hard :| t1.Add(diff).Equal(t2)
would still hold, because Now gets monontonic time, Add and Sub maintain it, and Equal checks it. // time = [wall, mono], just ints for simplicity
t1 = time.Now() = [10, 10]
t2 = time.Now() = [19, 20] // wall clock lags slightly on second measure
diff = t2.Sub(t1) = (20 - 10) == 10 // Sub only operates on mono-time
t1.Add(diff) == [20, 20] // Add adds `diff` to both wall and mono
[20, 20] ==?== [19, 20]
I'd expect those to be different, since they represent different wall-clock times.So t2.Equal(t1) is true.
You are right that "t1 == t2" (comparing the raw bytes of the time structures) is false, but that was already broken anyway (because time-zones break raw byte equality).
(Whether you think it's OK to have a language that doesn't overload == and makes you know that for complex structures you've got to call a method like Equal() probably correlates pretty highly with your opinion of Go.)
There will of course be other weird things, like:
print(t1) // "20 [20]"
print(t2) // "19 [20]"
But you could argue that's basically the least-surprising possible result in the face of the surprising fact time having gone backwards one second. :)By the way, worth mentioning that while this is all implemented in HEAD in Go, it's not a done deal yet -- it'll have a 3-month window for people to try it out in the real world, and if it's found to be problematic, it'll get backed out before becoming part of the official release.
Gotcha, I missed that somewhere. That's essentially fine - then the only real surprises are when you deserialize a Time (so it doesn't have a mono time), which should in principle have no interactions with this proposal.
And yeah, Equal vs ==, the meaning was clear enough that I didn't bother to be specific :) Thanks for the infos!
Seems to be some cognitive dissonance (in the modern erroneous sense of the word) going on. This was a hack necessary because the design of the library wasn't fully thought out. Imagining the world would one day become Google is not thinking things out.
And that's just an example that was intended to illustrative.
You'll just have to take my word for it that my experience of the Go ecosystem, tools, and standard library has been more solid than the various other things I've used over the years (python, C# + unity, c++, fucking maven, boost...).
If I'm missing out on something even better, let me know. ;-)
Easy to say 'not fully thought out'. It took Java from version 1.2 to 1.8 to fix its date/time library.
It took Java from version 1.2 to 1.8 to fix
its date/time library.
That is incorrect[0]. When spreading FUD[1], expect assertions such as these to be fact checked by others.0 - http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22joda-time...
1 - https://en.wikipedia.org/wiki/Fear,_uncertainty_and_doubt
An excellent example is the handling of this bug report(§):
https://github.com/golang/go/issues/12914
which resulted in this language-change proposal:
https://github.com/golang/proposal/blob/master/design/12914-...
And then these commits:
https://go-review.googlesource.com/#/c/36255/
I feel like any other language I've used would've just added a "monotonicTime" function and called it a day; the Go solution is impressive, elegant, and shows an exceedingly high level of care for the end-outcome results for the users of the language.
To me, that's what makes Go special.
(§After a rocky start; it took the core devs a bit to realize it was a real issue because within Google's special environment it isn't.)