6 ms·
Tech blog writers, please stop invoking the "UNIX philosophy". It's always used as a pseudo-technical argument replacement by people with subjective opinions a
by davexunit 9y ago
Tech blog writers, please stop invoking the "UNIX philosophy". It's always used as a pseudo-technical argument replacement by people with subjective opinions about why software X has too many useful features.
- dfabulich 9y ago(author here) I want all those features! I just want them to be separate commands, like "eg" does. "eg switch" and "eg unstage" will never clobber the working tree.
- davexunit 9y agoI think your article is good, I just think the UNIX philosophy is a bit oversold. The Git CLI certainly leaves something to be desired!
- msla 9y agoEven the traditional Unix tools don't follow the Unix Philosophy extremely well. ls is a prime example: It has too many ways to sort and format its output. It "should", in the Unix Philosophy sense, simply list things in a directory and leave sorting and formatting to other tools. However, parsing the output of ls is generally a bad idea, as it's meant for human consumption, so ls breaks another tenet: It isn't very composable, as it is difficult to use it in a pipeline, even though it should be a prototypical source program.
- hprotagonist 9y agoand `find` has practically re-implemented half the rest of the toolchain. last week i discovered the `-delete` flag. For years, i had been doing `find <stuff> | xargs -rm` instead.
- jff 9y agoI don't even bother using 'find' to actually find files. 'du -a <path> | grep <name>' works easily enough and I don't have to remember find's weird syntax.
- sametmax 9y agoI use the ffind program instead. It's just so much easier with saner defaultq.
- eridius 9y agoA better alternative to xargs is `find <stuff> -exec rm {} +` (though of course -delete is simpler).
- barrkel 9y agoI'm not sure there's much upside in using -delete, -exec etc. from find since they're redundant and can be replaced by composition; half the time, I want to stick a grep -v in there between the found paths and the execution, so xargs is usually handier than not. (I have a tool called print0 which converts line terminators to nulls, so I can use xargs -0 along with grep etc. without needing to use -print0.)
- woliveirajr 9y agoBut there are cases where `-delete` or `-exec` aren't enough, and xargs allows better handling.
- flukus 9y agoFor that matter, why do we need xargs and not just `find <stuff? | rm`?
- Asooka 9y agoI'd argue there's a difference between plumbing commands and UI commands. ls is strictly a UI command, a sort of mini-language to quickly and efficiently explore the file system. If ls didn't exist as a binary, we'd all have an ls bash function in our .bashrc that does the same thing with some perverse combination of for, globs, and stat. If you ever pipe the output of ls to anything (barring very simple cases), you're probably doing it wrong and should switch to find -exec stat instead.
- vidarh 9y agoTry to replace ls with something that acts subtly different (or just give one precedence in your path) for a few weeks and you'll see a surprising amount of stuff calls out to ls. I agree it's a bad idea (or if you do, at the very least make sure you're calling out to /bin/ls...), but it certainly happens.
- twoodfin 9y agoThe original authors of the Unix tools agreed back at least as far as 1983 that the traditional suite was growing new features inconsistent with the Unix Philosophy. Rob Pike's "cat -v Considered Harmful" presentation and associated paper are classics: http://harmful.cat-v.org/cat-v/ http://harmful.cat-v.org/cat-v/
- int_19h 9y agoThis goes to show why machine-readable output is an important thing to make processes composable. Have a look at libxo, which tries to fix this exact issue. FreeBSD adopting it in the base system is encouraging. I hope Linux follows suit, as well.
- Ixiaus 9y agoI agree that over use of a phrase can dilute a message but I think you're not acknowledging something important. The phrase "Unix Philosophy" is a concrete, functioning example of compositionality. Git is a pretty heavyweight tool and many of its commands are not compositional or built up from many smaller functional units. Git repos also do not compose, which is a significant flaw.
- davexunit 9y agoIf we're looking for good role models of composability, UNIX is not the place to be looking.
- Ixiaus 9y agoI think there may be better role models but I have a hard time finding ones that are jargon-free (to a degree, "pipes" and other terms are jargon but generally accessible to people who work with Linux), approachable, and functional for people that do not have the mental model.
- wnoise 9y agoIt's not great -- but it is a good example because nearly everything else in wide use is far worse.
- barrkel 9y agoUnix has produced a bunch of composable tools that have stood the test of time - find, grep, sort, uniq, wc, sed, awk etc. - decades of reusability and composability, things I reuse and compose to this day. I can't honestly say that about any other computing tool I use.
- gue5t 9y agoThe Unix philosophy references some concrete properties of software (many processes performing small tasks, communicating with text streams), but these are neither desirable (serialize/copy/deserialize is wasteful and kills locality; process boundaries preclude inlining and other optimizations) nor really core to compositionality. The compositionality of processes and pipes is arguably the best thing about Unix, but doesn't even work terribly well: piping n different inputs into the same command requires hacky workarounds, and you end up writing ad-hoc parsers/text-manglers constantly. One way to cast the ideological stance of the Unix philosophy is "simplicity of implementation at all costs"; the costs include memory unsafety, poor performance (of pipelines and shell scripts), code duplication, race conditions (look at the filesystem, a vast blob of global mutable state!). It's time we start fixing these problems and abandon the mistakes of Unix. Yes, composition is important, but you don't have to sacrifice so terribly much to get it.