I thought that for a bit until I realised tail is a bit ambiguous as it's used in the Unix space to mean the "last n" items and in some data structures as the last item pointer.
Yes but every structure that a cons represents can be expressed in terms of first and rest. That includes tables, singly linked lists, doubly linked lists, binary trees from experience.
Arbitrary and legacy, sure, but they do serve their purpose by communicating different expectations when using a single operator. CDR? result can be anything. REST? author probably thinks the result will always be a LIST. I can think of other examples using SETF but I think I made my point clear.
I once wrote an in-place quicksort in common lisp where I kept pointers to locations of interest in the list as halves of a cons cell. Was kind of fun coming across it later and figuring out what it did. That cons cell made no semantic sense as a linked list; it was just a pair of pointers.
I always forgot which was which until I actually forced me to use them for a while (and "while" was too long). The only cool thing of the names is that you can get a cryptic sticker "My other car is a cdr" that no-one will understand but will make you jiggle each morning
I just hard-wired into my brain they are car and cdr (I read it as "cadar," with both a's quite like the a in car, Spanish a for me.) In a cons list, you have the car (first) and then the cadar. Think it enough times and it sinks eventually.
I feel the same way about many *nix commands. A while ago I thought it was neat to have TLAs[1] for everything, but now I just think it's bad "API" design.
Why is it ls instead of list? chmod instead of permissions? grep instead of search? mv, cp, rm instead of move, copy, remove? Is it really so much work to type a few more characters to justify this?
Programming langue APIs (or rather their libraries) have come a long way since the C days in that regard, but OS wise we're still stuck with these cryptic names.
Yes, I wouldn't mind. That's what I'm saying. Imho it's a false assumption that you have to "minimize keystrokes". Programming languages noticed this a while ago.
The time I spent thinking "what was that command again?" is far greater than the time I would need to type a few more characters.
> The time I spent thinking "what was that command again?" is far greater than the time I would need to type a few more characters.
For ls? rm? mv?
I use ls many times per day. Lengthening the name would be a huge loss for absolutely no gain; the odds of my forgetting what it's called are precisely zero. The more you use something, the more gain you get from a short name; unix commands are a near-perfect example of where even cryptic names (which mv, cp, rm, and ls do not qualify as) are very desirable.
Commands are not APIs, and an interactive shell is not a programming language. It's an interactive user interface that some of us spend significant portions of our lives dealing with. I no more want to type an API-like "list_files" command ten billion times than I want to have it take ten mouse clicks to launch an application.
PowerShell does that - everything's a long verbose command. It helps avoid clashes in the global namespace. But it's only really usable with autocomplete. Same with Java, C#, and so on. Also, in local scope, long verbose names are far less readable. It might seem more skimmable or easy to get into a codebase with verbose names, but when you're debugging pieces of code, all the extra letters seem to clutter things up.
I don't mind that much unix commands, in general (with their names, not with their usage, I hate using grep and find.)
I hate chmod, too, because I can't remember exactly what permissions are what (number-wise.) My fault, not his. But I'd love it to be named "grant" and have a neater language. Like grant user/group/whatever read,write,execute (rwx are actually okayish...) filename. I know chmod is more or less like this. But I don't stand it. It's like combinatoric problems, something deep inside of me refuses to accept doing it :)
I guess you know what grep stands for, don't you? It's a "legacy" command from an early version of ed, g/re/p as in "global search" a "re"gex "p"rinting results. It could be named re (for regex, search implicit) or res (I like this.) Anyway, I use ag (the silver searcher) for text/code search, though. Less letters, easier to use (I keep forgetting if I need -r, -e and all that, ag makes it somewhat easier.)
As for mv, cp, rm, if all 2-letter acronyms were that easy to remember! Did you use extensively DOS? Most commands where far too verbose, I cringe if thinking about having to write copy to copy. Cp is just a smash with the left hand and another with the right hand and off you go. Minimise errors, 2 strokes. Actually now I wonder why in nix we have clear and not cls (or just cl)
As a matter of names... Plan9 uses nix names, and since Plan9 tried to do things "differently" almost just for the sake of it, either they didn't think about it or thought it was a bad idea.
Meh, whats one word cloud over another? We can just say the reason for Unix is because: history, and be done with the discussion .. throw a bit of 'its probably because IBM Selectric had easy keys for | and blah' seasoning, douse a fair bit of flamage with bowls of "oh, the monte-carlo on the keypresses says that its all EMACS fault" kerosene, but then again, like I said: whats one word cloud over another? I've heard much relief, for example, from the no-more-Powershell-users who finally 'grok' bash, while (1) grep :P * ; done
I like them because they don't guide thought: They're abstract names for abstract concepts. They don't impose any interpretation on the ideas, they simply present them for what they are. Having to break down a less-useful conceptual model is even more difficult than building a more-useful one.
It's a pity they're not standard in many other languages. I'm not a fan of having to type first/rest or playing around with syntax soup and I really miss caddadadaddaaaaaring around.
sub car { $_[0] } sub cdr { shift; @_ } # every utils module ever
47 comments
[ 4.7 ms ] story [ 114 ms ] threadBut why SBCL? LAST should behave the same on all implementations.
First, Rest, Most, Last
(Results on Range[4], respectively: 1, {2, 3, 4}, {1, 2, 3}, 4.)
Car and Cdr are arbitrary and legacy terms.
I'd rather salt my eyeballs.
ps: based on that, head/tail, hd/tl, fst/snd (seen in ml dialects) are also good candidates.
Why is it ls instead of list? chmod instead of permissions? grep instead of search? mv, cp, rm instead of move, copy, remove? Is it really so much work to type a few more characters to justify this?
Programming langue APIs (or rather their libraries) have come a long way since the C days in that regard, but OS wise we're still stuck with these cryptic names.
[1] http://en.wikipedia.org/wiki/Three-letter_acronym
Would you like to type out 2-3x more characters per command?
The time I spent thinking "what was that command again?" is far greater than the time I would need to type a few more characters.
For ls? rm? mv?
I use ls many times per day. Lengthening the name would be a huge loss for absolutely no gain; the odds of my forgetting what it's called are precisely zero. The more you use something, the more gain you get from a short name; unix commands are a near-perfect example of where even cryptic names (which mv, cp, rm, and ls do not qualify as) are very desirable.
I hate chmod, too, because I can't remember exactly what permissions are what (number-wise.) My fault, not his. But I'd love it to be named "grant" and have a neater language. Like grant user/group/whatever read,write,execute (rwx are actually okayish...) filename. I know chmod is more or less like this. But I don't stand it. It's like combinatoric problems, something deep inside of me refuses to accept doing it :)
I guess you know what grep stands for, don't you? It's a "legacy" command from an early version of ed, g/re/p as in "global search" a "re"gex "p"rinting results. It could be named re (for regex, search implicit) or res (I like this.) Anyway, I use ag (the silver searcher) for text/code search, though. Less letters, easier to use (I keep forgetting if I need -r, -e and all that, ag makes it somewhat easier.)
As for mv, cp, rm, if all 2-letter acronyms were that easy to remember! Did you use extensively DOS? Most commands where far too verbose, I cringe if thinking about having to write copy to copy. Cp is just a smash with the left hand and another with the right hand and off you go. Minimise errors, 2 strokes. Actually now I wonder why in nix we have clear and not cls (or just cl)
As a matter of names... Plan9 uses nix names, and since Plan9 tried to do things "differently" almost just for the sake of it, either they didn't think about it or thought it was a bad idea.
The shell is a working language as much as English is. You'll spend more time using it than learning it, so get crackin'.
sub car { $_[0] } sub cdr { shift; @_ } # every utils module ever
Perl can be written ugly enough without introducing car and cdr to it!
For eg:
then... Some refs: https://metacpan.org/pod/perl5i | https://metacpan.org/pod/autobox::Core