News for hackers. Stuff that matters.
Re:TC39 Pipeline Operator – Hack vs. F# by azangru on Tuesday September 14, 2021 @04:58PM (#28531078)
> once you move away from toy examples, most pipeline operator use cases are already covered by chaining class methods on classes

But what if we don't want to use classes? What if we want to be cool and compose functions out of functions, Ramda-style, or Elm-style?

Re:TC39 Pipeline Operator – Hack vs. F# by nsonha on Tuesday September 14, 2021 @05:17PM (#28531389)
Unpopular opinion: we could just add, say, `pipe` and `pipeAsync` into the standard library, appart from aesthetic, I don't see the pipe operator to be very useful, at least the F# one doesn't because it's literally just another syntax for function invocation.
Re:TC39 Pipeline Operator – Hack vs. F# by slaymaker1907 on Tuesday September 14, 2021 @05:54PM (#28531932)
It is useful as an operator due to the fact that you avoid unnecessary function calls/lambda creation. "pipe(x, f, g, y => h(42, y))" is not going to be as easy to optimize as "h(42, g(f(x))" yet "x |> f |> g |> h(42, ^)" has the ordering of the pipe function while being equivalent to normal function invocation for the purposes of optimization.

I sort of agree though about the F# proposal version. It doesn't make sense to introduce if it is basically equivalent to having a pipe/pipeAsync function. I suspect this is a big reason why the Hack version was favored.

Re:TC39 Pipeline Operator – Hack vs. F# by pygy_ on Tuesday September 14, 2021 @05:46PM (#28531825)
When you look at a Ramda-based JS code base, all there is to look at is function calls. Such code eschews most statements.

Piping is a common operation, though, and having dedicated syntax makes the code more readable. For those code bases that use curried, unary functions, the F# proposal is perfect (this is the original motivation behind the operator).

The hack-style pipe syntax that has been chosen is much worse in that regard, which is disappointing for the very folks that requested its addition.

Re:TC39 Pipeline Operator – Hack vs. F# by azangru on Tuesday September 14, 2021 @05:36PM (#28531684)
Standard library? In javascript? You mean a keyword like `async` or `yield`, or a built-in object like Date or Math?