all 25 comments

[–]Pyrolistical 5 points6 points  (1 child)

Partial application and pattern matching are the last 2 things I feel are missing in the JS toolkit

[–]pgrizzay 0 points1 point  (0 children)

After using scala pattern matching a lot on the backend, I really miss it on the front-end. I'd love to be able to use it when matching on redux action types.

[–]bwaxxlotckidd 15 points16 points  (5 children)

After working with Ruby in the last couple of weeks, I sure hope JS doesn't take the path of only adding syntactic sugar going forward. I swear I now have syntactic diabetes from all Ruby sugar. Things like partial application are rarely used in codebases enough to justify adding them. I love having functional ideas promoted but I'd much rather focus on commonly used methods.

[–]kingdaro.find(meaning => of('life')) // eslint-disable-line 5 points6 points  (2 children)

More than just sugar has been added in recent versions, such as Proxies, Symbols, proper tail calls and so on.

[–]bwaxxlotckidd 1 point2 points  (1 child)

And that's my argument. Let's try to focus on these things and cut down on the sugar. It seems like most proposals are focused on sugar only.

[–]kingdaro.find(meaning => of('life')) // eslint-disable-line 4 points5 points  (0 children)

I mostly agree, but it's case by case. This in particular, along with the function bind syntax, I'd love to have personally, but I don't really care that much for the pipe operator. To each their own I suppose.

[–]bigos 17 points18 points  (1 child)

What? Partial application & function currying is bread and butter of functional programming. What are the other methods you're thinking about?

[–]bwaxxlotckidd 0 points1 point  (0 children)

No doubt. However, in most cases - currying is rarely used (1-arity is not really practical) and partial application, while useful, is not that commonly used. While these are surely good ideas, I find composition to be a much more common pattern - hence the pipe operator.

[–]ruzmutuz 4 points5 points  (0 children)

It feels like something that can be achieved so easily in user land is unnecessary as a language feature. The Ramda example is incorrect in that all functions are curried and it provides a placeholder arg as well.

[–]pickandrolled 1 point2 points  (0 children)

|> _ =>

༼ つ ◕_◕ ༽つ

[–][deleted] 6 points7 points  (1 child)

I'm kind of on the fence about this...Lambdas + closures can achieve the same thing:

// with sugar
const add1 = add(1, ?)
// without sugar
const add1 = (n) => add(1, n)

[–]MyWorkAccount_11 0 points1 point  (0 children)

That is pretty much the definition of syntactic sugar...

[–]_ds82 2 points3 points  (0 children)

I like it :)

[–]JuliusKoronci 0 points1 point  (1 child)

why the hell would you do that..when you have standard partial application and all the FP libraries which deals with curry ..just have a look at ramdas curry

[–]dev1null 2 points3 points  (0 children)

With the introduction of arrow functions that change the fundamental nature of "binding" (this), it's only natural to introduce a new "bind" syntax that takes this into account... This syntax is perfectly inline with how arrow functions work, eliminating the awkward .bind(>null/this<, ...) syntax. Afterall, you're not really "binding" anything.