STL or Write-Your-Own?

Started by
4 comments, last by jbadams 17 years, 9 months ago
Hi, For my current project, I need several types of containers (linked-lists, hash tables, etc.). Would it be worth saving development time and using STL, or writing my own implementations? In most situations, I'd just go with STL, but I've recently heard it has a lot of overhead which is unnecessary for video game developement. I'm sure that I could implement my own container classes and get them fairly fast with VTune eventually, but I'm wondering whether the STL is actually fine and I'd just be wasting my time... If any one can offer an opinion I'd be very grateful :) James.
Advertisement
It be worth saving development time by using STL. And I don't know where you have heard that stl has alot of overhead and that slt are not suited for game development, because thats just not true.

Lizard
Use STL. Always. I do, and it has never hurt me. My bottlenecks are in my own code.

Reason: you posted in "for beginners", so you probably wont beat the compiler writers doing what they do best. I know I wouldn't be able to.

If it was easy to beat the STL, don't you think people would be using such a faster version as the standard?
Thanks, STL it is then :)
The C++ FAQ Lite has a good explanation of why you should use the container classes rather than writing your own.
Let's see... you can use existing code that has had a lot of testing and is quite well documented, or you could spend what could be quite a bit of time rolling your own solution which would then require extensive testing to ensure it was behaving as you expected.

Unless you're making your own implementation as a learning experience (it is quite a good excercise if you've got some spare time) always go with the Standard Library implementation; if you find that your resulting program is too slow and profiling reveals the overhead from a Standard Library container is at fault then you might consider trying to write a faster implementation.

- Jason Astle-Adams

This topic is closed to new replies.

Advertisement