Alex Russell alex at
Fri Apr 30 22:21:17 PDT 2010

On Apr 30, 2010, at 5:33 PM, Jürg Lehni wrote:

> Brendan,
> Thank you for clarifying.
>> But did you know that Dojo's hitch also allows leading arguments to be bound too? Likewise MooTools's bind. Only jQuery's proxy does not.
> I did not know about Dojo's hitch, but I believe Mootools' bind is not behaving in the same way. It receives an array as a second argument, defining the arguments to be passed to the bound functions, and appears to ignore any other parameters passed to it when calling. I actually prefer this passing of arguments in an array over the standardised bind, for reasons explained in my previous email.
> But this means libraries like MooTools automatically break the JavaScript standard, as now Function.prototype.bind gets overridden with an incompatible version. And it also is too late for MooTools to change that now, as such a change would break all depending code at once.

Libraries that extend intrinsic prototypes deserve any and all pain that comes to them. Their users should likewise be warned of the impending pain; but no affordance should be made for their poor decision making when it comes to designing a better API for users of the language.

> This then raises other interesting questions: Should libraries refrain completely from polluting any of the default prototypes?

Yes, absolutely, 100%.

> How else can one be sure there won't be a standardised property in the future that might overlap with functionality of a library in such a way?

And why is that the language's job? As a library author, the goal for me of a library was always as a stop-gap until the cavalry arrived. Now that they're showing up, I'm glad to un-plant my flag and cede the high ground to the committee.

>> I always say that it is early days in the JS library standardization process, and we should not prematurely standardize. Nevertheless I think ES5 is better off with Function.prototype.bind than without. We could have done nothing to serve this use-case, but that seems strictly worse. We could have done something else but it would have been under a different name.
>> Instead we went with what seemed the de-facto standard. It's still a point in common among several top libraries.
> I can only see one library that exactly follows the standard, or the other way round; Prototype.js. Dojo's hitch does many other things as well, but it might be able to use the native bind now to optimise that particular case. MooTools' bind shares the name but behaves differently. And jQuery is as always fine as it does not mess with the prototypes.

Dojo's hitch doesn't touch prototypes. With non-intrinsic-munging libraries do is between them and consenting users. It's only libraries that are foolish enough to extend intrinsics that are at any risk here, and as I said, they deserve it.


> In this case I get the feeling everybody could have benefitted from a Function.bind generic that all the different implementations in the prototype could refer to, but nothing standard in the Function.prototype object.
> Such a Function.bind could then have been defined to receive the arguments in one array object, and to concatenate them with the ones passed to the returned function when calling. This would have allowed all the different implementations mentioned above to use it in an efficient way.
> But I guess there is no point crying over spilled milk, and I agree, it is better to have the current Function.prototype.bind than nothing at all.
> At the same time I believe it is also important to understand that libraries are good sources of hints for what needs to be improved in the language, but not necessarily for how, as such libraries do not have the same amount of freedom in the formulation of functionality, and often aim for solutions that produce little source code or can reuse functionality defined elsewhere in the library. This is then not necessarily the right way to implement it natively.
> Jürg
> _______________________________________________
> es-discuss mailing list
> es-discuss at

Alex Russell
slightlyoff at
alex at BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723

More information about the es-discuss mailing list