> Technical book writers could easily use non-monospace fonts for code examples and they don't-- for good reasons.
Actually, Stroustrup did use a proportional font (and an italic one at that) for the code samples in The C++ Programming Language.
I've never seen anyone doing serious research on the effect of this style on comprehension or reading speed. Subjectively, I didn't find it unduly difficult to read. I suspect any concerns over alignment could be overcome by using the same typographical tools we use in other contexts: tabs/tables, proportional vs. lining figures, etc. We already use specialist editors and fonts for programming routinely anyway, so I don't see any inherent reason we shouldn't make them look good. :-)
Actually, Stroustrup did use a proportional font (and an italic one at that) for the code samples in The C++ Programming Language.
I've never seen anyone doing serious research on the effect of this style on comprehension or reading speed. Subjectively, I didn't find it unduly difficult to read. I suspect any concerns over alignment could be overcome by using the same typographical tools we use in other contexts: tabs/tables, proportional vs. lining figures, etc. We already use specialist editors and fonts for programming routinely anyway, so I don't see any inherent reason we shouldn't make them look good. :-)