5 ms·
You should see how two-space indents look in a proportional font! It's a sorry sight. That's the real shame of two-space indents. They basically require that a
by Stratoscope 13y ago
You should see how two-space indents look in a proportional font! It's a sorry sight.
That's the real shame of two-space indents. They basically require that all developers use monospaced fonts in their editors.
One of my most core principles for coding style is that the code should be equally readable in a proportional font or a monospaced font.
Why is that a core principle for me? Because I like proportional fonts. I don't use less-readable monospaced fonts when I write; I don't know why I should have to use them when I code.
You can't achieve this with two-space indents. When you view the code in a proportional font, it looks like one-space indentation.
For me, a proportional font is so much more readable, and lets me see so much more code at once, that I'm bummed that so many popular coding styles use conventions that only work monospaced.
To their credit, this coding standard actively discourages "column alignment". Abandoning column alignment is a wonderful thing: it gets you most of the way there toward having code that's perfectly readable in a proportional font.
It's unfortunate that they throw this benefit away by mandating two-space indents.
- seanmcdirmid 13y agoI use 2 space indent with Segoe UI and am pretty happy.
- vinkelhake 13y ago> Why is that a core principle for me? Because I like proportional fonts. I don't use less-readable monospaced fonts when I write; I don't know why I should have to use them when I code. I had a phase like that about 15 years ago. In the end I just felt that it wasn't worth it. Whenever I looked at other peoples code through the lens of a proportional font, it would look awkward. Any attempt on the authors part of lining things up would just make things worse. It turns out that proportional fonts are designed for text, not code.
- Stratoscope 13y agoThat 15-year-ago mark is interesting to me, because that was just about the time when I switched to proportional fonts. I recognize that I'm in a tiny minority: the vast majority of developers code in monospaced fonts. That's one reason why I value an editor that makes it easy to switch between a proportional font and monospaced, so I can code in the font I like or switch to a monospaced font when necessary. One of the few that does this well is Komodo, where each "theme" includes both proportional and monospaced fonts, and you can easily switch between them. (I just wish IntelliJ IDEA did this!) It's also why I wouldn't presume to use a coding standard that worked only in a proportional font but looked bad in monospaced. But to my eyes, a coding standard that works equally well in proportional and monospaced fonts is superior to one that works only in monospaced. I must respectfully disagree that "It turns out that proportional fonts are designed for text, not code." All of the code I've written in the last 10-15 years is just as readable in a proportional font or monospaced. It really makes no difference at all which kind of font you read the code in, if the coding standard was designed to support both.
- vinkelhake 13y agoI'll have to respectfully disagree as well :-) Fonts designed for programming typically take extra care of making sure that certain groups of glyphs look different: "O0" and "1lI" for example. Now I'm curious: what proportional fonts do you use for coding?
- Stratoscope 13y agoSorry for the slow reply. In case you read this later, my favorite coding font is actually Georgia. It's not perfect; Georgia's lowercase o looks a lot like 0. But in practice that has never been a problem for me. And unlike many proportional fonts which have monospaced numbers, even the numbers are proportional in Georgia. But I just like the way it looks and the readability it has - for my eyes.
- judk 13y agoWhat are you doing that ASCII art is a major factor in code readability?
- vinkelhake 13y agoNever said it was. I spend a lot of time reading code. I read other peoples code every day. To a very large extent, that code is going to use various layout tricks that are based on a monospaced font. Someone might line comments up like this: // 1. Blah blah, blah // blah and more blah. // 2. Second piece of blah. Arguments to a function might be lined up: void func(int arg1, int arg2... Someone might describe some detail of a network protocol with a diagram (as often seen in RFCs). A large comment block might be adjusted to fill out to a certain column width. I'm probably forgetting a ton of other layout tricks that people use. Almost all of them rely on a monospace font. Looking at code that wasn't specifically written for proportional fonts is death by a thousand cuts. The readability suffers greatly.
- userbinator 13y agoThis reminds me of some people who try to do ASCII art in a proportional font in a plaintext email, which then looks completely munged on everyone who uses monospace fonts or a different proportional font. IMHO plain text files should always be read/written in a monospace font, as otherwise you limit the expression of the medium unnecessarily since ASCII art becomes no longer "portable".
- judk 13y agoIf your blocks are so long and nested that you are worried about losing track of indent level, your blocks are too long and nested.
- Stratoscope 13y agoI actually write very short functions and blocks of code with very little nesting. So that isn't the problem. The problem for me is simply that a two-space indent looks like one space in a proportional font, and that makes it pretty hard to follow even one or two levels of indentation. (And apologies for not replying sooner!)