->
over |>
I was about to favor as of April, 2020
After reading this, https://www.javierchavarri.com/data-first-and-data-last-a-comparison/,
I thought I should use ->
over |>
for a performance reason.
by the way, the post was an excellent article 👍🏼
->
, |>
?
Wait, what are those symbols->
: pipe first, more on here, https://reasonml.github.io/docs/en/pipe-first|>
: pipe last, for this you can read the first link above.
But the results of my experiment says it differently
You can see the experiment here.
The result looks same to me 🤷🏻♂️
but to be fair, it's a quite simple example, so I'm not sure how this will work with more complex examples
Anyway I'm guessing the compiler must have improved some optimizations on this over time.
Mix them with a care
Although you can mix them together, you might run into some issues, when you do in one chunk. An example is here
->
for List.map
A tip for using if you want to stick with
List
instead ofBelt.List
when you want to use->
over|>
// this is
[0, 1] -> List.map(x => x + 1, _);
// basically doing the "same" thing as below:
[0, 1] |> List.map(x => x + 1);
about using
->
andf(..., _)
together, it's thanks to pipe placeholders
Personal conclusion
|>
because of:
I still prefer - formatting reasons
// I prefer this
a |> b |> c;
// over this
a->b->c;
- Play nicer with standard module like
List
- There seems to be no cost on JS side. (correct me if I'm wrong on this)
->
But I'm glad now I understand better about I think I will use ->
too in cases where it makes more sense to use over |>
.