WireWorld » Hacks » Wirehead on Hacking » My personal transformation about templates

My personal transformation about templates

I'd like to take upon myself the challenge of writing a response to the three blog posts that Reg Braithwaite wants to see written. What I'd like to talk about is how I went from never using any templates to using tons of them.

I spent a bunch of time in college programming in C++ but avoiding templates and the STL. I think this was largely because various people were telling me about how much templates sucked and they weren't portable and whatnot. So I went along with it. And I wrote a bunch of nice little base classes to do various useful things and wasted a bunch of time. And the thing is, the Mozilla folks in their old C++ portability document that got passed around was a perfect, knowing, portable, quotable document to refer to.

There were other things, of course. I really don't like the way that templates make your code look. And I was in school, where we had to implement all of the fundamental data structures ourselves, so having a huge base of tools already written wasn't very big in my mind.

I wrote some fairly substantial pieces of code on my own, for my career development, at this time. I even burned a CD to hand to prospective employers at career fairs with some of it. And all of it was totally and utterly template free.

Finally, I graduated, found a job, and entered the real programming world, where things had to be done.

Within a few months, everything I did was STL based.

What caused the turnaround? Well, there's a few ideas that I had previously held quite dear that I realized were pretty dumb:

Posted by david :
Thank you for saying that.

I've believed for years that "coding is like solving cross-word puzzles" -- great if your employer wants to employ cross-word puzzle solvers, otherwise a waste of time. It's a much older metaphor, (see for example)
but I meant exactly the same thing: templates are what you use when you want to leave something meaningful behind. "Low level code" is what we do for personal entertainment.
Posted by Reg Braithwaite :
Thanks, nice post!