Dealing with time on Go, whether simply unmarshalling string representations of time or handling timezone/locale converstions, is so incredibly convenient. Gone are the days when I'd have to remember the difference between "%MM", "%mm", and "%m".
I have gotten incredibly spoiled in this regard, and it's incredibly painful now to deal with time in Python or (even worse) Javascript[0].
This isn't even getting at the synchronization/timing features, which Go provides amazing support for as well.
Agreed. In particular, I found the "reference value" approach that Go uses for time parsing incredibly quirky, but ultimately intuitive and unambiguous.
It was one of the things I hated about Go! I am entirely comfortable with the POSIX-style %Y, %m, etc. formatting and having to learn Go's silly way to do it annoyed me no end. The documentation should be much more explicit about what the "reference time" thing means for someone used to strftime. http://golang.org/pkg/time/#Time.Format
It took me an unreasonably long time to figure out how that time parsing works. The explanation is not particularly clear. That said, once you understand the format, it is very easy to use.
> For more information about the formats and the definition of the reference time, see the documentation for ANSIC and the other constants defined by this package.
I just didn't "get it" as I had no idea what it meant by a reference time. Normally a time is formatted like %Y-%m-%d and so on, these examples look nothing like that so I had no idea that 2006 is how they spell %Y, 01 is %m, 02 is %d, etc. If you have grown up with strptime and friends, the Go version and documentation makes literally no sense. Then it suddenly clicks ("ah! they do that?!") and it is perfectly obvious.
Using a reference time to describe the layout is pretty brilliant. Out of curiosity, how would it handle non-time "noise" data that happened to be embedded in the string? Expecting "it'll throw an error, also why would you do that" as the answer, but just curious.
Are you talking about some other answer from top one? The one that takes index of current month and prints it? That looks pretty straight forward to me.
Explicitly and manually creating a (mutable!) array of strings for this purpose is rather ridiculous. Contrast with the equivalent code in Go: http://play.golang.org/p/lpYeBYGEv5
It's especially ridiculous in Javascript because the internal functions make use of it (try calling (new Date()).toString()), but they don't give direct access to it.
A well-designed stdlib should handle all of these basic things without requiring the programmer to do any extra work. It's especially important when talking about time, because there are so many wacky edge cases that no programmer is ever going to be able to predict all of them if they have to roll it themselves.
I haven't spent any time looking at Go because I'm pretty satisfied with Ada, but these libs do smell a bit like the Ada time handling functions which only get better through each ISO revision. Not handling dates like POSIX is nothing new, but it some of us just haven't been exposed to it. Of course, Ada would never guess at a format. Blasphemy. The more you know™
I am a freelance Ada developer who is currently working on a contact management system for call centers for a small company. It's the usual array of DB access, webserver and AJAX/websockets. The product is exclusively in Ada though it relies on Freeswitch currently and has recently allowed some Python scripting for calls. The front-end is handled by Ada Web Server which is a rather good Ada HTTP library among other things. Mounds of concurrency and threading in the product back-end.
spacetime.WhereAndWhen, because you might be representing a time in the past, somewhere else, and because most timezones aren't UTC. Good job astronomers of Britain!
Ugh.. time, durations and location is enough to make anyone's head spin. Nice to see how important something so overlooked in many languages is addressed. I haven't personally had the opportunity to play with go but I like what I see.
I'm not sure if this is a joke. None of us have done any work on this for years (yeah, somehow I'm a maintainer for it).
I've gotten go to run on baremetal systems since then, and there have been other operating systems attempts (not to mention rsc's original kernel in go).
I have gotten incredibly spoiled in this regard, and it's incredibly painful now to deal with time in Python or (even worse) Javascript[0].
This isn't even getting at the synchronization/timing features, which Go provides amazing support for as well.
[0] My jaw hit the floor when I saw how difficult it is to get the name of a month from a Date object in Javascript: https://stackoverflow.com/questions/1643320/get-month-name-f...