STL is not slow.

Recently I was having a conversation with some former colleagues of mine and I got a feeling that most of them were of the opinion that STL was slow and/or inefficient . If you think there is truth to this then let me assure you it’s not the case, not at all. STL is used by so many people and so many libraries that it, in fact, is probably the most optimized piece of code there is. This misconception is actually a result of inappropriate use of STL library and not because STL is inefficient. It maybe true that different versions of STL may have different speeds and I have heard that MS STL is a little slower than others like STLport, but I have no data to either prove or disprove this. I never use MS STL even while programming under Visual Studio (find out why), so I can’t really say.

As I said earlier, the perception that STL is somehow slow and/or inefficient stems from the fact that programmers generally tend to abuse STL containers by not using correct ones. STL has different containers and each is specifically designed to address a particular problem. I don’t want to get into which container to select when, I think Scott Myeres has done a far better job that I ever can. If you haven’t read his book then you better get down to it right now. It clearly outlines how one should go about using STL and addresses several subtitles involved in correct container selection.

Leave a Reply