Remix.run Logo
jeroenhd 7 days ago

With JS' async/await system basically running on creating temporary closures, I don't think things will change all that much to be honest.

Furthermore, I don't see why engines should police what is or isn't acceptable performance. Using functional interfaces (map/forEach/etc.) is slower than using for loops in most cases, but that didn't stop them from implementing those interfaces either.

I don't think there's that much of a performance impact when comparing

    const x = fun1(abc);
    const y = fun2(x);
    const z = fun3(y);
    fun4(z);
and

    abc |> fun1 |> fun2 |> fun3 |> fun4
especially when you end up writing code like

    fun1(abc).then( (x) => fun2(x)).then( (y) => fun3(y)).then((z) => fun4(z))
when using existing language features.
ufo 7 days ago | parent [-]

The problem they were discussion in the linked Github issue are pipelines where the functions receive more than one argument.

    const x = fun1(a, 10)
    const y = fun2(x, 20)
    const z = fun3(y, 30)
In this case the pipeline version would create a bunch of throwaway closures.

    a |> ((a) => fun1(a, 10))
      |> ((x) => fun2(x, 20))
      |> ((y) => fun3(y, 30))