Live data from Hacker News

ECMAScript bind operator proposal

github.com

11–20 of 50 posts

Re: ECMAScript bind operator proposal

#11

there are couple libraries that are build on top of this proposal: https://github.com/jussi-kalliokoski/trine https://github.com/roobie/mori-ext https://github.com/thisables/curry

It also makes Reactive Extensions for JavaScript (RxJS) very nice: https://github.com/ReactiveX/rxjs

Re: ECMAScript bind operator proposal

#12

there are couple libraries that are build on top of this proposal: https://github.com/jussi-kalliokoski/trine https://github.com/roobie/mori-ext https://github.com/thisables/curry

Already had some time on the front page on HN today, but I just released https://zaphod.surge.sh/ which uses it.

Re: ECMAScript bind operator proposal

#13
post #2

Neat! Extension methods and getting rid of "var that = this;" in one! It seems that it also extends to full expressions on the right-hand side of ::, so you can even do, for using Array operations over things that look like arrays but not quite: document.querySelectorAll('p')::([].map)(f) instead of: [].map.call(document.querySelectorAll('p'), f) (replace [].map with Array.prototype.map if it feels less gross)

This also works, by the way:

    [...document.querySelectorAll('p')].map(f)
In the future, NodeList could extend Array which would make these workarounds redundant. Extending Array was made possible by ES6.

Anyhow, I think having some kind of extension methods would be great.

Re: ECMAScript bind operator proposal

#14
post #3

With arrow functions released and class properties likely to be approved soon, this has minimal value and is probably not worth the cost of the extra complexity to the language.

I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…

Wouldn't a pipeline operator [1] be a more interesting solution for this instead of adding syntax that relies on the `this` keyword?

[1] https://github.com/mindeavor/es-pipeline-operator

Re: ECMAScript bind operator proposal

#15
I don't think Ecma-script needs new operators ,especially the kind of operators that will make it look like C++ , just to save a few key types. There needs to be a balance. A balance between all these tricks and readability.

Re: ECMAScript bind operator proposal

#16
post #14

Earlier quoted context omitted.

I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…

Wouldn't a pipeline operator [1] be a more interesting solution for this instead of adding syntax that relies on the `this` keyword? [1] https://github.com/mindeavor/es-pipeline-operator

Yes! Elm has it and it's very nice.

Re: ECMAScript bind operator proposal

#17
This proposal really deserves the "kill it with fire" label. Adding new operators to do things that are already possible will only serve to make the language more complicated and code written in JS more difficult to understand and maintain. JS's minimalism is its greatest strength.

Re: ECMAScript bind operator proposal

#18
post #3

With arrow functions released and class properties likely to be approved soon, this has minimal value and is probably not worth the cost of the extra complexity to the language.

I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…

> It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today."

There is nothing that this proposal does that cannot be done today. It brings nothing new to the table aside from operator noise. I hope the committee pushes against these exotic features, like the bind operator or the pipe operator.

> Right now functional libraries like static-land, ramda, sanctuary, etc. are working hard to provide these functional primitives but it's still painful to write readable code that uses these.

No it's not. explicit != painful .

Do people really want to end up with a spec of the size of C++ spec ?

Re: ECMAScript bind operator proposal

#19
post #2

Neat! Extension methods and getting rid of "var that = this;" in one! It seems that it also extends to full expressions on the right-hand side of ::, so you can even do, for using Array operations over things that look like arrays but not quite: document.querySelectorAll('p')::([].map)(f) instead of: [].map.call(document.querySelectorAll('p'), f) (replace [].map with Array.prototype.map if it feels less gross)

Wow, what an improvement! In fact, why don't we just drop keywords altogether and adopt APL-like syntax for better code concision? Here, let me offer an example of how superior APL is:

  (~R∊R∘.×R)/R←1↓ιR
Post reply on HN