12 ms·
Babel 7.5
- dotsarefun 7y agoThis will incur the same degree of argumentation as pipable functions in C++ 14.
- cupofjoakim 7y agoThe F# pipelines look interesting, but how should one think about this? It's a Stage 1 proposal, meaning it could actually not only be changed, but also be dropped from the TC39 consideration. Will future babel versions under the 7 tree keep supporting it?
- Klathmon 7y agoI would really avoid using this in anything that you aren't okay with rewriting right now. The pipeline proposal has multiple syntaxes right now that the community is trying to pick from and discuss. The chances that the F#-style syntax will be chosen AND will make it to the language proper unchanged is VERY low in my opinion. And if the community goes in a different direction, it's unlikely that the F# style will be maintained for all that long because it's still such an early stage proposal.
- finchisko 7y agoIs there any chance, there will be codemods?
- Klathmon 7y agoThey could probably be made, but I still wouldn't rely on it. Well working Codemods are difficult to make in many cases, and unless someone is paying for it, I don't think there will be many calls for one to translate between the syntaxes unless the proposal gains a lot of usage without settling on one.
- deleted 7y ago[deleted]
- snek 7y agoit's part of the stage 1 preset, and in the future it will either disappear from the stage 1 preset or move to the stage 2 preset.
- bhurlow 7y agoI'm excited to use the pipeline operator but I was burned when I adopted a library (https://github.com/danprince/zaphod https://github.com/danprince/zaphod) which used the function bind operator only to find that lost major steam in TC39 process
- uhryks 7y agoIt really is a bummer... Pipelines look cool and straightforward but the bind operator is much more flexible and seems more adapted to the language's semantics.
- spion 7y agoWith partial application the situation is mitigated somewhat but bind offers other benefits by being a decent primitive to help explain how JS `this` works. I wonder if there is a way to revive the proposal...
- ianwalter 7y agoI’m excited for pipelines but I think the simple pipeline feels much more natural than the “smart” one and allows for destructuring props. Also, am I the only one that feels like the way await is handled in pipelines is backwards? Why not just add await before the function call like a normal function call?
- kristiandupont 7y agoI guess it's because of potential ambiguity, it's discussed here: https://github.com/tc39/proposal-pipeline-operator/issues/145 https://github.com/tc39/proposal-pipeline-operator/issues/14...
- ianwalter 7y agoThanks for linking. It doesn’t look like that discussion includes the “F#” arrow function style discussed in the babel release. I believe using this style would get rid of the ambiguity they were discussing since it could be handled in the same way as a async function outside of pipelines. I really like the consistency of that approach.
- netdur 7y agoFor your own sanity, for your future own self and whomever poor soul that maintain your code, do not use smart syntaxes, there's nothing smart about it, those are just unreadable shortcuts, please use longer and simpler to read syntaxes.
- sametmax 7y agoI pity the guy who has to debug a code base full of: let newScore = fetch(url) |> await # |> #.json() |> await # |> #.ID;
- frabert 7y agoI don't know, it seems pretty clear to me. It beats doing let newScore = (await (await fetch(url)).json()).ID and no, a myriad of intermediate variables is not always a nice alternative. This syntax gives a clear view of what happens to the data without having to untangle deeps expressions. I like it.
- dmitriid 7y agoThe page shows a much more clear and readable alternative, F# pipelines: let newScore = fetch(url) |> await |> r => r.json() |> await |> obj => obj.ID;
- Klathmon 7y agoWouldn't this be a lot easier to understand and work with? let newScore = await fetch(url) .then(r => r.json()) .then(obj => obj.ID) I think another problem is that these are just examples that aren't necessarily representative of real-life use cases but more just try to show all the different ways of using the syntax in one small chunk.
- dmitriid 7y agoYes, in this particular case `then` works better. Pipes are a very generic pattern though, and are quite useful when you have a chain of operations (whether those operations are async or not).
- microcolonel 7y agoCool, a bit more powerful, like ->> and -> in Clojure.
- Lowkeyloki 7y agoI have a strong feeling that these pipeline operators are headed for the purgatory that decorators are languishing in, at least as far as official ECMA spec approval goes. But I hope to be proven wrong.