| ▲ | klps10 8 hours ago | ||||||||||||||||||||||
I think this article rewrites history and it is unfortunately already cited by the clankers. "Intrusive" is C++ speak. The regular linked lists always had embedded data or a mix of embedded data and pointers to outside data in a C struct. | |||||||||||||||||||||||
| ▲ | dahart 7 hours ago | parent | next [-] | ||||||||||||||||||||||
I googled it and got the response that Bjarne Stroustrup first used “intrusive” in his 1985 C++ book. He was adding a new distinction between the older intrusive kind and the new ‘non-intrusive’ kind, because some people had started using C++ to allocate the list nodes and the payload structs separately. Now with std::list and college classes often teaching non-intrusive linked lists, and intrusive lists only being used in deep dark places like the OS kernel, maybe it’s easy to assume the ‘regular’ kind is non-intrusive. What Stroustrup called ‘intrusive’ had been the default understanding of linked lists since around 1955, and what people used most often. A ‘regular’ linked list to most people back then was the intrusive kind, and the term ‘non-intrusive’ might have been an attempt to sell people on the benefits of abstracting and separating node types from payloads, but that maybe papers over the disadvantages a little. The only kind of linked list I’ve ever used in my professional career is the intrusive kind. There are very few good reasons to ever use non-intrusive lists outside of the classroom. At least, not if you care about performance at all. They might be convenient & easy, but it’s usually the case that either an array or an intrusive list would be a better engineering choice. | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | usrnm 7 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
"Intrusive" may be a C++ speak, but I wouldn't say that one or the other type of lists is necessarily much older or more "normal". After all, a cons cell embeds data and not the other way around and lisp is one of the oldest programming languages in existence | |||||||||||||||||||||||
| ▲ | HarHarVeryFunny 7 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
Back in the day what is being called out here as an "intrusive" linked list was just a linked list, since you didn't have the luxury of having memory and CPU cycles to waste with extra allocations and indirection. In the C++ world the STL introduced generic data types such as linked lists, which became the default, but "instrusive" linked lists still have their place in specialized list-heavy use cases where performance matters. In a previous job I wrote a widely adopted XML/JSON library using instrusive lists to link child elements, and the performance benefit was considerable, with my DOM API basically hiding this implementation detail from the user. | |||||||||||||||||||||||
| ▲ | packetlost 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
You have it backwards, an intrusive linked list is a linked list that is embedded in another data structure. The classic example is a linked list whose elements live on the stack. The article is wrong too, or at least using the term over-specifically. It's not really tied to C++isms at all. | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | 8 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
| [deleted] | |||||||||||||||||||||||
| ▲ | thewillowcat 7 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
This was my reaction exactly. I was surprised by the diagram of a "normal" linked list. | |||||||||||||||||||||||
| ▲ | Lwerewolf 7 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
I came to this relatively late (2013-ish, windows kernel development, scouring OSDev, etc) so I thought that was always the right name for them. Prior experience was mostly... higher-level langs. | |||||||||||||||||||||||
| ▲ | tantalor 8 hours ago | parent | prev [-] | ||||||||||||||||||||||
I concur. I recall being a student and when implementing LL for the first time, you did it this way (mix your data and ptr to next node). It is baby's first linked list. | |||||||||||||||||||||||