Remix.run Logo
nilslindemann 7 days ago

Your simple example (`2 |> Math.sqrt`) looks great, but when the code gets more complex, then the advantage of the pipe syntax is less obvious. For example,

    foo(1, bar(2, baz(3)), 3)
becomes something like

    1 (2, (3 |> baz) > bar), 3 |> foo
or

    (3 |> baz) |> (2, % |> bar) |> (1, %, 3 |> foo)
    
That looks like just another way to write a thing in JavaScript, and it is not easier to read. What is the advantage?
avaq 7 days ago | parent [-]

Uhm, don't do it, then. That's like arguing that the addition of the ternary operator is a bad one because not all if/else blocks look better when translated into it.

The goal is to linearlize unary function application, not to make all code look better.

sir_eliah 7 days ago | parent [-]

I think the commenter meant that once the new syntax is approved and adopted by the community, you have no choice to not use the syntax. You'll eventually change your project and will be forced to deal with reviewing this code.

dotancohen 5 days ago | parent [-]

_You_ might not use it, but somebody's going to send a PR, or some LLM is going to spit it out, or some previous maintainer put it in there, or will be in some tutorial, or it will be in some API documentation.

You are going to have to deal with it as a mess at some point. One of the downfalls of perl was the myriad of ways of doing any particular thing. We would laugh that perl was a write only language - nobody knew all the little syntax tricks.