Hacker News new | past | comments | ask | show | jobs | submit login
Car, Cdr, and Lisp... (mschaef.com)
8 points by mk on Feb 14, 2008 | hide | past | favorite | 7 comments



The first time I went to Cambridge to visit MIT (and was incidentally first getting into Lisp), I noticed the Massachusetts slogan on the automotive license plates: "Spirit of America".

This, of course, made me think of the Beach Boys song "Spirit of America," which includes the lines:

  Once as a jet it played in the stars
  But now on the ground it's the king of our cars
and thus I now have this interesting and seemingly permanent cognitive mapping in my mind between Massachusetts, the Beach Boys, MIT, Lisp, and "car". Lisp without car, to me, would just be awful... but for reasons that likely don't apply to anyone else on the planet. :-)


Upmod for arbitrary free association. Now I too cannot imagine Lisp without car. I might say you've consed me into your way of thinking...


"After several months and giving a few classes in LISP, we realized that 'first' and 'rest' were better names, and we (John McCarthy, I and some of the rest of the AI Project) tried to get people to use them instead. ... Alas, it was too late! We couldn't make it stick at all. So we have CAR and CDR."

So car and cdr have been around for 49 years, while first and rest have been around for 48 1/2. I don't think "historical reasons" explains the survival of car/cdr. How many other things that survive from the first 6 months of Lisp could be called accidental?

Edit: this reminds me of the survival of s-expressions. For a long time the plan was to replace them with m-expressions so that Lisp could be a "real" programming language like Fortran. But people kept preferring to write s-expressions. Eventually it became clear that s-expressions were not an unfortunate weakness at all, but one of the best things about Lisp. Obviously the names car/cdr aren't close to this important, but I do think that if there weren't something deeply right about them, they would have been discarded long ago.


I don't think explanations of the popularity of car and cdr need to be any more complicated than that they were the first and hence using them was consistent - also two 3 letter keywords are better than any alternatives I've ever seen proposed. They could happily be called left and right without any inconsistency with implementation.


I tend to use car and cdr when I'm writing functions with some kind of list recursion, and first and rest when I'm using lists as a data structure - not so much of a difference really, but seems to be a useful way to see quickly what a function's doing.


Are you sure you didn't mean to point to http://www.mschaef.com/blog/tech/lisp/car-cdr.html ?


Also: cadr. "Firest" doesn't have the same ring.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: