Do I need to learn the Standard C++ Library???

Started by
40 comments, last by torakka 17 years, 8 months ago
HI I'm a beginner C++ programmer and have experience in C#/VB.net and am wondering do I really need to learn the STL? or the C standard library or can I just get on with learning Win32?
Advertisement
you should learn a good part of it yes. however, there are some less important things that you don't need to know... like how many of us have ever used a valarray?
well of course. :) you should learn as much as you can. stl is far from perfect though so don't get too attached. when you work professionally you're less likely to use it but still having a good understanding will keep you from sounding like an idiot when you talk to your lame friends who develop non game stuff. ;)
For just Win32, maybe you can get by without it. But try to learn a little of it anyway. So far I've only used vectors, and they have gotten me out of many sticky situations. I certainly don't regret it.
(Also, I hear learning/using Boost is beneficial as well; I may look into that soon)
____________________________________Spazuh- Because I've had too much coffee
Quote:Original post by adjustedrace
HI I'm a beginner C++ programmer


Welcome!

Quote:and have experience in C#/VB.net


That's a good start. [smile]

Quote:and am wondering do I really need to learn the STL?


Yes, undeoubtedly.

Quote:or the C standard library


That too, though it's not as urgent.

Quote:or can I just get on with learning Win32?


You might, but you're severely limiting your options.
"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 blackpawn
well of course. :) you should learn as much as you can. stl is far from perfect though so don't get too attached. when you work professionally you're less likely to use it but still having a good understanding will keep you from sounding like an idiot when you talk to your lame friends who develop non game stuff. ;)


Really? You don't usually use the standard C++ library as a professional game developer? This comes as a bit of a shock to me, as there are some parts of it that I find practically irreplacable when using C++. I mean, what do you use rather than vectors for instance? You don't create your own custom vector class do you? Do you just program without the use of them entirley? Some clarification here would be neat, I am always interested in how things usually work in the professional game development world.
Quote:Original post by PunaProgrammer chris
Quote:Original post by blackpawn
well of course. :) you should learn as much as you can. stl is far from perfect though so don't get too attached. when you work professionally you're less likely to use it but still having a good understanding will keep you from sounding like an idiot when you talk to your lame friends who develop non game stuff. ;)


Really? You don't usually use the standard C++ library as a professional game developer? This comes as a bit of a shock to me, as there are some parts of it that I find practically irreplacable when using C++. I mean, what do you use rather than vectors for instance? You don't create your own custom vector class do you? Do you just program without the use of them entirley? Some clarification here would be neat, I am always interested in how things usually work in the professional game development world.


I think there's some (incorrect) prejudice in the industry against SC++L. They don't trust it because it's not "fast enough" and maybe even because it's "3rd party"(like it's a seperate library and not as much part of C++ as the float or int types). So they go ahead and implement their own containers. I think even Carmack did this. Now, how is it possible a group of programmers that is specialized to develop SC++L is writing a worst implementation than 1-2 programmers that also have a game to write, I'll never know. Do they also implement their own float type? Why not write their own compiler and be done with it?
You should definatly learn the STL, you'll be so much more productive, produce better code, learn some smart tricks, produce more efficient code, etc.

Quote:Original post by mikeman
I think even Carmack did this.

They were working with Visual C++ 6, which does have some crappy containers; also I remember him talking about how some people (maybe himself?) wasn't that familar with C++. If some algorithm/data structure is not implemented in the STL then you can go ahead and code it yourself, unless you have special knowledge of your target system (for instance is it guarenteed to support SSE3?) you won't beat your compiler's implementation and if you can then you shouldn't work with that compiler. A good example of a data structure you could implement yourself is a hash map, and the STL doesn't have a lot of search algorithms.
Here's my 2 cents: learn it, and use it for everything that looks like a "container problem", especially if you're a beginner at C++!

I won't judge on the whole flame-prone subject of the STL being too slow or badly implemented or whatever. No matter who is right there, using it will give you a reliable, portable and versatile implementation of many containers, and thus it will spare you a lot of time and frustration. If, at any point, your profiling efforts tell you that some part of the STL is slowing down a critical part of your code, then you can still try to implement something better with the things you've learned by then. At that point, you'll probably be pretty familiar with the language, and it won't take you much time. Trying to implement a map as a beginner will take a lot of time and the results will be nowhere near the quality of pretty much any current STL implementation.
>you won't beat your compiler's implementation and if you can then you shouldn't >work with that compiler.

Actually, I can beat the compilers implementation by order of magnitude -- and that is using clean C++ - no assembly at all!

http://www.liimatta.org/fusion/profile/result.txt

The times are in milliseconds, smaller is better. The times are average of (N-2) runs, where N is 20 I think. The lowest and highest time are dropped before averaging.

The results are from top to bottom in order of oldest to latest, it's noticeable how g++'s std::list implementation has improved over the years. ;-)

This topic is closed to new replies.

Advertisement