These days my eyes are dimming, so I dislike skinny fonts. Now I use DejaVu Sans Mono in _bold_ exclusively. Every now and then when HN does a programming font post, I try out different ones, but I always end up going back to DejaVu Sans Mono Bold.
Also, the old VGA font is surprisingly nice and legible. Can be had here:
You might take a look at Trebuchet MS. One thing I like about it is that the strokes are nice and fat. At least on my high-DPI displays; haven't checked on a low or medium DPI display.
https://www.microsoft.com/en-us/p/verdana-pro/9n8d67vhhdc2
Coincidentally, I wonder if the license allows it to be downloaded and installed on other OSes, like the old "Microsoft core fonts" package that included Verdana.
It doesn't look like it.
The Microsoft core fonts EULA (https://web.archive.org/web/20091208063245/http://www.micros...) says things like:
> You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
> You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT; provided that [they're verbatim, include the EULA, aren't distributed for profit]
> You may not rename, edit or create any derivative works from the SOFTWARE PRODUCT, other than subsetting when embedding them in documents.
> You may permanently transfer all of your rights under this EULA, provided the recipient agrees to the terms of this EULA.
So you can distribute and install them. You have to take some care, but you don't need to involve Microsoft, and you're not bound to the systems they were originally intended for.
The Verdana Pro license (https://www.microsoft.com/en-us/servicesagreement/#STANDARDA...) says things like:
> You may install and use the application on Windows devices or Xbox consoles [...]
> [You may not:] Work around any technical limitations in the application.
So it's very limited.
This makes sense: our eye uses the top and bottom of words to ‘key’ the word. Use proportional and you add information to this system.
[1] https://blog.codinghorror.com/comparing-font-legibility/
[2] https://journals.sagepub.com/doi/pdf/10.1177/001872088302500...
(edit: add references to research)
Coding using proportional fonts is easy to get used to, and it has its proponents. The key is: indent, don't align, and use TABs.
https://news.ycombinator.com/item?id=18958335
But one thing I'm wondering about:
> All of the tooling for writing code defaults to monospace...
Do you have an example of such tooling? One that I'm familiar with is Google's coding standards, which are obsessed with lining things up in ways that only work in monospaced fonts. Is that the kind of thing you're thinking of, or something else? Thanks!
People are always puzzled when they learn I'm not using a monospaced font, think it's impossible but agree that it's much more readable. Then keep using their monospaced fonts.
Actually, nobody likes to read books or blog posts printed with monospaced fonts, right? There is no reason to do it with code.
Alignment like this
short = 1
much_longer = 2
is lost but it's not really important. I think it's also against Python's style guide and for sure it doesn't survive the Elixir formatter (I checked this now.)I don't! :-)
I spent many years lining things up. I would write code like this:
foobar(firstArg,
secondArg,
thirdArg);
(For the sake of discussion, assume that those arguments were too long to just put it all on one line, so you would naturally want to use multiple lines.)Then when I realized that 'foobar' wasn't such a good name, I had to re-align all the code:
doTheRealThing(firstArg,
secondArg,
thirdArg);
At some point, maybe 20 years ago, I got really tired of this.So I thought, "what if I just use indentation instead of trying to line things up in columns?" Which led to this:
foobar(
firstArg,
secondArg,
thirdArg
);
And when I renamed the function, I didn't have to move everything around any more: doTheRealThing(
firstArg,
secondArg,
thirdArg
);
Instead of every line changing, only one line changed. [1]After I adopted this style, I noticed that the code editor I was using at the time supported proportional fonts, so I got curious and tried one - I think it was Verdana.
And sure enough, the code was just as readable as it was before.
If you don't line things up in columns but instead just use indentation, then a proportional font works just as well as monospaced.
[1] Some will say "just ignore whitespace in your VCS diffs, and this won't be a problem." But I want to know about whitespace changes, just like I want to know about any other change.
Interestingly, one of the reasons sometimes cited for using alignment is that it reduces the number of lines of code needed for a statement or expression. But as often as not, I've seen that backfire because the code gets pushed farther and farther to the right, eventually resulting in more lines of text instead of fewer.
I posted an example from the Rust/Servo code in another comment:
https://news.ycombinator.com/item?id=18962177
This code in their old column-aligned style is actually one line taller than the indentation style they recently switched to.
Cannot you just have your editor do that for you?
But there was more to it: I realized that I didn't like column alignment any more. It didn't make the code any more readable, and in many cases it made it less readable.
A more recent example of a group that abandoned alignment is the Rust and Servo teams at Mozilla. Their code style used to look like this:
let mut rewrites = try_opt!(subexpr_list.iter()
.rev()
.map(|e| {
rewrite_chain_expr(e,
total_span,
context,
max_width,
indent)
})
.collect::<Option<Vec<_>>>());
A year or so ago they changed to a purely indentation-based style: let mut rewrites = try_opt!(
subexpr_list
.iter()
.rev()
.map( |e| {
rewrite_chain_expr( e, total_span, context, max_width, indent )
})
.collect::<Option<Vec<_>>>()
);
They found this style to have advantages over alignment, perhaps for some of the same reasons that I prefer it.Of course, if you already have made one of these two jumps, it should be a no-brainer to make the other one as well.
Proportional fonts are different. Anyone can use them without interfering with readability regardless of the fonts and editors that others use. If you look at my code, you will never know whether I wrote it in a proportional font or a monospaced font.
It is not quite as bad as you make it sound.
While editors which haven't yet implemented the elastic tabstops mechanism may not align some text properly in files where tabs were used with elastic tabstops, the problem isn't that bad. All leading tabs (indentation) will be okay, and the chances of text not aligning correctly diminishes as the width between tabstops increases.
Most things line up perfectly fine i IntelliJ.
I have had someone on my team with an itch for lining up variable assignment. That was the one thing that looked off.
int abc = 3
int defg = 4
int bigTestVaribale = 6Nevertheless, for teams that insist, the auto code formatter makes it look ‘nice’ for them.
Personally, I think vertical alignment apart from indentation is a mistake for more than these reasons. It implies a structure where there is none.
I realize that most programmers use monospaced fonts, but I personally find proportional fonts to be much more readable and pleasing to my eye. I would be really interested in a similar font comparison that included proportional fonts that are suitable for programming.
Right now my favorite is Trebuchet MS. This renders beautifully on the high-DPI displays I use, and it has easily-distinguished glyphs for the common mistakables like Il|. Its tilde is not very good though, so I used a font editor to swap in a better one.
But I'm always interested to hear about other options!
When I do have to use a monospaced font (e.g. in a terminal window), Liberation Mono is my favorite. Definitely worth a look if you like monospaced fonts.