Comment Re:Templates all over again (Score 1) 427
Thanks for your comment. FWIW, here's what really happened. The function took a std:string as a parameter. The nominal use of it was to put in a char * literal which would get automatically converted to a string, so the parameter couldn't be passed by reference. While trying to step into the function, I stepped through the string constructor, which made several small function calls. When I replaced the parameter declaration with "char *", all that went away, and I was able to step directly into the function.
To be fair, the actual runtime overhead of the std:string constructor might be minimal, and could potentially be avoided by using a reference in many cases - though not this one. So, my concern about bloat when using template classes was anecdotal and might be overblown. As with any tool, you should use the right one for the job, and the string class does have some advantages, notably the ability to magically grow as needed. In this case, though, a char * would have worked just fine, so I contend that the original programmer didn't choose the right tool for this job.
I've used STL classes over the years, primarily vector and string, but I've had many experiences like this where something that C provided was a better fit for what I was trying to do. For example, a file name parameter probably doesn't need to magically grow, so a char * works just fine for that. That sort of experience, combined with having to repeatedly consult the documentation about STL functions because they aren't very intuitively named, has led me to prefer C constructs when I could potentially use either. That's what I meant in my original post when I said "many programmers minimize their use of templates".
Then again, I'm from the "less is more" school of programming. Some folks like to impress themselves and/or their friends by using as many fancy constructs as possible, in order to be judged a "*good* programmer" - as another commenter in this thread evidently does.
Though my original post was perhaps a bit overstated (for your entertainment), I actually do use the STL, but only at a very basic level, and only where it explicitly solves a problem. I think I would be a lot warmer to it if C++ templates and the STL itself were better designed. For example, I much prefer Python's string functions and MFC's "CString" class to std:string.
But even if templates and the STL were better, good-old-fashioned C still can meet most such needs very nicely. And as Tim Peters said, "Beautiful is better than ugly." (BTW, I wonder if Dr. Stroustroup thinks his template baby is beautiful? - maybe he'll tell us.