Globalization API discussion

Brendan Eich brendan at mozilla.com
Thu Nov 17 14:29:56 PST 2011


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 - http://pastebin.com/pjfdKYss
> 
> 
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111117/f2370b33/attachment.html>


More information about the es-discuss mailing list