Friday, June 24, 2005

Use of Color

So I've been reading (among other things, I've got this perpetual pile of books that I'm currently reading sitting next to my bed or on my coffee table) the latest edition of Effective C++ by Scott Meyers.

If you're a C++ programmer, odds are I don't have to tell you what a great book this is, and that even if you've read the first or second edition you really should go out and get the third, since it's got a lot of new stuff in it that brings the various topics up to date with the current state of the art. All this goes without saying when you're talking about a book from Scott Meyers.

What I do want to talk about is the way Meyers uses color in the book, because it seems to be pretty unique as far as I can tell.

The book is printed in black text on a white page, as you'd expect, but Meyers has gone out of his way to highlight various interesting parts of his examples and text by making them bright red, so they clearly stand out to the reader.

Rather than just showing yet another version of the piece of code he's been modifying throughout the current example, subsequent iterations of a design will have the new additions highlighted in red, so it's quite clear that, for example, the reason this version of the code is better than the last one is that the Window parameter is being passed by const reference instead of by value as in the previous version of the code.

So as to avoid totally screwing over the color blind among us, the examples also include descriptive comments that serve to draw the reader's attention to the section of code in question, in addition to further elaborating on what's being changed.

This isn't the first Meyers book that has used this technique, he does the same thing in Effective STL, which is also quite worth picking up, but so far I haven't seen a whole lot of other authors making use of it. If I had to guess I'd say it's probably because printing in multiple colors has to make the production process for the book quite a bit more expensive, and unless you're someone like Meyers, for whom publishers can be pretty damn sure any given book he writes will be a smashing success, it's probably pretty hard to justify, even if it does make the book quite a bit more readable.