Live data from Hacker News

The Beauty of Unix Pipelines

prithu.xyz

91–100 of 388 posts

Re: The Beauty of Unix Pipelines

#91
post #27

Earlier quoted context omitted.

How’s it uncool? Just not “ mobile”?

Exactly. “ Linux, ew !” A big part of teaching computer science to children is breaking this obsession with approaching a computer from the top down — the old ICT ways, and the love of apps — and learning that it is a machine under your own control the understanding of which is entirely tractable from the bottom up. Unlike the natural sciences, computer science (like math) is entirely man made, to its advantage. No m…

My sense is that people do think Linux is "cool" (it's certainly distinguished in being free, logical, and powerful), but its age definitely shows. My biggest pain points are:

- Bash is awful (should be replaced with Python, and there are so many Python-based shells now that reify that opinion)

- C/C++ are awful

- Various crusty bits of Linux that haven't aged well besides the above items (/usr/bin AND /usr/local/bin? multiple users on one computer?? user groups??? entering sudo password all the time????)

- The design blunder of assuming that people will read insanely dense man pages (the amount of StackOverflow questions[0][1][2] that exist for anything that can be located in documentation are a testament to this)

- And of course no bideo gambes and other things (although hopefully webapps will liberate us from OS dependence soon[3][4])

0: https://stackoverflow.com/questions/3689838/whats-the-differ...

1: https://stackoverflow.com/questions/3528245/whats-the-differ...

2: https://stackoverflow.com/questions/3639342/whats-the-differ...

3: https://discord.com/

4: http://wasm.continuation-labs.com/d3demo/

Re: The Beauty of Unix Pipelines

#92

Unix pipelines are indeed beautiful, especially when you consider its similarity to Haskell's monadic I/O: http://okmij.org/ftp/Computation/monadic-shell.html Unix pipelines actually helped me make sense of Haskell's monad.

Pipelines are function composition, not monads.

For pipelines to be monadic, their structure must be able to change depending on the result on the part of pipeline. The type of binding operator hints at it: (>>=) :: m a -> (a -> m b) -> m b.

The second argument receives result of first computation and computes the way overall result (m b) will be computed.

As for program composition, I would like to add gstreamer to the mix: it allows for DAG communication between programs.

Re: The Beauty of Unix Pipelines

#94
The first time I saw pipes in action I was coming from Apple and PC DOS land. It blew my mind. The re-usability of so many /bin tools, and being able to stuff my own into that pattern was amazing.

If you like pipes and multimedia, checkout gstreamer, it has taken the custom pipeline example to real-time.

Re: The Beauty of Unix Pipelines

#95

Earlier quoted context omitted.

God help you if your paths have spaces in them.

By “God” you may mean “libc”... ...if it was the 1970s. Nowadays we use Python etc for tools where it’s less acceptable for them to fall apart, though everything falls apart at some point, spaces or otherwise.

That's Perl role, not Python. You are like 20 years late, kid. Have fun with that shitty whitespace syntax. At least Perl can be refactorized.

Re: The Beauty of Unix Pipelines

#96

Earlier quoted context omitted.

Exactly. “ Linux, ew !” A big part of teaching computer science to children is breaking this obsession with approaching a computer from the top down — the old ICT ways, and the love of apps — and learning that it is a machine under your own control the understanding of which is entirely tractable from the bottom up. Unlike the natural sciences, computer science (like math) is entirely man made, to its advantage. No m…

My sense is that people do think Linux is "cool" (it's certainly distinguished in being free, logical, and powerful), but its age definitely shows. My biggest pain points are: - Bash is awful (should be replaced with Python, and there are so many Python-based shells now that reify that opinion) - C/C++ are awful - Various crusty bits of Linux that haven't aged well besides the above items (/usr/bin AND /usr/local/bin…

- Python as a shell would be the worst crapware ever. Whitespace syntax, no proper file autocompletion, no good pipes, no nothing. Even Tclsh with readline would be better than a Python shell.

- By mixing C and C++ you look like a clueless youngster.

- /usr/local is to handle non-base/non-packages stuff so you don't trash your system. Under OpenBSD, /usr/local is for packages, everything else should be under /opt or maybe ~/src.

- OpenBSD's man pages slap hard any outdated StackOverflow crap. Have fun with a 3 yo unusable answer. Anything NON-docummented on -release- gets wrong fast. Have a look on Linux HOWTO's. That's the future of the StackOverflow usefulness over the years. Near none. Because half of the answers will not apply.

Re: The Beauty of Unix Pipelines

#97
post #45

Pipes are wonderful! In my opinion you can’t extol them by themselves. One has to bask in a fuller set of features that are so much greater than the sum of their parts, to feel the warmth of Unix: (1) everything is text (2) everything (ish) is a file (3) including pipes and fds (4) every piece of software is accessible as a file, invoked at the command line (5) ...with local arguments (6) ...and persistent globals in…

More Lego rules: (7) and common signalling facility (8) also nice if some files have magic properties like /dev/random or /proc or /dev/null (9) every program starts with 3 streams, stdin/stdout for work and stderr for out of band errors

(9) every program starts with 3 streams, stdin/stdout for work and stderr for out of band errors

This is false - if a process closes stdin/out/err, its children won't have these files open.

Re: The Beauty of Unix Pipelines

#98

I think there's an interesting inflection point between piping different utilities together to get something done, and just whipping up a script to do the same thing instead. First I'll use the command line to, say, grab a file from a URL, parse, sort and format it. If I find myself doing the same commands a lot, I'll make a .sh file and pop the commands in there. But then there's that next step, which is where Bash…

I have never come across a NodeJS script instead of a shell script. Can you suggest an example to look at that shows the advantages of this?

Re: The Beauty of Unix Pipelines

#99

Pipes are wonderful! In my opinion you can’t extol them by themselves. One has to bask in a fuller set of features that are so much greater than the sum of their parts, to feel the warmth of Unix: (1) everything is text (2) everything (ish) is a file (3) including pipes and fds (4) every piece of software is accessible as a file, invoked at the command line (5) ...with local arguments (6) ...and persistent globals in…

Can you give me any clue as to what execve does? I looked at the man page but none the wiser. Sounds like magic from what I read there. I'm from a Windows backgroud and not used to pipes.

It replaces the executable in the current process with a different executable. It's kind of like spawning a new process with an executable, except it's the same PID, and file descriptors without CLOEXEC remain open in their original state.

Re: The Beauty of Unix Pipelines

#100
post #49

Earlier quoted context omitted.

I wouldn't be so quick to say it's an alt-right joke. Plenty of my friends will describe something/someone as a Chad and it has nothing to do with incel/alt-right cultures. Are those kind of phrases thrown out in those circles? Yes, but that's more of the general meme/internet lingo as opposed to subscribing to an ideology.

This is brogrammer speak (e.g. http://new_words.enacademic.com/662/brogrammer ).

Thanks! In fact, your link suggests that it may have originated (in this context) from Rob Spectre calling his alter ego 'Chad': https://www.businessinsider.com/the-ultimate-guide-to-learni... https://twitter.com/ChadSpectre/
Post reply on HN