News for hackers. Stuff that matters.
Re:Pipe Operator (|>) For JavaScript by BigJono on Friday January 20, 2023 @11:00AM (#34454868)
TC39 proposals often have rubbish real world examples that should never see the light of day in a JS codebase.

It makes me really question the judgement of the people that are working on this language, and it explains how some of the shittier proposals manage to slip in and why the good ones are misused all over the place in every real world codebase when this is the kind of guidance devs have on where to use fancy new features.

In a few years everyone is going to collectively lose their fucking mind once again and decide that ternaries are now the devil and every React component should be chock full of do expressions. I can see that coming clear as day. That might finally be enough to get me to throw in the towel if the also incoming decorator hell doesn't do it.

Re:Pipe Operator (|>) For JavaScript by nightpool on Friday January 20, 2023 @11:29AM (#34455444)
> TC39 proposals often have rubbish real world examples that should never see the light of day in a JS codebase.

This example was literally taken directly from real-world code in the React codebase (a script to call jest-cli). While you're correct that there are probably a lot of clearer and more readable ways to write this snippet, the fact of the matter remains that people write code exactly like these "real world examples" all of the time.

Re:Pipe Operator (|>) For JavaScript by BigJono on Friday January 20, 2023 @11:37AM (#34455594)
Yes and those people with a proven track record of writing awful code will now have another new tool to apply their valuable skills with. I can't wait.
Re:Pipe Operator (|>) For JavaScript by DarkNova6 on Friday January 20, 2023 @11:28AM (#34455434)
> It makes me really question the judgement of the people that are working on this language

Only now?

Re:Pipe Operator (|>) For JavaScript by stoned on Friday January 20, 2023 @11:04AM (#34454955)
I am still hoping that decorators might not pan out :fingers-crossed:
Re:Pipe Operator (|>) For JavaScript by recursive on Friday January 20, 2023 @11:41AM (#34455661)
Wait, what's wrong with decorators? They seem pretty nice in python.
Re:Pipe Operator (|>) For JavaScript by tracker1 on Friday January 20, 2023 @02:12PM (#34458186)
I like decorators as a concept... but there have been a couple different implementations now... the TypeScript version is probably the most broadly used, but there were others before it via Babel (formerly 6to5).

I was an early adopter of the original decorators proposal as well as the F#-style pipeline operators. The more time has moved on and other bits made it into JS proper, I'm far more inclined to stick to what's "in the box"... Have even considered just writing straight JS + ESM (modules). Of course, I also like JSX, though not sure of any proposals of how to get that "in the box" as e4x died on the vine and a lot of other efforts didn't gain much traction either.

Re:Pipe Operator (|>) For JavaScript by pwdisswordfisha on Friday January 20, 2023 @12:25PM (#34456427)
> some of the shittier proposals manage to slip in

Examples?

Re:Pipe Operator (|>) For JavaScript by wruza on Friday January 20, 2023 @06:35PM (#34461719)
React component should be chock full of do expressions

If the motivation behind these features are React components, javascript clearly lacks proper logic in array (and object) literals, like

  '[' if (cond) […]expr1 [else […]expr2] ']'
Although it seems pretty strange to add syntax only because some specific user interface library together with a specific language extension could benefit from it.
Re:Pipe Operator (|>) For JavaScript by MathMonkeyMan on Friday January 20, 2023 @11:17PM (#34463836)
Do you mean this?

    [cond ? expr1 : expr2]
Or maybe this:

    [(() => {/*code*/})()]
Re:Pipe Operator (|>) For JavaScript by wruza on Saturday January 21, 2023 @01:28AM (#34464371)
More like this:

  [...(cond ? [expr1] : [])]