News for hackers. Stuff that matters.
Re:Pipe Operator (|>) For JavaScript by dmix on Friday January 20, 2023 @11:01AM (#34454895)
Just because pipe's aren't the ideal solution for that convoluted example they decided to list doesn't mean they aren't still extremely useful for a consistent set of problems. Like anything they can be abused to make code less readable.

I also have a feeling this doc lists every sort of usecase, not because they are advertising it as "always the better version", but because it's a design doc that needs to factor in edge cases, such as using a pipe following chained function calls.

Re:Pipe Operator (|>) For JavaScript by arp242 on Friday January 20, 2023 @11:20AM (#34455283)
I'm just using the example they posted in the README as an "before-after". I think that's a reasonable thing to do when evaluating "do I think this would be a good feature?" Blame the author(s) of that document if you don't think it's a good example.
Re:Pipe Operator (|>) For JavaScript by dmix on Friday January 20, 2023 @12:43PM (#34456734)
That seems to be missing the point of the document then. Before/after in a design doc isn't "this is a better way to do it".
Re:Pipe Operator (|>) For JavaScript by arp242 on Friday January 20, 2023 @01:14PM (#34457228)
What is the point then?
Re:Pipe Operator (|>) For JavaScript by dmix on Friday January 20, 2023 @01:37PM (#34457617)
I don't see design docs as a tutorial on how to be a better programmer using a new syntax, the goal is to flesh out a new concept built on some fundamental ideas.

You cherry picked one example of a tangled/messy block of code that they used to communicate specific idea around "left to right" comprehension and flow of the data using the new syntax. For that specifically it did a fine job.

But that doesn't mean that's the way you should be writing code in the first place, given it started with a mess and only used one piece of syntax to change it.

I will admit it's a poor example to open with. But for a design doc about exploring and debating ideas it's fine.

Re:Pipe Operator (|>) For JavaScript by arp242 on Friday January 20, 2023 @02:04PM (#34458064)
The way I read the proposal is that they used a real-world example from a commonly used codebase (React) to demonstrate how this feature would improve it. I think that's a good approach as features are intended to address real-world concerns, and concrete real-world examples help with that.

I don't think it's fair to say it's "cherry picking" to focus on the example they focus on themselves. They have a few other examples too, but I would say "I don't see how [NEW] is better than [OLD]" for many of those as well (and for some, I think the [NEW] is significantly worse).

Re:Pipe Operator (|>) For JavaScript by dmix on Friday January 20, 2023 @11:56PM (#34464024)
Considering it was their opening example (which they reiterated multiple times) I will concede it was a poor choice. Since yes one of the top goals is selling the general idea. So it's fair the general audience would take it at face value, especially when they use it multiple times as a real world use case, it is hard to take it any other way.

Plus the doc is #1 on HN after all, which could IRL push it beyond a proposal stage if done right.