[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [OT] Lua community and Go language
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Thu, 08 Aug 2013 17:23:57 +0200
On 08/08/2013 15.37, steve donovan wrote:
> On Thu, Aug 8, 2013 at 3:20 PM, Lorenzo Donati
> <lorenzodonatibz@tiscali.it <mailto:lorenzodonatibz@tiscali.it>> wrote:
>
> fmt.Println(time.Now().Format("2006-01-02 03:04"))
>
>
> It is very .. eccentric. Rob Pike is very proud of this idea ;)
VIP people can do whatever they like with their toys ;-)
But the ancients had a lot to say about hubris being the sin of the
mighty ones ... :-)
>
> I guess all languages have their weird bits, although I can no longer
> tell what's weird about Lua. A feeling of weirdness is just cognitive
> indigestion - obviously I've just got used to things as they are.
>
Well, yes. Every language has some. As a general rule of thumb I like
languages which try to come close to natural language (Chomsky hierarchy
permitting) without being too verbose at the same time.
So i tend to interpret the line
fmt.Println(time.Now().Format("2006-01-02 03:04"))
approximately as:
print a line containing the current time formatted as ...
and till this point it is fairly good, but then comes the distractor
... as "2006-01 ...etc."
so my brain starts thinking why this special date must be there. Why not
"1990-02...etc". It is just the wrong bit of information. Wrong because
it doesn't belong there. It has nothing to do with the code I'm writing.
It is an arbitrary artifact of the API design. Just smoke in your eyes.
No more helpful than "%Y-%M .. etc.", but in this latter case there is
no distracting factor, it is evident it is a template for something and
not a sort of "date literal". FWIW they could have chosen to parse also
"YYYY-MM-DD HH:SS", or "year-month-day".
Moreover it fails miserably on such simple things:
fmt.Println(time.Now().Format("I drank 15 bottles of beer in 2006") )
which prints:
I drank 23 bottles of beer in 2009
instead of:
I drank 15 bottles of beer in 2009
Debug this! You get the point. :-)
So whenever you must construct non trivial messages involving dates you
end up doing more work!
I wonder if Pike's idea has some followers. Maybe it's me, but I really
cannot see any advantage beside screaming to a non programmer reading
the code "hey, look at me, I'm a date!" (and only in the most simple
cases, as the above trivial example shows).
--
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments