Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unfortunately, part of the pragmatic usefulness of newer Lisps (Clojure and Janet) is the abandonment of CAR and CDR in favor of efficient distinct data structure types backed by efficient bases (tries, arrays, arraylists, hashmaps) and a focus on homoiconicity as the winning feature, separated forcefully from the idea of linked lists and CAR/CDR.


I'm honestly not sure why this sentence starts with "unfortunately".

Linked lists are comically inefficient on modern hardware and naming two of your fundamental operations based on CPU instructions from a chip from the 60s is not what I would call good API design.


1954, actually. But it's a minor thing. You don't need to know anything about the IBM 704 to write Lisp. A cons cell is a specific data structure and its components have specific, if unusual names. There's a lot of unintuitively named symbols in Lisp that are better targets for criticism than car and cdr.


I don't well understand this. How is clojure more efficient than common lisp?

Would you explain further?


From a compute standpoint I guess I'm wrong. But from a modeling power perspective, I definitely prefer the clarity and uniformity of Clojure's standard library functions. Maybe that has something to do with its distinct data types, maybe not.


What do you mean with 'distinct data types' ? Most lisps are strongly typed. SBCL even accepts type declarations.


Data structure types. In standard CL and Scheme, data structures are implemented at their base using cons cells, and their interpretation as tables, trees, queues, etc. is up to library functions. Unless I have somehow misinterpreted the selling points of classic Lisps, because Clojure and Janet data structures sell themselves as being not built this way. Clojure makes a different trade-off by building all its data structures off of hash array-mapped tries. But Janet goes out of its way to use efficient and closely-mapped base stores, even if the contained elements are dynamic Janet objects.


> In standard CL and Scheme, data structures are implemented at their base using cons cells

That's not true. Both CL and Scheme have other data structures besides cons cells, and that's been true for the Lisp family of languages for nearly 70 years now.

This bizarre belief that everything is a cons cell in Lisp and Scheme needs to go away.


Thanks for courteously linking me to the relevant documents! Very productive and good-natured of you.


> Thanks for courteously linking me to the relevant documents! Very productive and good-natured of you.

Thanks for the sarcasm! Very productive and good-natured of you.

For your reference:

LISP 1.5 manual: https://www.softwarepreservation.org/projects/LISP/book/LISP...

Arrays were present in 1960. Admittedly, not much else but clear evidence that even then it wasn't just cons cells.

https://www.lispworks.com/documentation/HyperSpec/Front/Cont... - Common Lisp Hyper Spec which describes data structures other than lists and cons cells.


For someone who initiated hostility, you're a dismal failure at supporting your arguments. I'm not reading two entire manuals to find the citations you're referring to and should've cited yourself.


> I'm not reading two entire manuals to find the citations you're referring to and should've cited yourself.

C-f that PDF for "array". For the other manual, I linked the TOC. It's right there on the page (arrays and hash tables, and you can follow up with structures and objects) and there's no reason to read the entire manual. I figured most people knew how to use a table of contents, I apologize if I expected too much from you.


Flavors, from 1979 or so.

https://www.softwarepreservation.org/projects/LISP/MIT/nnnfl...

LOOPS, from about the same time.

https://interlisp.org/documentation/2024-loops-book-1.pdf

More general discussion in a OOPSLA contribution from 1986.

https://web.archive.org/web/20220817140051/https://interlisp...

The 1988 book about CLOS, the approach that was later accepted in ANSI Common Lisp.

https://doc.lagout.org/programmation/Lisp/Object-Oriented%20...


Ok, so I am sorry but this is an extremely uninformed take. Please have a look around in Racket's documentation before going any further: https://docs.racket-lang.org/


> efficient distinct data structure types backed by efficient bases

...do not require abandoning CAR and CDR, I think. See all other lisps having vectors, hashmaps, etc. Perhaps you're talking for code representation ? But I don't think that true for all 'traditional' lisps either. Also, there's been some innovation regarding lists: https://docs.racket-lang.org/reference/treelist.html




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

Search: