I have to respectfully disagree with Elynn Lee's answer here, just the part that proportional fonts can't line up at the beginning of indents. I actually think there's a strong case to be made for the advent of proportional fonts in programming, especially after David Jonathan Ross' work with Input.
Converse Unisex Adults Converse Unisex Unisex Converse Adults Converse Adults So, first I'll screenshot the example from Elynn's answer in Input:
As you can see, lining up indents can also be achieved with appropriately adjusting spacing.
The real place proportional fonts shine is in readability. These are the letters 'm' and 'n' in Source Code Pro, a popular monospaced programming font.
Here they are again in Input:
Notice the subtle difference here, this may not be much but it turns out our eyes are way better at detecting typos when they have the letter's width as a clue, e.g.
is easier to tell apart than
in a sea of code. So, spaces before the beginning of a line are not a problem inherent to proportional fonts and can be solved with variable spacing.
To quote Input's creator:
I realize that using proportional fonts in code is a tad experimental, and some will keep to Input’s 56 monospaced variants. Input’s proportional fonts, Sans and Serif, try to take what is best about the monospaced genre and fuse it with a font that lets each letter take up the space it needs. I use and combine them on my computer for everything from code to correspondence. While most user interface fonts are generic, Input has a distinct voice. And when some of Input’s earliest beta testers never realized they were coding in a proportional font, I knew I was onto something.
Source: David Jonathan Ross
Personally, I've tested this and my error rate from typos has gone down significantly, enough to convince me to switch despite some awkwardness. The only downside of this is a convention where spaces are used after characters to line things up, such as a variable declaration like the following:
vs.
This could actually be fixed with a more subtle variable spacing algorithm. It doesn't bother me enough to move off Input because
- This convention, while aesthetically pleasing isn't very critical and has the jury out on it. People like to debate it to no end. I just personally don't care for it much and don't do it in code I write from scratch.
- Most of my code is not variable declarations.
- This can probably be fixed, by teaching our editors to treat 2+ consecutive spaces or tabs with variable spacing. The editors just haven't gotten around to it yet. There's work going on in this already, e.g. Elastic tabstops. This is what an ideal outcome could look like:
Converse Converse Adults Converse Unisex Unisex Adults Unisex Adults Converse Overall, the jury's still out on what's globally better (I asked this question) but I thought I should make a case for proportional fonts.
But if you're someone like me who makes typos semi-regularly, I'd definitely recommend trying out a proportional programming font like Input and seeing what your before/after is. I also highly recommend reading this essay about Input -- Input: Fonts for Code.