How much is STL used in game programming?

Started by
65 comments, last by Polymorphic OOP 19 years, 2 months ago
On second thought, maybe I should have posted anonymously too; Looks like anyone who ever says anything negative about STL gets bashed + rated down.

STL is about making life easier for the programmer. It's higher level, more abstract and generic. It's great because it's standard and it saves you a lot of work reinveting the wheel. I'm not disputing those things. What I am saying is that if you want the *fastest* data structures, you get them by tailoring them specifically to their use and working at a lower level of abstraction. I don't think you can really argue with this, it's quite a general concept in computer programming.
Advertisement
really depends on the complexity of your game, SDL means less coding and the speed is a little slower but usally not a big deal, howerver when you get into serius sprite magment you hit a point where you really need something more customized to your needs
Quote:Original post by Melekor
On second thought, maybe I should have posted anonymously too; Looks like anyone who ever says anything negative about STL gets bashed + rated down.


I'm not bashing anybody - I'm genuinely interested in any actual insight you are willing to share with us.

Quote:What I am saying is that if you want the *fastest* data structures, you get them by tailoring them specifically to their use and working at a lower level of abstraction.


What data structures do you have in mind. I'll happily grant you that things like winged-edge data structures have nothing to do in a library of generic data structures. Yet, even in a game, things like that do not make up the bulk of your code.
So it ain't really a STL vs. custom data structures dichotomy - rather, which custom data structures commonly show up in game programming that aren't already provided by the STL.

By all means, do share your experience, instead of being so negative.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by jyk
I can't tell you for sure how much stl is used in commercial games. I can tell you that id rolled their own container classes for Doom 3.


Theres probably a good reason for that and probably related to compiler tech around at the time of writing the code (i'm 99% sure it was started when VC6 was about) and less todo with the performance issues.

Ofcourse, I could be wrong, they might well have benchmarked things and in their case found the STL to be too heavy.
I'm not the authority on the matter, but if it means anything, i've never had a time where i regretted using STL.

If you are not sure of the speed of STL, i dare anyone to do this: make your own container and make the equivilent STL container, add 100,000 elements, and race 'em.
Quote:Original post by Fruny
By all means, do share your experience, instead of being so negative.


For example, some code I've been working with uses a lot of list operations. Because my list is not so generic(it doesn't have to work with every data type) I required that it can only use classes with a prev and next member, which lets nodes remove themselves instead of having to search the whole list before removal(like std::list does). If I was being negative, I appologize, but getting rated down will do that to a person.
Quote:Original post by leiavoia
I'm not the authority on the matter, but if it means anything, i've never had a time where i regretted using STL.

If you are not sure of the speed of STL, i dare anyone to do this: make your own container and make the equivilent STL container, add 100,000 elements, and race 'em.


Agreed! I know that STL is saving me lots for my Audio Library. I know I will have to do something different when it comes time to cross platform it, but maybe I can use STLPort or something.

- Drew
Quote:Original post by Melekor
I required that it can only use classes with a prev and next member, which lets nodes remove themselves instead of having to search the whole list before removal(like std::list does). If I was being negative, I appologize, but getting rated down will do that to a person.

std::list does not require the entire list to be searched in order to remove an element. Removal is guaranteed to be performed in constant time given that you have an iterator to your object.
Quote:Original post by _the_phantom_
Quote:Original post by jyk
I can't tell you for sure how much stl is used in commercial games. I can tell you that id rolled their own container classes for Doom 3.


Theres probably a good reason for that and probably related to compiler tech around at the time of writing the code (i'm 99% sure it was started when VC6 was about) and less todo with the performance issues.


i have doom 3 sdk 2, the project is in VC++ 7.0, i'm sure it has to do with more of portability than anything else because each implementation of STL will be slightly different on different compiler vendors that can be abit unsettling.

I've looked into ID's container library and in terms of C++ its pretty mediocre and use of templates is very minimal, no separation of de/allocation de/construction that the STL allocator concept do an important thing to do (although they have custom memory managers). Compared to some of the implementations of STL i've seen its nothing.

Quote:Original post by _the_phantom_
Ofcourse, I could be wrong, they might well have benchmarked things and in their case found the STL to be too heavy.


Maybe i should do some profiling over the weekend and post some results if i'm not bussy [smile].
Quote:Original post by Polymorphic OOP
std::list does not require the entire list to be searched in order to remove an element. Removal is guaranteed to be performed in constant time given that you have an iterator to your object.


Hm, I must have missed something, what function does that? As far as I can see in the Docs there is only one overload of the list::remove function and it takes a const T&, not an iterator.

This topic is closed to new replies.

Advertisement