The traditional font family for use in writing computer code is monospace. Partly this is because monospace was all that was available when computer programming began and remained largely the only choice until relatively recently. Mostly, though, monospace is used because coders use spacing to line up their code to make it more readable.
I visited a website which listed some favorite programming fonts and described the properties of each font which made it suitable for programming. All the fonts were monospace as one would assume. However a commentor on the site said that he began using a variable width font a few years previously and never looked back.
So I’ve decided to give it a try, and so far, I like it. Variable width fonts are just easier on the eyes after a while. Still, you need a decent programming font. I would like one where the parentheses (and brackets) have wider than average spacing, and similar characters such as zero and the letter ‘O’ are distinguishable. Interestingly, I’ve found that when I don’t intentionally line my code up, I actually don’t want it to line up. I have found that it is actually easier to read the code when all the characters in the line below do not line up directly under characters in the line above. My left margin is always clean because the spaces and tabs are always the same size. For the most part, I don’t see spacing as a problem. In my particular font, I wish the space character was bigger, though. Another “pro” is that I can fit a whole lot more on one line without using a small font or a harder to read, narrow font.
There are some “cons” though. That narrow font means that people who wrap their comments to more than one line seem to wrap them way too soon. And using a variable width font means I will, likewise, tend to wrap mine later than would be readable for a monospace-font developer. My left margin is always clean, but every once in a great while, I find that code that was intended to line up does not. However, this hasn’t been a problem for me. Coders, I think, often over-format their code, even reducing readability to some degree.
What I would like to see is an editor that can mitigate the downsides of variable width fonts by manipulating the whitespace and recognizing the language syntax. For instance, the editor should be able to detect when a monospace-font developer adds superfluous whitespace for the purpose of lining up code and then expand the variable width whitespace as necessary to make sure the code is lined up. Though this can’t ever be perfect, it can be perfected to a reasonable degree. Also, comment blocks that are obviously wrapped intentionally could be “unwrapped” then “rewrapped.” There are email applications that do this with email text wrapped to the standard 80-or-so lines. The editor can then automatically wrap comments back to monospace width when saving.
I am currently using KDevelop, KDE’s development environment, for my C++ development. I might just try to find out where the editor code is and see if I can implement something like this. In the mean time, though, I think I’ll keep experimenting with different variable width fonts anyway.