johno
Ok, so STL isn't very OOP, all well and good. I am definitely moving away from OOP.
To clarify; I was trying to understand what I could do to move away from using STL containers purely based on Casey's apparent sentiment that STL is just plain bad. I certainly understand that Casey doesn't like templates.
Most STL structures give the calling code very little control over the memory allocation patterns. Random small allocations on the system heap are bad because:
a) They're bad for cache performance.
b) They fragment the heap.
EA's reimplementation of the STL fixes at least some of this (though not all of it is publicly available):
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html
Implementing classic datastructures by hand is where I started out, so it certainly isn't beyond my ability to build something custom, but I'm trying to understand if there is any real reason to not use STL. As mentioned, my tests indicate that the implementations that MSVC STL offers are at least as performant as my own (and most of the time better), and not having to maintain something myself is a big win imho.
Well, yes, std::map will beat out an unbalanced binary tree, because balancing is a critical optimization for trees. (A good question to ask yourself here is: why use a tree for key-value lookup? There are lots of ways to build maps that are both simpler and have fewer performance cliffs.)
I will freely admit that I'm much more of a game designer / programmer than a purely technical programmer type, so that is my primary concern, but I do still write lots of my own code / use very few third party things. So I'm basically just checking to see if I'm missing something that would be a big productivity and / or performance gain.
This talk by Jonathan Blow is worth watching:
https://www.youtube.com/watch?v=JjDsP5n2kSM
90+% of the time, you want an array or a resizable array (std::vector). When that's *not* the case, you will usually have enough information on hand to build a better solution for the problem you *actually have* than the STL authors did.