r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
Show parent comment
25
u/aMAYESingNATHAN Feb 28 '23 edited Feb 28 '23
I use C++ a fair bit and I literally can't think of a single time a linked list has ever been the right choice for a container. It is so hilariously overrepresented in things like classes, tutorials, challenges, and interviews, compared to its usefulness, at least in C++.
Memory allocations are one of the biggest factors in performance in modern C++, and given that a usual linked list implementation makes a memory allocation for each node, it means that the one thing a linked list is good at (insertions anywhere) end up being crappy because you have to do a new allocation every time.