news.volyx.in

In defense of linked lists (antirez.com)

603 points by grep_it · 1403 days ago · 501 comments on HN

Article summary

The article defends the use of linked lists as a valuable data structure, citing their educational, augmentable, and composable properties. Linked lists can be useful in certain situations, such as in the Linux kernel and Redis, where they are used to implement efficient data structures. The author argues that linked lists are often misunderstood and underappreciated. They also highlight the simplicity and conceptual nature of linked lists, making them a fundamental data structure to understand.

Main themes

  • linked lists
  • data structure choice
  • performance
  • educational value
  • intrusive linking
  • multithreading
  • cache locality
  • kernel implementation

What commenters say

  • Linked lists are not suitable for performance-critical applications due to their poor cache locality.
  • Intrusive linked lists, where the data structure itself contains pointers, can be useful in certain situations, such as in kernels and high-performance servers.
  • Linked lists can be beneficial when simplicity and O(1) operations are more important than performance.
  • Some commenters argue that vectors or arrays are generally a better choice than linked lists, unless specific requirements make linked lists more suitable.
  • The Java LinkedList implementation is particularly inefficient and should be avoided in favor of ArrayDeque.
  • Lock-free linked lists can be useful in multithreaded environments, but implementing them correctly can be challenging.
  • The choice between linked lists and other data structures depends on the specific use case and requirements.
  • Intrusive linking allows an object to participate in multiple collections, but this can also lead to complexity and limitations.