5 ms·
Please no. This “operator” turns everything into an unreadable mess. Where can one vote against it?
by wruza 5y ago
Please no. This “operator” turns everything into an unreadable mess. Where can one vote against it?
- slaymaker1907 5y agoUnreadable in your opinion. In my opinion, it is far more readable than the alternative in many cases.
- dataflow 5y agoA pipeline operator would be nice, but I just took a look and I agree that |> and % are difficult to read. I also think |> is hard to type, which makes it more painful. Admittedly I don't have a stellar solution to this though. Only alternative I can think of is ~
- deleted 5y ago[deleted]
- tentacleuno 5y agoThe tilde (~) operator is already used for Bitwise NOT[0]. [0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_NOT https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- dataflow 5y agoThat's not an issue. This is a binary operator not a unary one.
- tentacleuno 5y agoIt is a unary operator, from my understanding of operators, as it only operators on one subject (~2). However, I very much doubt TC39 would use this character, as it would cause a great deal of confusion and poor semantics, not to mention the complexity on the engine side (does the user want NOT or pipe?)
- dataflow 5y agoNote we already use + as both binary and unary (and for both arithmetic and concatenation).
- mrblampo 5y agoExample case?
- slaymaker1907 5y agoStylistically I think it is most appropriate when you are writing conversions/cleanup/transformations. Places where method chaining is nice but not always possible. Suppose you are doing a bunch of string manipulation with custom string operations (maybe a custom regex engine with timeouts unlike the default JS regex API).
- joshschreuder 5y agoThere’s an example in the article. > const y = h(g(f(x))) This example of nested function calls needs to be read from the inside out (execution is f, g, then h) which is unintuitive to how we read and parse text. The alternative is to use intermediate variables instead of nested function calls to represent the control flow of f, g, h.
- bern4444 5y agoI've come to prefer storing each intermediate value in its own variable. Debugging becomes a lot easier this way with a break point available at each step of the process. There's nearly no disadvantage to creating the extra variables given how quickly they can be cleaned up by the GC in these cases.
- pacaro 5y agoHistorically I would have agreed with this position, but debuggers have gotten a lot better, so it's typically possible to break wherever you need to. The intermediate variables still have value, just not as much as they used to, and they do (arguably) increase the cognitive load for the reader
- colordrops 5y agoBut intermediate variables are almost always better if named properly, as they provide a contextual name as to the purpose of the output of the function. Then only very minor downside is a bit more typing and more lines of code.
- tylersmith 5y ago> Where can one vote against it? In repos you're contributing to.
- twistedpair 5y agoThe slippery slope toward Scala's operator madness. Please find a sensible stasis. Checkout this list of new JS/Node.js features [0] as an example. Will a world with the following be an improvement? [1] - ??= - ||= - &&= And don't forget the strife around the Python "walrus operator" := [2] [0] https://node.green/ https://node.green/ [1] https://github.com/tc39/proposal-logical-assignment/ https://github.com/tc39/proposal-logical-assignment/ [2] https://realpython.com/python-walrus-operator/ https://realpython.com/python-walrus-operator/
- valenterry 5y ago> The slippery slope toward Scala's operator madness. Or is Scala's way what languages eventually converge into? Funnily, in Scala, all of these are just simple plain methods. Including the pipe "operator". So Scala as a language is actually simpler here.
- dragonwriter 5y ago> Where can one vote against it? TC39, as the article notes, and where the F#-style pipe has been shot down enough that it's been abandoned in favor of the Hack-style one by those championing a pipe operator.
- userbinator 5y agoI am against this sort of churn, but for a different reason ---https://news.ycombinator.com/item?id=29894300 https://news.ycombinator.com/item?id=29894300
- edem 5y agoFor you maybe. For me it is a great addition. If you dont like it use font ligatures.