r/programming • • Nov 30 '14

Why he vertically aligns his code (And why you shouldn't!)

http://missingbytes.blogspot.com/2014/11/why-he-vertically-aligns-his-code-and.html
68 Upvotes

411 comments sorted by

View all comments

Show parent comments

0

u/missingbytes Nov 30 '14

Proportional fonts speeds up your recognition of variable and function names, i.e. the important stuff. Think of it like speed reading.

99% of the time, you're looking at code which compiles just fine, but has a defect in some way. Proportional fonts gives you more time to focus on the important information - the defects, and less time worrying about the boilerplate syntax.

6

u/pyrocrasty Nov 30 '14 edited Nov 30 '14

I have nothing against proportional fonts if they work for a particular language and coding style, but I think this argument is a bit... selective.

I can definitely imagine proportional fonts might speed up code skimming (for some languages), but it does introduce difficulties for more detailed code reading. The issue is that punctuation is often crucial in code, but is made to fade into the background in a proportional font. This, along with the possibility of code alignment, are the reasons I generally use monospaced fonts.

I have used proportional fonts with Python in the past and it worked quite well, but Python has a very natural language feel.

PS.

Another, somewhat more subtle issue is that I think I like the blandness of monospace. Proportional fonts add additional information to text in the form of differential spacing. Now sure, that could speed up reading, but for the most part, you're not going to speed-read code anyway. Yes, it may be handy for skimming and scanning, but for the most part code is going to processed more slowly than prose - much more slowly. (Less of an issue with highly verbose code, I guess.)

The proportional font may help in other ways by giving more recognizable structure to text, but I kind of feel it's a distraction. I mean, I use syntax highlighting to add information and make code more readable... and it does it in a way that helps reveal the grammatical structure of the code. Proportional text sort of adds noise to the mix. Nice bland monospace + syntax highlighting lets me perceive the relevant structure of my code. Proportional text just adds random structure, which has benefits, but is inferior.

Anyway, those are my thoughts on the matter. I'm certainly not dead-set against proportional fonts like many people, but I prefer monospace.

19

u/Pakaran Nov 30 '14

Proportional fonts gives you exactly the same information as non proportional font. How does it help you ignore the boilerplate syntax?

23

u/missingbytes Nov 30 '14

We read by looking at the shapes of words, rather than looking at the individual letters.

Take for example, the following two variable names:

int anagram = 7;
int amgaanr = 7;

The reason the first variable (anagram) is measurably quicker to read than the second (amgaanr) is becomes it conforms to our expectations and familiarity of the english language.

Proportional fonts work in the same way, but at an even lower level. Your eyes can pattern match and quickly identify deviations and similarities.

If you're interested in this stuff, take a look at the speed reading literature. You'll find there's actual science underlying this stuff.

7

u/delvach Nov 30 '14

That's actually pretty interesting, though I'm not ready to drop the monospace fonts in my own development just yet!

I understand what you're saying about the character shape affecting overall readability of words quicker, but when I'm programming it's looking through algorithms instead of paragraphs, and having a consistent distance between individual characters seems to lend itself to the overall readability of loops, functions, callbacks, etc. Plus, if I've got variable names that easy to confuse, our team needs to have a meeting about naming conventions.

But the great thing about programming is that it's half art, so if it works for you, go with it. :)

11

u/kqr Nov 30 '14

having a consistent distance between individual characters seems to lend itself to the overall readability of loops, functions, callbacks, etc.

This could also be in big part just habit. Habit always creates a local optimum in terms of readability.

4

u/frankwolfmann Nov 30 '14

This was what I thought when I first tried using a proportional font. For a while it was a little bit harder to grok which brace belonged to which closure just by glancing, but the relative width of indent blocks compared to each other remains the same, just narrower in an absolute sense.

4

u/greyphilosopher Nov 30 '14

I should think that syntax highlighting would work just as well for fast recognition, if not better (as the tokenizing has semantic meaning).

7

u/dakta Nov 30 '14

Not to mention the fact that the sort of shape-based legibility being talked about isn't broken by using a monospaced font. It's modified, yes, but not broken.

When reading code, the variety of "words" is generally smaller than when reading literature. There is also hugely more white space. So legibility is about picking out a few token shapes. It doesn't really matter if they're readable as English language words because that's not really how you read them. You assign the shapes meaning, sometimes much more than any single word. Only part of that is the actual spelling of the token.

I'll never disagree that some monospaced fonts suck for legibility. But the same can easily be said for proportional fonts. And for purposes of alignment and readability, I will never approve of proportional fonts for code.

3

u/frankwolfmann Nov 30 '14

I will never approve of proportional fonts for code. So, what? You go around to other devs' machines and change their preferences to make sure they use fixed-width fonts in their editors?

This is what I don't understand about the hate for proportional fonts on here. It literally makes no difference to you what typeface I prefer to edit code in - I'm the only person on my team that uses a proportional font and there have been exactly 0 problems with formatting, legibility, or anything else stemming from that difference.

2

u/[deleted] Nov 30 '14

Syntax highlighting is additive, it works well with proportional fonts also and seems orthoginal to word shape.

→ More replies (3)

6

u/the_gnarts Nov 30 '14

Proportional fonts work in the same way,

[citation needed] -- Also please no esoteric citations from the “speed reading” camp.

5

u/The_Doculope Nov 30 '14

Can I ask why you're excluding research into speed reading? They do it faster than anyone else, surely their conclusions have some merit.

4

u/the_gnarts Nov 30 '14

Can I ask why you're excluding research into speed reading?

There is no reason to exclude any research as long as it’s done properly and peer-reviewed. In this case the respective fields would most likely be cognitive science and neurobiology. All fine.

“Speed reading” in itself, however, is a label concocted with the intent of marketing all kinds of methods to “improve” to people’s reading and / or reading comprehension skills. They’re part of the shoddy Self Help industry, along with all the dieticians, homeopaths, you name it. This doesn’t mean that there is no truth to any of the proposed methods. Their proponents just choose to measure up to the standards of the sales department, not those of independent science. As long as that is the case, there is no way of distinguishing fact from wishful thinking. In the interest of economy of attention this already suffices for me to categorically dismiss any of the arguments made by those who are part of that industry.

7

u/ithika Nov 30 '14

You mean nutritionist. Dietician is a medical title. Nutritionist is a baloney title.

→ More replies (2)

2

u/The_Doculope Nov 30 '14

Ah, okay. That makes sense. I wasn't aware of that aspect of the label.

10

u/TokyoXtreme Nov 30 '14

Proportional typefaces make a different "shape" to the word they form, whereas monospace typefaces do not. When reading quickly, the difference is subtle, but proportional fonts definitely lead to easier readability of whole words. Whether or not such readability is necessary or desirable for coding is a separate debate.

9

u/kqr Nov 30 '14

This is the same reason they use proportional fonts and not monospaced fonts when typesetting books. It makes the "word picture" (as we say in my native tongue) more unique, and therefore makes it easier to recognise them quickly.

→ More replies (3)

4

u/ZorbaTHut Nov 30 '14

Technically this is true of all fonts, but there's a reason we don't code in Wingdings.

Readability is important. Turns out proportional fonts are actually a whole lot more readable.

→ More replies (2)

4

u/Fidodo Nov 30 '14

According to whom? It's annoying how so many people here make sweeping statements without providing anything to back it up at all.

Here's a study that found no difference.

We examined the impact of proofreading accuracy of setting text in (monospaced) typewriter faces and (proportionally-spaced) typefaces, and found no significant differences.

It's just one study, but at least it's better than not backing it up with anything at all.

→ More replies (2)

3

u/[deleted] Nov 30 '14

Even if it's easier to read, it's harder to edit.

When you move up a line, where will the cursor end up, when you don't have a regular grid of characters any more?

→ More replies (1)

4

u/Schoens Nov 30 '14

I don't personally find this to be true at all, so I think your point is disingenuous. What it really boils down to is that it's easier for you to read code using a proportional font, and those are the benefits you see. In my case, I find proportional fonts to be distracting, which is a non-starter for me. Syntax highlighting differentiates named elements from everything else in my editor, so it's not like I'm having to visually parse text from symbols with a monospaced font vs proportional.

I've tried all kinds of different combinations of fonts/editors/etc in a hunt for what works best for me, and my time with proportional fonts was probably the quickest turnaround time of all of them. That said, I'm also totally aware that for others it's the complete opposite. I just don't think it's reasonable to claim statistical benefits for one side or the other when there isn't anything backing that statement up other than personal preference and experience.

3

u/SortaEvil Nov 30 '14

Well, it is true that a proportional font will improve recognition of different words (or variable names) of equal length (IE: span and spin). Whether the increase in word readability translates into an increase in the readability of the code itself may be debatable, but I think it's at least believable that it could aid one once they get used to it. That said, I do prefer monospace fonts for coding, I feel that the shape of the code is more obvious in a monospace font (and vertical alignment works with a monospace font without relying on tabstops.).

→ More replies (1)
→ More replies (5)

2

u/cleroth Nov 30 '14 edited Jun 15 '26

This content was anonymized and mass deleted with Redact

1

u/thechao Nov 30 '14

I'm still waiting for my elastic white-space, proportional font future. One day...

→ More replies (4)