7 ms·
Deciding whether a program does "one thing well" is a matter of granularity. `ls` with its 38 flags is absolutely tiny compared to, say, finder, which displays
by coffeemug 10y ago
Deciding whether a program does "one thing well" is a matter of granularity. `ls` with its 38 flags is absolutely tiny compared to, say, finder, which displays multimedia previews, allows you to connect to remote servers, and probably does a bazillion other things.
Yes, `ls` isn't perfectly clean in a mathematical sense, but it's still tiny compared to modern software, and passing a couple of flags for common tasks now and then is far more convenient than writing `ls | map ... | sort ...`.
Unix is not a mathematically perfect Unix, but it is most definitely an acceptable one.
- vacri 10y agoThe article hinges far, far too strongly on the "do one thing" part of the definition, and largely ignores the "do it well". The optional flags to 'ls' are there to help "do it well". If we're going to use the overzealous puritism of the article's definition, why not go further? My keyboard driver isn't unix-ey, because I can use it to input a 'k'. Or a 'K'. Or a lot of other characters. The argument in the article would mean that for a keyboard driver to be unix-ey, it should only output a single character. Nevermind the fact that I have 104 options on the HID at my fingertips, if my driver allowed that, it wouldn't be "doing one thing"!
- skierscott 10y ago> The optional flags to 'ls' are there to help "do it well" And by default `ls` does it's job well.
- mfukar 10y agoBy default, `ls` doesn't even list all files. So no, it does not do its job, let alone 'well'.
- oneeyedpigeon 10y agoIt hides hidden files by default. It would be bizarre if it didn't do that.
- mfukar 10y agoAh, hidden files. That's files with "-hidden" in their name, right?
- JdeBP 10y agoIn an alternative universe, Dennis Ritchie would have fixed the bug and yes, the current behaviour would indeed be seen as bizarre; as it actually is on systems which didn't have this bug to turn into a feature.
- fenomas 10y ago> My keyboard driver isn't unix-ey, because I can use it to input a 'k'. Or a 'K'. Or a lot of other characters. You're missing the article's forest for its trees. The author is claiming that "filter or sort the items in a list" and "get a list of files in a folder" are two different "things". That's not a frivolous, hair-splitting thing to say - the difference between generating a list and re-ordering it should be apparent to anyone who writes code. After all, when you write a function that returns an array, do you typically have it take in a boolean argument for whether or not to reverse the array's contents?
- flukus 10y ago> After all, when you write a function that returns an array, do you typically have it take in a boolean argument for whether or not to reverse the array's contents? And the granularity of unix is much more course than a single function. Have you never written a program or application that returns the array and sorts it?
- Someone 10y agoYes, but I preferably compose it of two functions: one that gets the data and one that sorts it. Only rarely that isn't the right thing to do. For example: if the data comes from SQL, I tend to do the sorting in SQL, it I see that as a problem with SQL: it composes badly.
- flukus 10y agoIs there anything stopping you from doing that with current unix tools? You can do that, I'll continue using the more pragmatic option.
- Someone 10y agoThere isn't, but if you see the base system as the library to build your tools on, a library function to get all files in a directory and, optionally, sort them by name, doesn't seem like a good design.