2/03/2006

02-03-06 - 4

02-03-06

Printf is the "leak" in my coding game. Those of you who have worked with me or seen my Game-Tech talk on using C++ to make self-checking code know that my coding style is very rigorous, and I try to engineer things such that the compiler catches the errors, rather than the run time. That is, as much as possible, I want any errors to be compile time errors which I can easily fix, rather than run-time errors which I have to test and debug. While working on GoldBullion I've hardly ever had a bug which wasn't some sort of complicated logic situation. However, there is one glaring exception : PRINTF !! I still make heavy use of printf because IMHO it's the only decent way to format text in C, but it's lack of type safety gives me a stupid bug several times a week. Obviously they're easy to fix, but they cut into my dev cycle a lot, because they're bugs where I have to run the app, see there's a problem, and go fix it. If it was compile-time type-checked the iteration time would be so much better.

addendum : Wes pointed out Boost format as an option. Just reading about it, it looks pretty darn cool. I think I'll try it out. It is 5X slower than printf (!!) and I imagine the compile time hit is not zero because it is a big boost template beast, but those are probably minor trade offs.

No comments:

old rants