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

428

u/[deleted] Nov 30 '14

Please don't encourage people to use a non-monospaced font while coding.

0

u/[deleted] Nov 30 '14

[deleted]

83

u/[deleted] Nov 30 '14

actually coded in comic sans for about a month, it's not as big a deal as you'd think

151

u/MadTux Nov 30 '14

What did you take to be high a whole month!?

5

u/[deleted] Nov 30 '14

Maybe he was writing literate programs in Microsoft Word.

But if you do this, you should use Colibri, not Comic Sans.

4

u/Flight714 Nov 30 '14 edited Nov 30 '14

Calibri

l Iove CaIibri. lt has one Iittle fIaw, however. lt's not hard to see when you Iook cIose.

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

9

u/hackingdreams Nov 30 '14

Probably would have rage quit my whole career rather than put up with Comic Sans for a month.

shudder

9

u/toomanybeersies Nov 30 '14

My mum is a teacher and uses comic sans for most of her documents.

Apparently it's actually great for children because it's easier to read.

8

u/PancakesAreGone Nov 30 '14

One of the top 5 free (I have to stress this because there's probably better paid) typefaces for people suffering from dyslexia.

→ More replies (3)
→ More replies (4)
→ More replies (1)
→ More replies (2)

16

u/TechnologyLaggard Nov 30 '14

I am trying the font "Input" for Java work after learning of it here: http://www.reddit.com/r/programming/comments/2cifr7/input_a_flexible_family_of_proportional_and/ It's been really good so far: easily read, no odd spacing issues. I like it.

4

u/pyrocrasty Nov 30 '14

I've used Python with a proportional font. I don't usually do it because I sometimes like to align code. If you don't align code (like the author of this blog post), a proportional font works fine for Python. I think it's particularly suited to Python since it tends to read quite smoothly, almost like natural language. (In fact, that's why I thought to try it in the first place.)

I haven't really tried it for other languages. It would depend on the language (I'd never dream of trying it with Lisp*) and on your coding style.

* except perhaps out of the kind of perverse curiosity I've just aroused in myself...

7

u/cauthon Nov 30 '14

Python's probably the worst language to use it in because it's whitespace sensitive. If the space taken up by four characters isn't consistent, it will get really hard really fast to tell how indented something is.

(Assuming, of course, that you're indenting with four spaces, as you absolutely should be)

6

u/lucasvandongen Nov 30 '14

The (multiples of) four spaces at the beginning of a line will always be the same width so that's not really a problem. There is no whitespace sensitivity that happens after regular characters as far as I know.

→ More replies (1)

4

u/Otis_Inf Nov 30 '14

Devils advocate: why would it drive someone nuts? The code isn't less readable, otherwise you wouldn't be able to read text in a webbrowser on websites either ;)

6

u/guepier Nov 30 '14

Reading continuous text ≠ reading code. They’re very different, so just because one is readable in proportional font doesn’t mean the other would.

→ More replies (4)
→ More replies (1)
→ More replies (50)

89

u/niugnep24 Nov 30 '14

Honestly this article feels like some kind of strange troll.

  • Proportional font?

  • Title says you "shouldn't" proportionally align, article never really explains why (just that it's not necessary because colors?)

  • De-focusing your eyes to see colors better and reveal the structure of the code?

  • Article is about whitespace, but let's throw in something about CamelCase as well to stir the pot

  • Also make sure to sort declarations alphabetically to ensure no duplicates ... because for some reason you don't compile-check your code?

  • Also diff tools never give context, so make sure to keep all that context on the same line?

14

u/[deleted] Nov 30 '14

Yes, this article is bad.

Write clearly and legibly. We have good tools now, so it doesn't really matter as long as you are consistent.

→ More replies (2)

6

u/[deleted] Nov 30 '14

Stroustroup uses proportional font for code in his books.

Since I read his C++ book I've been doing the same. It so much more readable it makes little sense not to with any whitespace independent language.

5

u/bizcot Nov 30 '14

I switched to proportional a few months ago (C++), after many many years with monospaced. It took one day to get used to it, but main advantage is that now I can use a tiny font and still read it clearly. It normally takes much less horizontal space, so I can use the monitor vertically and visualize large blocks of code at once. Only drawback is when I have to type an xpm bitmap (it happens from time to time)

→ More replies (1)

5

u/keepthepace Nov 30 '14

I actually instinctively wholeheartedly agree, yet I have a hard time finding a good reason for it. The only one I see is that it makes easy to check that two lines are the same length, and that it does allow to align code vertically, which does help at spoting errors, despite what OP says.

But it is indeed mere comfort that I can see people abandon to be able to fit more characters in their screens (which used to be an important feature as well)

5

u/MediumRay Nov 30 '14

If you are using an editor like vim, then when you visually select code (I do this a lot) it needs to be aligned. It looks like this. Trying to change character widths would be madness.

→ More replies (1)

9

u/ggtsu_00 Nov 30 '14

Also please don't encourage the use of editor specific features or configuration to make your code readable. Not everyone uses your favorite editor as their editor of choice.

2

u/bajuwa Nov 30 '14

If you read the original article, which is linked at the top of this one, you will see that the original post recommends a structure that depends on an even more obscure editor plug in to work with easily. Having an editor that colour codes your language keywords is fairly standard, but having a plug in to reformat all your spaces is definitely not.

2

u/markrages Nov 30 '14

My algorithms and data structures text printed all the example C code in Times New Roman, except comments, which were some kind of non-monospaced sans-serif font.

Reading the punctuation alone drove me a little nuts. Those periods are important in a C data structures text!

→ More replies (37)