248 points · by janvdberg · 6y ago · 171 comments
GUIs provide discoverability so often times you don't need a manual. If you don't know how to use a command line tool you must open the manual. So in that way I would consider the man pages as part of the UI and those definitely get cluttered.
For a desktop paradigm, there is always a way to do better with GUI as you add more features; but you'll refactor / redesign a lot on the way and that has a cost in familiarity, which directly impacts user productivity. It's a trade off.
The dirty secret of discoverability is that only a tiny subset of features is relevant at any time in the UX, and identifying that subset + triggering user awareness about it is the "art" part. We learned a lot with mobile in that regard because the harsh limit on real estate becomes incentive to identify the essentials.
Discoverability doesn't have to suffer from complexity of the software, but it's not just UI design, it's UX.
For some reason, designers and some users don't like it, but a hierarchy (folders, menus, etc) is something many people find useful and effective.
But it seems pretty common to declare people can only handle a few options plus search.
A GUI can much more easily emphasize the most common options, it can visually group related options, and it can use common GUI widgets to, for example, show that some options are mutually exclusive with each other.
But the same could be said of CLIs tbh. After a couple dozen options, man pages, or `--help` lists become a dense read, where as a simple form on a webpage might be easier to grok. YMMV
You don't read a man page top to bottom, you skim and skip around, discovering the information you need.
The trend in the command line is in an orthogonal direction - more and more complex function-like options with minimal mnemonic labels, optimised for text representations and text processing.
Which is a problem of its own, in a way. Reading a man page top to bottom is few minutes. Reading a user guide/Info pages (for the good software that still comes with one) for a more complex tool (e.g. gdb) takes couple of hours. If you're going to use the application more frequently or for more than an hour in total, the time spent reading the manual will pay for itself - in reduced frustration, much quicker discovery, and much less StackOverflow searches (and getting confused by wrong/misguided answers).
Reading manuals top to bottom: an ancient, forgotten superpower.
Of course some principles of speech and syntax should stay around (as they probably exist for a good reason), but it is foolhardy to grip tightly onto any language, human or computer, thinking it will always stay the same, when it plainly won't.
Partly, but less so.
Human language vocabularies approximate Huffman Coding - the more frequently used words (and phrases) tend to be proportionally shorter. This is a gradual process for spoken languages, and somewhat quantized for written languages.[1] It's possible because with human languages, "close" is "good enough"; one can read english written with ye olde orthography, if with a bit of extra effort.
Less so in the lifespans of particular programming languages. Per Postel's law we tend to be liberal with extending but conservative with breaking backward compatibility. I think the case of command line tool parameters is particularly conservative for various reasons; among them because the 'knowledge' of options is spread among multitude of separate project - many of them obscure and bespoke - and coordination would be nigh impossible.
However there are some signs of similar trends; note how the "function" and "integer" and similar keywords of older languages tend to turn into "fn" and "int" in newer languages.
--
[1] Not sure if there's a comparable process for grammars, but I guess it's a fair bet...?
Pejoration happens too. When is the last time you used a GOTO in code? And yet, 40 years ago, you couldn't write a BASIC program without one. And the revulsion against NULL causing a shift to Maybes and optional types to the point where the concept is reified in many languages now?
All I'm saying is that there are multiple mechanisms that are changing the languages we write code with, and that it is changing far faster than people realize.
Just yesterday in fact, while implementing a state machine. Except the developers of that particular language explicitly did away with GOTO, so I ended up approximating it with a SWITCH/CASE. At least the language supports fall-through...
Which is to say, people differ in judgements of various features (footguns vs swiss army knifes). Moreover, the judgements seem to oscillate as fashions, in ~10 year long cycles. Please recall how exceptions and templates used to be a hot thing back in the day. Ditto garbage collectors. Presently we're all in love with Rust, and the "JITs considered harmful" paper will drop any day now.
It's interesting to think about how things can be swapped dynamically in this system. Consider the evolution of 'telephone.' In the 1980's, 'phone' referred to a land-line telephone. In the 2000's, it was ambiguous; for young people, it meant 'cell phone' most likely, or we started calling them 'house phones' for land lines. Now 'phone' is mostly used for a 'smart cellular telephone'.
Another interesting example is "Playstation". That always refers to the current generation, and we retroactively apply "PS1."
It will be an interesting period for history in the future to try and decode our present-day meanings since so many words are period specific.
You could probably trace a similar evolution across programming languages, just by systematizing the phrases/words used in each to accomplish the same thing.
The true winner is probably gcc though, which was unfairly excluded from competition. Over 1000 options is excellent work.
https://unix.stackexchange.com/questions/112125/is-there-a-r...
As an exercise, try to sort a directory by size or date, and pass the result to xargs, while supporting any valid filename. I eventually just gave up and made my script ignore any filenames containing \n.
The `printf (od -> sed)' construction converts back out of null-separated characters into newline-separated, though feel free to replace that with anything accepting null-separated input. Granted, `sort --zero-terminated' is a GNU extension and kinda cheating, but it's even available on macOS so it's probably fine.
printf '%b' $(
find . -maxdepth 1 -exec sh -c '
printf '\''%s %s\0'\'' "$(stat -f '\''%m'\'' "$1")" "$1"
' sh {} \; | \
sort --zero-terminated | \
od -v -b | \
sed 's/^[^ ]*//
s/ *$//
s/ */ \\/g
s/\\000/\\012/g')
If you're running this under zsh, you'll need to prefix it with `command' to use the system executable: zsh's builtin printf doesn't support printing octal escape codes for normally printable characters, and you may have to assign the output to a variable and explicitly word-split it.This is all POSIX as far as I know, except for the sort.
I think we can all do that. Did anyone ever came across a legitimate reason for filenames with newlines? All I can think of are intentionally bad-named files to exploit bugs. Those filenames should be avoided in the first place.
python -c 'import os; \
os.write(1, b"\0".join( \
sorted(os.listdir(b"."), key=lambda p: os.stat(p).st_size)))' \
| xargs -0 ...
By date: swap st_size for st_mtime.(Python3 does try to make this hard on us — Unix path names are just bags of bytes, but Python insists that printing must have some known encoding. I get around that by abusing os.write(1, ...) and by adding the dummy b"." argument to os.listdir(), which forces the results to be in bytes format.)
find /etc/ -mindepth 1 -maxdepth 1 -type f \
-printf '%s:%T@:%p\000' \
| sort -z -t: -k1,1g \
| sed -E -z 's/^[0-9]+:[0-9.]+://g' \
| tr '\000' '\n'
Sorts by size, can just change -k1,1 to -k2,2 to sort by date. Tested on fedora 31 with gnu find, sed, sort and tr.And really the answer given at the stackexchange link is quite on point:
> However ls is really a tool for direct consumption by a human, and in that case further processing is less useful. For futher processing, find(1) is more suited.
Find is the right solution, find gives you an enormous amount of control, to re-implement find in ls seems counter productive.
Another example: the modern Bash shell vs the Plan 9's Rc shell. The difference in documentation is over tenfold, with the latter still being more less laden with gotchas:
$ man bash | wc -w
48189
$ 9 man rc | wc -w
3264
Having said that, I still love me some sick diff -burN-style mnemonics.perl -lane # process input by line, split into fields, print outputs with new lines, execute code
netstat -planet # show process, extended info, all socket types
ss -pimento # basically every piece of info about live connections
iostat -txyz # extended, omit first report (the since-boot one), omit devices with no activity, log datetime
less -SEXIER
Truncate long lines instead of wrap, quit at eof, don't clear the screen, show ansi color escape codes as colors but escape other ansi escape codes.(The second E does nothing but complete the word)
$ man dash | wc -w
10122
If you are running scripts most of the time bash is overkill (batch files don't need things like command completion, history and all that interactive stuff). Don't believe me? $ ls -lAh `which bash`
-rwxr-xr-x 1 root root 1.1M Jun 6 2019 /bin/bash
$ ls -lAh `which dash`
-rwxr-xr-x 1 root root 119K Jan 25 2018 /bin/dashThat's an advantage; Plan 9 provides awk for those use cases. There is a clear separation, and a simple yet powerful language for communication (pipes, file descriptors, and files).
>bash is trying to be a full scripting language these days
Arguably Bash over-did somewhere around the time they added support for TCP connections
exec {FD}<>/dev/tcp/news.ycombinator.com/80; echo GET / >&$FD; cat <&$FDI won't get to this in Oil (without help) but I still think it's valid. The languages have so much overlap that they should just be combined. Of course that's what Perl was (leaving out Make), but Raku and Python 3 seem to have left a hole in that design space.
Shell, Awk, and Make Should Be Combined http://www.oilshell.org/blog/2016/11/13.html
Example Code in Shell, Awk, and Make http://www.oilshell.org/blog/2016/11/14.html
I think the change was jokingly called “pulling up the ladder behind us.”
Learning some command line commands feels like learning a whole new framework. A man page should rarely need to be a whole damned manual.
If so, then this primarily seems like an issue of how to present the documentation and not the mechanics of the change itself. Instead of autogenerating docs that say concat :: Foldable t => t (t a) -> t a (or whatever) and making people think about Foldable, write docs that say that concat is still [[a]] -> [a], with a note at the bottom saying, by the way, this generalization exists, click here to see the more complicated version if you've decided you care about Foldable. Probably the text of the docs remains the same, in fact ("concatenate a list of lists together into a single list"), you just display the real prototype and explain that "list" could also mean something else. (There's a number of ways to implement this, from writing docs by hand, to extending the doc protocol to support this specific case of lists and Foldable, to extending the doc protocol to support documenting a fake function prototype and then have a link to the real function at the bottom, and using the type system to ensure that the fake prototype is just a special case of the real function.)
A corollary is that documentation presentation is an inseparable part of library / tool design.
The same type of solution that you propose for docs can work here too, though. The compiler can trivially substitute the typeclass for any known instance.
tar xvf foo.tar.gz # extract, verbose, file
I use the longer but more readable stream idiom: tar -x -z < foo.tar.gz
tar --verbose -x --xz < foo.tar.xz
(It does force you to specify -z for gzip or --xz for .xz, but I'm OK with that redundancy in the name of readability.)This makes it easier to remember the syntax for create and list too:
$ tar --create e.txt k.txt > out.tar
$ tar --list < out.tar
e.txt
k.txt
That's how I write the install instructions for Oil:https://www.oilshell.org/release/0.8.pre2/doc/INSTALL.html
-----
So basically tar can behave normally (at least GNU tar can) -- it's just that there's an ancient idiom that most people have in their fingers, and that's copied around in various instructions.
The nice thing about the verbose way is that the hyphen prefix enables autocomplete.
tar caf foo.tar.gz foo/ bar/ # Compress As Fuck
tar xaf foo.tar.gz # Xtract As FuckThe alternative (presuming the extra functionality is useful to someone, somewhere) would seem to be more standard commands, and that choice would use up more of the precious global namespace for small yet memorable lower-case command names.
I prefer as much of that as possible be reserved for userspace. I'll admit my mind boggles a bit when I ask myself what tar could possibly do with 139 flags, and it makes me a bit nervous about the surface area the program exposes.
Does this better alternative exist?
>the added options are convenience flags: setting the permissions of the new directory and making parent directories if they don't exist.
Obviously completely unnecessary for normal users, but those have to exist for automated processes. The "problem" is caused in part by the success of Unix, that now computers are using computers.
> To be clear, I'm not saying that I or anyone else could have done better with the knowledge available in the 70s in terms of making a system that was practically useful at the time that would be elegant today. It's easy to look back and find issues with the benefit of hindsight. What I disagree with are comments from Unix mavens speaking today, with comments like McIlroy's, which imply that we just forgot or don't understand the value of simplicity, or Ken Thompson saying that C is as safe a language as any and if we don't want bugs we should just write bug-free code. These kinds of comments imply that there's not much to learn from hindsight, we were building things as well as anyone could build things in the 70s, all we have to do is go back to building systems like the original Unix mavens and all will be well. I respectfully disagree.
In other words, the real problem isn't that modern software is getting more complex (as there is a good reason for it); the problem is that we're insisting on using an environment that is not up to the task of dealing with modern complexity.
For an example of how insane this world is: consider putting your source trees in a location that contains a space in its name. How many build systems are going to completely and utterly fail to build your code? And... why should we tolerate this situation?
Sure it’s convenient for writing scripts too but a script could just as well include some boilerplate for the functionality if required and it if not.
This is the argument between CISC and RISC.
It's not as much that the arguments allow you to run a program under variant configurations, but rather that you create completely new programs for each run.
The alternative is to hide all of the complexity and hope that the defaults are good enough for your users. Which works ok for stuff like Mom encoding her cell phone video but falls down pretty quick when someone needs to do something slightly out of the box, like add in a second audio track.
anything as powerful as FFMPEG, EXIFTool, ImageMagick, x264/265, etc is going to have switches/options from hell just out of plain necessity. these are not simple little Unix-esque tools. these are full blown applications that just happen to not have a UI.
$ import fs
This imports all the commands in the 'fs' library, without any concern for namespaces, and if there are any already existing commands with the same name, they are not overwritten (the new ones are not imported).But if you do this:
$ import fs as myfs
Then, all the commands in the 'fs' library are invoked like this: $ myfs.vim
[0] https://dev.lotw.xyz/shell.osA general purpose ad-hoc data format with all the fundamental types, that doesn't require endless text parsing but can be converted to a 1:1 text format for human viewing, would be helpful in so many situations, including serialization for piping between unix tools.
XML strength also lies in its extensibility, and its large number of compliant implementations, which goes way way beyond a single uncompleted implementation by a single author.
RON is fine for rust, but not for other languages that might not have its feature set.
[1] https://github.com/kstenerud/concise-encoding#comparison-to-...
[2] https://github.com/kstenerud/concise-encoding/blob/master/de...
In your comparison you claim Concise is zero-copy, but it does not appear to be so, at least in the sense that Cap'n Proto and FlatBuffers are. Concise appears to use variable-width integers, tag-value sequences, and 8-byte alignment, all of which make encoded messages unsuitable as in-memory data structures; it looks to me like you have to parse the message into some sort of AST before you could meaningfully operate on the content. "Zero-copy" in the Cap'n Proto / FlatBuffers sense means that there's no need to do any "parsing" because the whole message is efficiently traverseable as-is; e.g. you can mmap() in a very large message and then find and access any one value within it in O(1) time (or perhaps O(log n), if the data structure is nested). This generally requires that primitive values have fixed widths and fields have fixed offsets within their parent object.
Digging into your docs it looks like what you really mean by "zero copy" is that individual strings or byte sequences can be used directly without copying them out of the original message buffer. This is a fairly common property of any binary protocol; e.g. Protocol Buffers can do this (albeit without NUL-termination), but in your table you have indicated that it cannot. I would maybe call this "zero-copy strings" to be clearer.
On another note, in your table you have indicated that Cap'n Proto doesn't have a "String" type, but this is not true -- Cap'n Proto's "Text" type is a UTF-8 string (and is even NUL-terminated on the wire).
(I'm the author of Cap'n Proto.)
Although not technically a pro/con list, it highlights the evaluation criteria used to compare.
I personally don’t use most of these options and their existence just clutter up the manual.
https://www.gnu.org/software/coreutils/rejected_requests.htm...
tar xfvz my-source-code.1.2.3.tar.gz
What does those flags mean? Who knows! I mean, I know because I've used it enough, but for many people those are just a mysterious incantation (there's even an xkcd about it! [0])The reason is arguably that tar has too many responsibilities here. Tar should only do two things: create tar streams and extract tar streams into files. You do that with "tar c" and "tar x", and that's everything you should need to remember (ok, fine, "tar t" for listing files is good to know as well).
Commands to create tarballs should look like this:
tar c directory | gzip > directory.tar.gz
And untar commands should look like this: zcat directory.tar.gz | tar x
or maybe cat directory.tar.gz | gunzip | tar x
or whatever version you prefer with "tar x" at the end. This is composable, super-easy to remember, and you can VERY easily swap out any parts for any other parts (for instance, changing the source from a file to a url with curl, or the destination for an ssh pipe or something).One of the benefits of the "swapping out" parts are of course that you're not restricted to what's built into tar: you can use ANY compression utility you want. For instance, there's a thing called pigz[1] which parallelizes gzip decompression for increased speed. It's trivial to swap into the pipeline when you use tar that way:
cat directory.tar.gz | unpigz | tar x
Congratulations, you now have much faster expansion of tarballs, without needing to recompile tar.We've taught a generation of programmers that "tar" is hard to use and you have to look up a magic incantation every time you need it. Ironically, that makes tar less flexible, because now you think of it as a single-purpose utility (creating and unpacking compressed tarballs) instead of a versatile unix tool which can be used in all sorts of different situations.
Perhaps you mean that you've looked it up. Others could do so, too; it's not that hard (even if a web comic makes light-hearted fun of the subject)!
Anyway, here's a fun fact: tar is smarter than you give it credit. The commands below do just work:
tar xf uncompressed.tar
tar xf gzipped.tar.gz
tar xf xzipped.tar.xzHow about:
tar c folder | bzip2 > folder.tar.bz2
I didn't have to look any of that up. tar -c [files...] -f archive.tar
The thing is, for both basic compressing and decompressing you don't actually have to memorize all that much: tar xf archive.tar.gz # to uncompress
tar caf archive.tar.ext [files...] # to compress
(One could argue that for symmetry you might want to use xaf instead of xf.)But what I came here to say is that I find the typical tar flags pretty intuitive. X means extract, z means using zip/unzip, v means verbose, and f for file I/O instead of stdin/stdout. For typical use cases, I don't find its interface magical but logical. I'll freely admit to needing 'man tar' anytime I stray from the typical use, but that's true of a lot of commands.
The bigger offender in my mind is rsync. I remember auvP as my typical flags but don't ask me what they do. And good luck guessing whether my destination or source path need a trailing slash on the first try...
I remember reading that xkcd comic though and I went "yup, that's me!", and I've spent a bunch of time thinking about why that was. You list those flags there and say there intuitive, but they're unique to tar, you have to memorize them, and there's no reason that they need to be in tar when they're available right there in the shell.
Why do I need to memorize that the "f" flag is "file output/input", when I can just write "> dest-file" or "cat src-file |" (or "< src-file") in my shell? That works for every command, not just tar. Why do I need to remember that the z file is for gzip (what's the equivalent flag for bzip2?) when gzip/gunzip exists and works for anything?
So many people simply don't understand what tar does or how to use it without googling the magic formula they need, and it's because of all these damn flags that everyone insists on using instead of doing it the "unix way".
dd is another program where the commandline flags predate modern usage (although it does at least behave nicely with pipes by default) and look totally weird compared to everything else. But again nobody wants to touch them because it would break millions of existing scripts.
> z means using zip/unzip
gzip/gunzip, doesn't look like tar supports zip/unzip, which is a whole different algorithm.
Modern tar can detect the format so "tar xfv" is enough. The "v" option only means "verbose" so it's better just "tar xf" and avoid spamming the terminal.
Note: If none of your files were clobbered and there are no spaces in the filenames to worry about you can do:
tar -tf [tarball] | xargs rm -d
Run it repeatedly if you also want to remove the directories.
Back before clear, I used 'echo ^V<esc>c', but that's not portable to different termcap/curses/ncurses display devices.
that said, I live in it.
Given the nature of open source, I'd be surprised if there isn't a alternative for less dynamic, less resource req, systems. Is there a system out there that still uses fewer commands?
I don't know how to ask this next question, so please bare with me.. Are there any modern systems that don't require modern hardware, but are just more efficient versions of past systems?
I have been happy with the way I could use my computer for the last 20 years (probably earlier, too).. so are there any efforts to keep the simplicity of older systems that were adequate for most, make them more efficient, and either have "super hardware", or I suppose very cheap hardware?
Thanks for anyone who made it through my ignorant ramblings.
Can't find but feel there's a quote like "Programs will grow to fill memory"
BTW, I have a first gen iPad sitting around that worked very the first two years or so of its existence, and it barely functions today. I know part of that is Apple "protecting" older batteries by slowing down older stuff so we go out and buy new things, but I would like to believe that we're capable or creating an OS for that hardware today that would run better than it did originally, rather than barely function at all.
That is a ball we set in motion when we introduced virtual memory, particularly with overcommit.
Give a developer the option to write calls to malloc that never fail, and boy will they make use of that! Performance be damned.
I remember when I ran the original MacPaint (I assume it was in hand optimized assembler?) on a 16 MHz 68030 and it was amazing - everything seemed to simply be instantaneous. It put in perspective how when the 68000 came out, it was a "minicomputer on a chip" and the 68030 was conceived as a "mainframe on a chip".
Also tar's increases might include new compressions methods like bzip2, XZ, etc.
Most of the tape devices themselves had/have compression on them so that tar did not need to do it. However, that compression was pretty weak (2:1), so giving tar the ability to use bzip2 and send the compressed data stream to the tape (bypassing the hardware compression) gave the user much more convenience. Also, older systems probably were bad at doing the compression in real-time, so it probably slowed down the write to tape. I'm just guessing, I have no experience writing to tape from such an old system. I'm not really upset by tar geting some extra features.