Frozen Date objects?

Brendan Eich brendan at
Mon Jul 22 18:12:06 PDT 2013

Jonas Sicking wrote:
>> 2) APIs may return Date objects but they should always be newly created instances and never retain references to them.  An API client might mutate such returned Date objects but that's really the clients business  and it will have no impact upon the DOM.
> The emails in this thread seems to indicate that we should in fact not
> return Date objects ever (though like any rule, I could imagine there
> being exceptions). Instead we should simply return numeric timestamps.


Dave has a sad history. Cloned from JDK1.0 java.util.Date, y2k-bugs and 
all, with hidden mutable state, it still vexes. On top of the legacy 
smell, the question arises: why create an object with mutable state when 
you are expressing a universal time coordinate?

A number wins in almost all cases, for economy and precision, if not 
economy of expression for code that will (somewhere) use the timestamp 
to create a Date object to present some strings to a user.


More information about the es-discuss mailing list