Quote:I come from a background of around seven years developing games on consoles where code must be designed for performance and a small memory footprint. This is definitely something STL is not.
Well, that's one way of looking at it. Another way of looking at it is that STL code is either performant, or small in memory, or in some cases both. I have only ever seen a few people actually profiled their hand-rolled code against the STL, and I've never seen any significant performance boost. On the other hand I have seen many bugs and errors, which you just don't get in the STL.
We're quite happy to use STL in our console games and it does the job just nicely, thanks.
Quote:Code must be kept simple, and reasonably easy to understand.
Anyone with sufficient experience in C++ can look at STL code and know exactly what it does, because it's used everywhere. Your hand-rolled code that your company uses? Yeah, YOU know it, but when you hire someone new and they write something like linkedListAdd and you have to explain that no, they really needed to use linkedListAddToEnd, and there's casts of void*'s everywhere... is that
really easier to understand?
Quote:Concatenate strings? That's what strcat is for!
I really hope you're not using strcat for something as important as a console game, which is emphatically
not allowed to crash! strncat maybe, strcat_s quite possibly, but please god not strcat in anything critical! I put it to you, it is both faster and more secure to write this:
DoSomethingToFile( folder + "\\" + filename ); // using a string
...than it is to write this...
char path[MAX_PATH];strncpy( path, folder, MAX_PATH - 1 );strncat( path, "\\", MAX_PATH - 1 );strncat( path, filename, MAX_PATH - 1 );DoSomethingToFile( path ); // using a char*
...particularly remembering all the -1's which I nearly did myself before subnmitting.
(Alright, it's still not 100% secure as written. If folder or filename are sufficiently large, the string might fail to resize, and the program will crash - and I'm not checking for exceptions (apart from anything else the overhead of exceptions precludes their use in most games). However, this is substantially LESS likely than a buffer overflow of a mere 260 characters. Furthermore, if the worst comes to the worst, I will know if the string memory allocation fails because it will crash instantly, which hopefully will happen during QA rather than after release (checking player input for validity is therefore still necessary, of course). If str(n)cat writes off the end of a buffer, there are no clues, just strange behaviour and possibly crashes in a completely unrelated part of the program. Good luck hunting THAT down during crunch - yeah, I've been there, and didn't enjoy it.)