Hacker News new | past | comments | ask | show | jobs | submit login

I've recently switched to coding in a proportional width font (right now I'm using Verdana) and I'm never going back. I've yet to be bothered by things not lining up perfectly like things can in fixed width fonts, and overall my code feels more readable and easy on the eyes. I recommend giving it a try.

What sort of code are you writing? What languages are you using?

While I'm not the parent, I can comment on this too.

I program in Python, C, C++ and Java. In all these languages I prefer a proportional font. However I had to stop, mainly because the editors I want to use (Sublime text 2 at the moment) don't support proportional fonts.

Programming in Python, where whitespace is syntactically significant, with a proportional font, seems to be volunteering for an unnecessary burden. Reasonable people may differ.

The only mitigating factor would be that the spaces at the left margin all (presumably) have the same width.

Another proportional font using python programmer here. All significant white space is in the left margin and all has the same width, so not a problem at all.

And those are the only spaces that are significant in Python. Indentation works fine in proportional fonts, just like it does in monospaced fonts. The only thing that doesn't work is columnar alignment after the indentation, and that wouldn't be significant in Python anyway.

Proportional fonts seem to work for me in ST2 (http://i.imgur.com/ZLZWP.png) I just put this into the config:

    "font_face": "Verdana"
Though I may be missing something.

You're not missing anything. I'm using Georgia in ST2 via the same font_face setting you're using. Works great!

No, you aren't. I tried something like that in the past and it didn't seem to work. No idea why now!

In fact, I'm pretty sure if you put an invalid font name in you get a default proportional font.

Lately I've been writing a lot of ruby on rails

Second Verdana. I use it on both Mac and Windows for all languages. It looks and reads better that any of the fixed fonts I've tried. In the first couple of days after I switched it felt a bit weird, but then that feeling went away. I suspect that was due to the fact that I was simply used to fixed fonts and not that there was anything wrong with proportional fonts.

I also use proportional fonts when programming, since reasonably looking proportional and antialiased fonts appeared on Windows and X.

Recent example: http://www.michielovertoom.com/pictures/kwrite-textanalyse.p...

I would consider trying proportional width fonts, but I work on a fairly large team that all touches a lot of the same code. Having bunch o comments not line up may not bother me, but it would annoy others on the team.

Wow! I've had so many programmers react with shock when I tell them I use proportional fonts, that sometimes I think I'm the only one. I'm glad to hear your comments and the others here.

I really enjoy reading text in proportional fonts much more than monospaced. That's true for program code as much as any other text.

Like you, it doesn't bother me to lose vertical alignment. The only vertical alignment that matters to me in code is the indentation, and that works fine in proportional fonts. (The one exception being that the popular two-space indents are really lousy in a proportional font. So I prefer tabs, or if spaces are a requirement, four-space indents.)

In fact, some time before I started using proportional fonts, I'd already changed my coding style to avoid vertical alignment other than the left margin. I used to write code something like this:

  function someFunction(aParam,                   // This is the the main thing
                        anotherParam,             // This is another thing
                        aParamWithALongerName) {  // Remind me what this is for
      firstStep();        // Here is a description
      secondStep();       // of these three statements
      thirdStepSortOf();  // that go together
That kind of code is the very reason for coding in monospaced fonts, but why? It is a pain to maintain and keep the spacing right, and in this (fairly realistic) example I find it extremely unhelpful to have all that whitespace separating "aParam" with its comment.

Instead, about ten years ago, I switched to a style more like this:

  function someFunction(
      aParam,  // This is the the main thing
      anotherParam,  // This is another thing
      aParamWithALongerName  // Remind me what this is for
  ) {
      // Here is a description of these three
      // statements that go together
Now it may not be as "pretty" to have those comments on the parameters not all lined up as they were before, but it's a heck of a lot easier to maintain, and to my eyes it's easier to read too. The comments about the parameters are not related to each other, they are related to the parameter that each one applies to. With this style I can read:

      aParam,  // This is the the main thing
as pretty much a single unit, where the excessive whitespace in my previous style made it hard to match up each parameter with its comment.

Having made this change, some time later I discovered that the version of Visual Studio I was using at the time supported proportional fonts, gave it a whirl, and like you, found I really liked it.

It is true that when I read other people's code who've used columnar alignment, the alignment doesn't work any more. But for the most part that just doesn't bother me. In the few cases where the alignment really makes a difference, I just switch to a monospaced font to read that file.

My favorite editor, Komodo IDE (or the free Komodo Edit), does a marvelous job of handling this. Like many editors, you can set up a customized theme of fonts and colors, but unlike any other editor I know of, each theme includes separate selections for a proportional font and a monospaced font. For some reason they don't provide a keyboard shortcut by default to switch between them, but I mapped Alt+O (on Windows) which is unused otherwise. I remember it by thinking "prOpOrtiOnal" and "mOnOspaced". :-) So I can switch between my favorite proportional and monospaced fonts easily, and it also remembers that setting for each file I've edited.

UltraEdit and UEStudio (Windows only) are not bad here either. They don't have an explicit way to select proportional vs. monospaced, but if you press Alt+C to go into column selection mode it switches to a monospaced font while in that mode. So that's a way to view a monospaced file. I wish more editors had this kind of flexibility.

> That kind of code is the very reason for coding in monospaced fonts, but why?

Aligning crap like that is one of the indicators I use to tell if someone is an inexperienced coder. After you write enough LOC, you eventually realize that lining things up is a waste of time. You're inevitably going to insert a line long enough to screw up your alignment, and now you'll have to bungle your diff.

I've tried proportional fonts and gave up as the programming languages tend to emphasize punctuation and put crucial meaning in it, but in proportional fonts the punctuation is a second-class citizen, and this is reasonable for natural languages, but is not good for programming languages.

Could you give an example or two of program code where a proportional font made the punctuation hard to read or stand out less? I'm curious because I've coded in proportional fonts for ten years and haven't found that to be the case myself - with a couple of possible exceptions.

One is names_with_underscores. In a monospaced font, the underscore is the same width as every other character. In a proportional font, the underscore is one of the widest of characters, and much wider than a space.

For example, in the font I'm coding in right now, an underscore is 13 pixels wide, a parenthesis is 8 pixels, and a space is only 5 pixels!

So what happens is that the underscore in a way gives more visual separation in an expression than spaces or other punctuation.

  var foo_bar = some_function(one_param, another_param);
To some degree, my eyes group that code this way:

var foo bar = some function(one param, another param);

My solution for this is simple: don't use names_with_underscores (except when language conventions require it, such as in Ruby), and do add spaces inside the parentheses:

  var fooBar = someFunction( oneParam, anotherParam );
Why do the spaces go inside the parentheses and not outside? Well, you need a space in there somewhere, and this just doesn't work for me:

  var fooBar = someFunction (oneParam, anotherParam);
Nor this (with no space at all):

  var fooBar = someFunction(oneParam, anotherParam);
To me, the space belongs at the same place where I might put a line break if I had a too-long line. I would never break lines like this:

  var fooBar = someFunction
or like this:

  var fooBar = someFunction(oneParam,
But I do break lines like this:

  var fooBar = someFunction(
This way the spacing goes in the same place regardless of whether it's a space or a linebreak.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact