Live data from Hacker News

For the Love of Pipes

blog.jessfraz.com

31–40 of 323 posts

Re: For the Love of Pipes

#31
post #10

Why isn't the pipe a construct that has caught on in 'proper' languages?

Julia has a pipe operator, which applies a function to the preceding argument:

julia> 1:5 |> x->x.^2 |> x->2x

5-element Array{Int64,1}:

  2
  8
 18
 32
 50

Re: For the Love of Pipes

#32

I think the Unix pipeline works because this it has this moldable and expressive text substance that is exchanged. Gstreamer also has pipelines, but the result in my opinion is quite awkward because events of many types are exchanged. Windows Powershell also has a pipeline where objects are exchanged, but it also somehow failed to become a huge success. i think the unix pipeline concept doesn't quite scale to other d…

While I do agree they can sometimes be tricky to use, Gstreamer pipelines are also it's best feature. Is there a better way?

Re: For the Love of Pipes

#33

For an alternative view, don't forget to read the section on Pipes of The Unix-Haters Handbook : http://web.mit.edu/~simsong/www/ugh.pdf (page 198)

> When was the last time your Unix workstation was as useful as a Macintosh?

Some of that discussion has not aged well :)

Re: For the Love of Pipes

#34
post #28
post #10

Why isn't the pipe a construct that has caught on in 'proper' languages?

OCaml has had the pipe operator |> since 4.01 [0] It actually somewhat changes the way you write code, because it enables chaining of calls. It's worth noting there's nothing preventing this being done before the pipe operator using function calls. x |> f |> g is by definition the same as (g (f x)). In non-performance-sensitive code, I've found that what would be quite a complicated monolithic function in an imperati…

IMO the really useful part of pipes is less the operator and more the lazy, streaming, concurrent processing model.

So lazy collections / iterators, and HoFs working on those.

The pipe operator itself is mostly a way to denote the composition in reading order (left to right instead of right to left / inside to outside), which is convenient for readability but not exactly world-breaking.

Re: For the Love of Pipes

#35

I think the Unix pipeline works because this it has this moldable and expressive text substance that is exchanged. Gstreamer also has pipelines, but the result in my opinion is quite awkward because events of many types are exchanged. Windows Powershell also has a pipeline where objects are exchanged, but it also somehow failed to become a huge success. i think the unix pipeline concept doesn't quite scale to other d…

While I do agree they can sometimes be tricky to use, Gstreamer pipelines are also it's best feature. Is there a better way?

ffmpeg took a different approach (sort of like a single program/system with many command line options). Some say its easier to use (at least easier than gst-launch)

Re: For the Love of Pipes

#37
post #23

Earlier quoted context omitted.

It is! It's the main way of programming in lazy functional programming languages like Haskell And many programming languages have libraries for something similar:. iterators in rust / c++, streams in java/c#, thinks like reactive

Haskell was the only possible I found. Iterators don't really fully capture what a pipe is though? Theres no parallelism. And streams don't have the conceptual simplicity of a pipe?

> Iterators don't really fully capture what a pipe is though? Theres no parallelism.

Pipes are concurrent, not necessarily parallel. Iterators are concurrent, and can be parallel (https://docs.rs/rayon/0.6.0/rayon/par_iter/index.html).

Re: For the Love of Pipes

#38

I recently came across Ramda CLI's interactive mode [1] It essentially hijacks pipe's input and output into browser where you can play with the Ramda command. Then you just close browser tab and Ramda CLI applies your changed code in the pipe, resuming its operation. Now I'm thinking all kinds ways I use pipe that I could "tee" through a browser app. I can use browser for interactive JSON manipulation, visualization…

You can just store the first pipeline results in a file, edit it, then use the file as an input for the second pipeline.

Re: For the Love of Pipes

#40
post #10

Why isn't the pipe a construct that has caught on in 'proper' languages?

It has, D's uniform functional syntax makes this as easy as auto foo = some_array.filter!(predicate).array.sort.uniq; for the unique elements of the sorted array that satisfy the predicate pred.
Post reply on HN