4 ms·
What do you think HN is written in?
by zeckalpha 3y ago
What do you think HN is written in?
- jacknews 3y agolisp is great, I'm currently learning Janet, playing with fennel and clojure. But a new 'lispish' should not replicate ancient historical 'accidents', IMHO, and in fact lisp itself should deprecate these names (and caar, caadr, caaaddr ... OMG). first, rest, or head, tail, or whatever please.
- msla 3y agoCAR and CDR can be used to do things other than take lists apart. That's why they have those names.
- jacknews 3y agoThey have those names because they relate to the registers on the original implementation machine. time to move on.
- msla 3y agoYou offer no actual arguments, just pronouncements and irrelevant history.
- jacknews 3y agoThe argument is the names make no sense, they are purely historical.
- msla 3y agoThey make perfect sense once you understand what they do. They're not mnemonic for any specific usage because they have more than one possible specific usage in the language. Besides, what kind of sense does '+' make for addition? It's also purely historical.
- jacknews 3y agoImagine you were tasked with implementing a linked-list in, let's say 'C', but anything really. So you choose 'cell' as your name for a node. OK, that's .. fine. Now you choose 'car' and 'cdr' for each cell's 'data pointer' and 'next-cell-in-list pointer'. How many 'WTF?s'* do you think you'd get in code review? (except from lispers, I guess) * obviously it's a rhetorical question, no-one writes or says WTF (out loud) in actual code reviews I hope.
- msla 3y ago> Now you choose 'car' and 'cdr' for each cell's 'data pointer' and 'next-cell-in-list pointer'. How many 'WTF?s'* do you think you'd get in code review? Your names are too verbose.
- flqn 3y agostruct node_t* node node->data node->next Zero "WTF"s
- msla 3y agoExcept those names are wrong in some contexts. That's the point.
- deleted 3y ago[deleted]
- jacknews 3y agoYou are tasked with writing a binary tree, and you pick car and cdr ... A key-value tuple-space... Complex numbers... The point is they are 'wrong' in every context. For LISt Processing, they should probably default to something to do with lists. And caaar et al are a fine example of why I completely skipped common lisp in favour of newer lisp-likes. Perhaps it happens to all languages eventually, people add a convenience here, an shortcut there, and a doodad here, and before long you have an impenetrable thicket. And these things seem convenient, but they are a huge extra cognitive load, and impose a further learning cost even to practicing experts who have to keep up with the latest doodads.
- deleted 3y ago[deleted]
- kazinator 3y agoJohn MacCarthy knew that not every computer is an IBM 704, and that users want higher level languages developed on one system to be usable on another. He stuck with those names because there is no problem with them. They are hard to improve upon in a ways that are only subjectively better while being objectively worse. For instance first and rest are subjectively better for some uses and for some people, while being objectively worse (wastefuly longer for something commonly needed, and falsely associating when the objects aren't used as linear lists). Thus at best we can adopt them as synonyms (and we have). The were inspired by FLPL ("Fortran List Processing Language"): a Fortran library for list manipulation. FLPL, for mysterious reasons, used pretty horrible names like XCARF and XCDRF. MacCarthy must have been thinking about good naming, because he thankfully dropped the X...F. I think if they were called something else, I'd still want them to be three-letter identifiers (not just one or two, to avoid clashes) which differ only in the middle letter, so a pattern similar to cadr, cddr ... is possible. In quantum mechanics there is a <a|b> notation where a is the "bra" and b is the "ket". That doesn't have the right property for cadr, and would be the the target of bra and fig leaf jokes. In TAOCP, I seem to recall, Knuth calls the fields of binary list cells alink and blink. Not sure if he wants us to pronounce that as blink (of an eye) or bee link. The names are a bit long, but aaabalink is possible. If shortened to alk and blk, that would work. If both middle letters were vowels, that would be more conducive for the words being pronounceable. That restricts us to aiueo and y. The car using a high vowel is nice, so let's go with i. How about: dit and dot? The dot is in the ... dot position! One problem is that cdar becomes doit, which looks like "do it".
- jacknews 3y ago"FLPL, for mysterious reasons, used pretty horrible names like XCARF and XCDRF" It's not mysterious at all, these were also named after the 704 register scheme. Your argument that MacCarthy et al couldn't think of accurate names may be valid (naming is one of the hardest things, after all), but there are certainly 'better' names, so more likely these just stuck after the initial implementations. "so a pattern similar to cadr, cddr ... is possible." Honestly, these are abominations. Remember the point of high level languages etc is not just so you can write code as fast as possible, but that someone else (maybe your future self) can read and understand it easily.
- zeckalpha 3y agoThey are a pair rather than a linked list, you could have a list in first and an item in tail. People just usually see them as lists. But they are binary trees. Left and right might make sense. But then you get into endianness.
- jacknews 3y agoIndeed lisp is built on these tree nodes, pairs, tuples, cons cells, whatever. We should rename it 'treep'? 'nodep'? Lol
- deleted 3y ago[deleted]
- incrudible 3y agoWho cares what HN is written in? It could be written in anything. No, I do not buy the Blub programmer argument, either. Yes, maybe literal geniuses are attracted by exotic languages, but genius alone makes for poor business decisions.