Live data from Hacker News

Show HN: A JavaScript function that looks and behaves like a pipe operator

github.com

31–40 of 148 posts

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#32

The following example code is a bit hard to read: const { status } = await send(capitalize(greeting) + "!") console.log(status) I disagree, I find this example code very easy to read because it reads like idiomatic Javascript. Unlike this library.

I agree with the author that it’s a little confusing, but that’s why I wouldn’t write code like that.

    const msg = capitalize(greeting) + “!”;
    const { status } = await send(msg);
    console.log(status);
Now it’s perfectly readable, no weird shenanigans required.

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#33

The following example code is a bit hard to read: const { status } = await send(capitalize(greeting) + "!") console.log(status) I disagree, I find this example code very easy to read because it reads like idiomatic Javascript. Unlike this library.

Right - because this library tries to fake a new language syntax feature without the actual support for it, it ends up being the worst of both worlds. Even ignoring the lines-of-code explosion, the non-standard use of parens/spacing makes it incredible difficult for me to parse. Props to the author for trying out something neat, but this is probably a bit to clever for my liking.

> the non-standard use of parens/spacing makes it incredible difficult for me to parse.

Same here. Not to mention this wouldn't work in a codebase with an autoformatter.The idea/API is clever. So, a pretty cool experiment I suppose

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#34
post #32

The following example code is a bit hard to read: const { status } = await send(capitalize(greeting) + "!") console.log(status) I disagree, I find this example code very easy to read because it reads like idiomatic Javascript. Unlike this library.

I agree with the author that it’s a little confusing, but that’s why I wouldn’t write code like that. const msg = capitalize(greeting) + “!”; const { status } = await send(msg); console.log(status); Now it’s perfectly readable, no weird shenanigans required.

But at what cost? You had to name two intermediate variables - and naming things is hard.

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#35

The following example code is a bit hard to read: const { status } = await send(capitalize(greeting) + "!") console.log(status) I disagree, I find this example code very easy to read because it reads like idiomatic Javascript. Unlike this library.

If you read all the text, it seems like the entire repo is intended to be a satire on https://github.com/tc39/proposal-pipeline-operator .

Unfortunately I’m not getting satire vibes from that blurb. I’m only more scared for JavaScript.

I love JavaScript but this pipe thing is horrific.

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#38
post #32

Earlier quoted context omitted.

I agree with the author that it’s a little confusing, but that’s why I wouldn’t write code like that. const msg = capitalize(greeting) + “!”; const { status } = await send(msg); console.log(status); Now it’s perfectly readable, no weird shenanigans required.

But at what cost? You had to name two intermediate variables - and naming things is hard.

Not hard: msg can be derived from the parameter name of the send() function and status is a fixed attribute of the result.

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#39
post #32

Earlier quoted context omitted.

I agree with the author that it’s a little confusing, but that’s why I wouldn’t write code like that. const msg = capitalize(greeting) + “!”; const { status } = await send(msg); console.log(status); Now it’s perfectly readable, no weird shenanigans required.

But at what cost? You had to name two intermediate variables - and naming things is hard.

Because they provide value and document the chain of events. I fear a long list of piped expressions without any idea of what they are intended to to. Would be like big regexps.

Re: Show HN: A JavaScript function that looks and behaves like a pipe operator

#40
post #32

Earlier quoted context omitted.

I agree with the author that it’s a little confusing, but that’s why I wouldn’t write code like that. const msg = capitalize(greeting) + “!”; const { status } = await send(msg); console.log(status); Now it’s perfectly readable, no weird shenanigans required.

But at what cost? You had to name two intermediate variables - and naming things is hard.

In this case the variable is the documentation of the code.

You don't have to write something like "this is the message", you can see it.

Post reply on HN