Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Code example?


IMO the problem with bash piping is that it's just text streams. Which means you end up having to do all sorts of text manipulation tasks if something outputs a complex object. Compare to, say, PowerShell, which pipes objects along. You can treat them as a text representation, or operate on their properties without having to embed a little parser.

I'm not sure what about F#'s piping syntax (it's just reversed function application) blows bash away, though.

FWIW: F# ships a standard definition for the operator |> as "let (|>) x f = f x".

Hence you can do e.g. "123 |> write" instead of "write 123". In practise this leads to normal chaining of map/reduce and other list manipulations. In F#, this operator also gains attention as F#'s inference is left-to-right, so suppose you have a list of strings "xs". Without piping, you might write:

  let firstChars xs = Seq.map (fun (x: string) -> xs.[0]) xs
With pipeline it becomes:

  let firstChars xs = xs |> Seq.map (fun x -> xs.[0])


Again, you are piping functions, not programs. Piping programs is important to shell scripting. This is actually very hard in PowerShell. I've written a few cmdlets; it is hard. And even harder for the user.


Can you provide an example of some task which is easy in a shell script (sh) and difficult in PowerShell? Perhaps something related to piping?

I've written a few .sh scripts here and there and I use PowerShell occasionally; I'm nowhere near an expert in either though, so a concrete example would make it easier to understand your point about PowerShell being more difficult.


Someone else provided an example of zipping a file.



Both of those links require a browser plugin that I'm not going to install. From the url's I'm guessing this is about piping functions? I'm not asking about that, I'm asking about piping commands (programs), something any shell scripting language needs to be able to do.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: