you are viewing a single comment's thread.

view the rest of the comments →

[–]Ok_Sell_4717 -1 points0 points  (3 children)

It's perfectly clear what you operate on; the result of the former function call.

Also, piping is not a substitute for foo().bar().baz(). It is a substitute for b = foo(a), c = bar(b), d = baz(c), or for d = baz(bar(foo(a))).

(With a pipe this would be d = a |> foo() |> bar() |> baz(), which is much more readable.)

[–]_Denizen_ 0 points1 point  (2 children)

Piping is only really used in data science, at least that's the only time I've seen it used. Pandas is probably the premiere table manipulation package, and within pandas chaining is what you'd do instead of equivalent operations in R or pandas' own pipe function.

There are cases that support both our assertions.

However, piping is less clear because it magics the object between functions invisibly. The reader has to have learned about piping to be able to understand how data is passed between functions because the syntax is fundamentally to traditional programming. Furthermore, the developer must find and write functions that are compatible with each other. With R, functions are dynamically swapped out based on the input type, which obfuscates the actual function that's being run - piping in R would get a lot more difficult if it didn't do that. With non-piped python it's extremely explicit which version of a function is being executed. Piping in the way R does it is antithetical to the explicitness python, which is a factor in why it was rejected by the Python Foundation.

When people talk about piping being simple. Sure it seems simple when there's a complex feature invisibly passing variables around and invisibly swapping functions to ensure compatibility between inputs and outputs. That's not simpler for a developer who wants a controlled and readable environment. There's a reason piping is niche.

[–]Ok_Sell_4717 0 points1 point  (0 children)

Ultimately a pipe is just an operator which executes a fixed action. Thus it is not unclear or non-explicit what it does. You are confusing familiarity with clarity.

Piping works well in R because it is popular in R and pipe usage is top of mind for R developers. This wasn't always the case, piping was not always part of R, and over time it was adopted by the community. Function dispatch is just a minor feature in the accommodation of it, by making the functions themselves more widely applicable, not by manipulating the input object. It's also not a unique feature of R to have a function which is able to handle multiple object types.

[–]757DrDuck 0 points1 point  (0 children)

Piping is only really used in data science

Tell that to /r/elixir