Hacker News new | ask | show | jobs
by account42 712 days ago
Not only are linked lists rare, they are also mainly useful exactly in situations where you cannot guarantee a (even mostly) linear allocation order.
4 comments

the optimization could be vaguely interesting if you are implementing a lisp (or some other list heavy language) and don't want to perform too aggressive non-local optimizations to optimize the layout of lists.
As I recall, at least one of the Lisp machine Lisps used a bit in the cons pair to declare if the cdr (tail element) was immediately following.

EDIT: https://en.wikipedia.org/wiki/CDR_coding

Memory pools are commonly allocated in a contiguous block and sliced into nodes placed onto a free list. They will be sequential until the pattern of allocations mixes them up.
Garbage collection is good at consolidating swaths of adjacent free objects into ordered allocation.
The point here is that this isn't guaranteed, it's that it is likely. And as the other commenters mention, it's likelier than you think.
The Linux kernel is full of links, and so are many (probably most) C programs in the GNU/Linux userland.