4 ms·
What’s wrong with STL?
by GnarfGnarf 2y ago
What’s wrong with STL?
- ratmeadow 2y agoLooks like the author is into game development, and STL is often avoided in that context. I think one of the reasons is performance - STL has made some design decisions which prioritise general use over performance. Often cited example is `std::unordered_map`, whose spec necessitates an implementation using separate chaining (or similar). Depending on the use case, in high performance applications, a different implementation can be much faster. Although I don't understand why some people hate all of STL so much. Like sure, use your custom hash map, makes sense. But is anyone really replacing basics like `std::find` or `std::sort`?
- GnarfGnarf 2y agoThanks for the clarification. I think STL is the greatest thing since sliced bread. The time I have wasted in the 90’s debugging malloc/realloc/free rat’s nests for dynamic arrays, I could have put to better use. Thank god for vector/deque etc. I work isolated. I didn’t learn about STL until years later,
- daemin 2y agoProbably also because Game Developers had to deal with the MS STL implementation which for many years both the compiler and standard library were behind the times and not that optimal. Case in point when using a std::deque with MS STL it's not really efficient because it has a very small buffer size, so it pretty much degrades into a linked list if the element is big enough. See: https://devblogs.microsoft.com/oldnewthing/20230810-00/?p=108587 https://devblogs.microsoft.com/oldnewthing/20230810-00/?p=10... Then there's the case of std::unordered_map which has been benchmarked recently, and for all the flak that boost gets I am considering using it for its hash map. https://jacksonallan.github.io/c_cpp_hash_tables_benchmark/ https://jacksonallan.github.io/c_cpp_hash_tables_benchmark/