Ask HN: Anyone using proportional fonts for coding?
I'm curious about any less obvious pros and cons, as well as recommendations for any fonts to try.
I'm curious about any less obvious pros and cons, as well as recommendations for any fonts to try.
It definitely felt weird at first, like I was reading code that somebody had pasted into Microsoft Word. But that passed and now it's all upside.
I screen-share my IDE from time to time and I've never had anyone comment on it.
To my eye, they also just make code look… I don't know, messy somehow? Especially with serifs it looks like a tractor trailer wrecked and spilled its payload of characters all over the place.
And, they say, programmers use monospace fonts because it helps them catch typos. In reality, variable glyph widths make it easier to identify typos.
Perhaps we can design a new character system script specifically designed for ease of programming! I say we use Aurebesh. :)
I think APL already did this.
Oh, what we are really missing are code-oriented ligatures, like -> or ==>. Sad, but I find fixed width so bothering that I’m not willing to try the fixed width fonts that offer such ligatures.
This is not a universal truth. I've worked at faang companies that don't even do this.
In fact many great comments I've seen have been ASCII art diagrams. Those should be encouraged.
Like when someone shouts to you after they've already thrown, and you must turn and catch in a fraction of a second. Or take a ball to the jaw.
You've expressed a considered preference, not a hot take.
https://developer.apple.com/library/archive/documentation/Xc...
E.g.
/*:
Some comment
*/
Is there a legitimate reason for the non-C addition atop a C-syntax?Edit: Thanks for explaining!
I use vim keybinds and movement was too unpredictable to keep using as my main font. Now I'm back to a monospaced font.
I bet it would traumatize some of my VIM diehard teammates.
Parallel definitions lined up for readability.
#define AF_UNSPEC PF_UNSPEC
#define AF_LOCAL PF_LOCAL
#define AF_UNIX PF_UNIX
#define AF_FILE PF_FILE
#define AF_INET PF_INET
#define AF_AX25 PF_AX25
#define AF_IPX PF_IPX
#define AF_APPLETALK PF_APPLETALK
#define AF_NETROM PF_NETROM
#define AF_BRIDGE PF_BRIDGE
#define AF_ATMPVC PF_ATMPVC
#define AF_X25 PF_X25
Similarly in structure definitions where there are line comments:C preprocessor continuation backslashes.
/* From some MD5 code */
#define FF(a, b, c, d, x, s, ac) { \
(a) += F((b), (c), (d)) + (x) + convert(u32_t, ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G((b), (c), (d)) + (x) + convert(u32_t, ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
Alignment in parallel definitions. struct netent {
char *n_name; // Official name of network.
char **n_aliases; // Alias list.
int n_addrtype; // Net address type.
uint32_t n_net; // Network number.
};
No, tabs will not fix this issue, unless everyone agrees on exactly the same font, and the same tab stops, in the same editor. What looks vertically aligned in your editor looks staggered in someone else's.This kind of thing is not unheard of:m
struct netent {
char *n_name; // Official name of network.
char **n_aliases; // Alias list.
int n_addrtype; // Net address type.
uint32_t n_net; // Network number.
};
We have the identifiers of the declarators vertically lined up, but the pointer derivators hang to the left. Tabs will just not do this.Proportional font coders are in the lunatic fringe.
All else being equal, do not hire.
function(arg1,
arg2,
arg3);
Note that this, and everything in my above comment, can work just fine with tabs used for indentation, and set to the developers' preference: [tab]struct netent {
[tab] char *n_name; // Official name of network.
[tab] char **n_aliases; // Alias list.
[tab] int n_addrtype; // Net address type.
[tab] uint32_t n_net; // Network number.
[tab]};
[tab]{
[tab][tab]function(arg1,
[tab][tab] arg2,
[tab][tab] arg3);
Change tab size, alignment is fine. Change to proportional font, it all goes haywire.Tabs people: let's negotiate a quick peace treaty so we can gang up on the proportional font wackos.
- a sequence of characters and spaces
- a series of lines
- a fixed grid of characters and spaces
Instead, store code as a parse tree -- comments and all. Then we'd view and edit code using "WYSIWYG" editors solely. No more "cat" and "less", we'd need new tools. No more tty-like terminals, we'd need something more like a web browser.
It would cripple existing workflows and hinder compatibility, but the advantage is that "formatting" would be the viewer's preference. Forget about tab stops and fonts; think more like CSS. It's an extreme version of the tabs people's argument.
Word/Sheets documents come close, in a horrifying way. What I'm describing is more like Graphviz.
As in "Just tell the AI what code you want to write and the language and it will just magically do it for you" is like, sure, no problem, but we absolutely draw the line at "Use proportional fonts to make the code read nice on a page" because thats WAY TOO HARD
Or, if you are typesetting a book, you can do alignment in the typesetting software instead of adding spaces.
Also, they make creating diagrams and aligning things essentially impossible.
And before you get your pitchforks out, that's from a longtime (since 1998) vim user, whose other current weapon of choice is a neovim setup which acts as as its own multiplexer, thereby replacing gnu-screen (tmux for the rest of you).
In cuis, the morphic graphics system has been rebuilt to be entirely vector-graphics based. Entirely. Everything. The text rendering is beautiful. Each window can be scaled up or down with just a right click to bring up the 'halo', and then just drag the icon. The fonts are redrawn with vector graphics. There is zero quality loss, up or down.
Scaling up or down to cater for different dpi screens is no longer an issue.
The beauty of it is actually a little inspirational, as silly as that sounds. You feel like you have an expensive Japanese-nibbed fountain pen, and high quality parchment, and it forces you to write something.
(yes, the rendering quality remains, even if you also rotate the window as well).
The tricky part is there aren't many proportional fonts designed for coding (but more than there used to be). One early 90s version of ST defaulted to Helvetica, which was a nightmare to read on the then current lowres screens. Of the current choices, Input is probably the best place to start. Verdana is popular with some, and I've used Lucida a bunch, both sans and serifed. I have also had fun using not really suited display fonts like Zapfino or surprisingly readable drafting handwriting fonts like Tekton. I am currently fiddling with using various ports of the TeX fonts, particularly the CM Concrete as I find the big serifs easy to read. It is usually recommened to use a sans font for readability, but I think that advice is outdated on modern very hires displays with subpixel antialising.
[1] https://fontstruct.com/fontstructions/show/1693628/cream-10p...
The proportional fonts question recurrs periodically:
2005 https://ask.metafilter.com/16469/Proportional-programming-fo...
2010 https://slashdot.org/story/130020
https://www.quora.com/Are-monospace-or-proportional-fonts-be...
Amazon may have changed, but this is also not universal. Team preference, though they may be enforcing it in the older code base for the site (i.e. detail pages, etc.).
Facebook is the only one on your list I can confirm does, in part perhaps due to the predominant language (Hack).
Unicode block characters have constant width.
Unicode also contains fixed-width equivalents to ASCII letters: abc. Just add 0xFEE0 to the code point.
And 0x3000 is an ideographic space, with the same width.
+---------+
| | +--------------+
| NFS |--+ | |
| | | +-->| CacheFS |
+---------+ | +----------+ | | /dev/hda5 |
| | | | +--------------+
turns into +---------+
| | +--------------+
| NFS |--+ | |
| | | +-->| CacheFS |
+---------+ | +----------+ | | /dev/hda5 |
| | | | +--------------+
EDIT: which would have looked much better had HN not replaced full spaces with the narrow kind.For editing, I'd just use a conversion tool, and edit it in a fixed-width editor rather than directly in code. Yes, it's an extra tool, but I don't think it's that outlandish to edit pictures in a tool for editing pictures.
You would need to put a little more effort into using your caret to find issues when a compiler gives a row and column coordinate.
Max width restrictions (i.e. 80 columns) would become meaningless and arbitrary.
Your entire team would likely have to agree to the font choice for consistency.
OS font rendering differences would make life very interesting.
Foo(Bar(...), baz)
But they are not required for a happy life:
Foo( Bar(...), baz, )
It's not PEP8, but it works, and it does not depend on the font at all. 80 columns is bollocks in any case, but with this style, width is usually even reduced.
Alternatively, Elastic Tabstops solves this, but it's supported by approximately no one.
Why, when I was a lad, we had to punch paper tape by hand! And it wasn't any of this buy-it-by-the-roll stuff either. My da' would send me to the woods, and I'd have to chew a branch for a week to make my own paper!
Well, real programmers just tweak the bias voltages on the op-amps driving the transistor networks.
And not using the potentiometers that today's "real programmers" use. No sir, when I was a lad...
https://gnucobol.sourceforge.io/faq/index.html#do-you-have-a...