3 ms·
Self-referential data structures are a code smell in non-GCd languages, and I think I have neither used or written a doubly linked list since university. You c
by nchi3 6y ago
Self-referential data structures are a code smell in non-GCd languages, and I think I have neither used or written a doubly linked list since university.
You can do both in unsafe rust though. But you probably shouldn't no matter what high level non-GCd language you use.
/Another ex-cpp-master-race guy who has been impressed with Rust
- cycloptic 6y agoI see doubly-linked lists and other self-referential structures all the time in low-level code. Boost even has a whole library dedicated to them: http://www.boost.org/libs/intrusive http://www.boost.org/libs/intrusive
- steveklabnik 6y agoFor a really interesting take on this area, see http://dtrace.org/blogs/bmc/2018/09/28/the-relative-performance-of-c-and-rust/ http://dtrace.org/blogs/bmc/2018/09/28/the-relative-performa... Specifically, the discussion about intrusive vs non-intrusive data structures and their frequency.
- cycloptic 6y agoIt would be interesting to see how that measures up in a different test where the accesses are all from a cold cache.
- nchi3 6y agoYeah, hence high level non-GCed language. Using heap allocated linked lists is rarely the way to go if you're not developing for embedded. However, if you're developing for embedded you'll probably want to be familiar with unsafe either way if you're going to use Rust. Regarding self-referencing: Rust encourages you to design differently, which I've found leads to nicer and more thought out designs most of the time. Not all algorithms are possible (or efficient) without it though, and for those you'll have to use unsafe if you _really_ have to implement them yourself.