Globalization API discussion

Nicholas Zakas standards at
Fri Nov 18 11:26:29 PST 2011

As part of the group that said the API is too Java-like, I'd like to
clarify. "Java-like" to me means that you need to create one or more
objects that are only kept around for a short period of time to
perform a single task. For example, if I already have a Number object
and want to format that number as currency, I'd expect to be able to
do something like this:

var price = 300,
    currency = price.toCurrencyString("USD");

Likewise for formatting dates:

var now = new Date(),
    pretty = now.toFormatString("mm/dd/yyyy");

Or some such thing. Realizing, of course, the discussion around
wanting to avoid formatting strings.

I'll be writing up a longer piece of feedback this weekend.


On Thu, Nov 17, 2011 at 5:29 PM, Brendan Eich <brendan at> wrote:
> On Nov 17, 2011, at 2:22 PM, Nebojša Ćirić wrote:
>> Q. API is too Java like. Use shorthand to invoke formatters.
>> A. I would like to hear proposals on how to make it more JS like. Adding
>> shorthand syntax is easy, but most of TC39 members were against having 2
>> ways of doing things first time we proposed it.
>> Here is an example of current API in action -
> Would converting constructors into factories help make API less Java like?
> For example, instead of:
> var dtf = new DateTimeFormat(...);
> we have
> var dtf = createDateTimeFormat(...);
> No, that's worse. Constructors used with 'new' are ok if you really need a
> new object to do something.
> What's JS-esque is to use a *function* when you don't need to allocate an
> object just to call one method on it, then let it become garbage to collect.
> Also being able to use the function as a first-class value (pass it around
> as a funarg, stick it on some other object, decorate it with ad-hoc
> properties).
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at

Nicholas C. Zakas

More information about the es-discuss mailing list