News for hackers. Stuff that matters.
Re:Can I use a non-monospaced font in either Vim or gVim? by mseepgood on Saturday August 04, 2018 @03:02AM (#17685739)
I also program in non-monospaced fonts. There is no reason not to.
Re:Can I use a non-monospaced font in either Vim or gVim? by stinos on Saturday August 04, 2018 @03:13AM (#17685771)
No reason at all? Not saying you're wrong per se, but basically you're saying all the monospaced fonts out there used by default in a ton of code editors are there for no reason. Or at least not a good one. Can you elaborate?
Re:Can I use a non-monospaced font in either Vim or gVim? by Stratoscope on Saturday August 04, 2018 @03:37AM (#17685834)
Many programmers believe that it is impossible, or at least impractical, to code effectively in a monospaced font.

For most kinds of code, this is a mistaken belief.

You only need a monospaced font if you want to use column alignment. But it's really quite rare that column alignment is necessary. It can almost always be replaced with simple indentation.

Here's what I mean by column alignment:

  function foo(firstArgument,
               secondArgumentFunctionCall(itsArgument,
                                          itsOtherArgument),
               thirdArgument) {
      bar();
  }
Obviously, those arguments won't line up in a proportional font. But this kind of column alignment is a bad practice anyway. It leads to excessive line lengths, spurious VCS diffs, and is just generally fiddly.

The Rust/Servo coding guidelines formerly mandated column alignment like this. But after seeing the problems it caused in their codebase, they switched to a pure indentation style like the one I've used for many years.

The idea is simple. Stop making a distinction between statements and expressions, and instead format expressions just as you would format blocks of statements:

  function foo(
      firstArgument,
      secondArgumentFunctionCall(
          itsArgument,
          itsOtherArgument
      ),
      thirdArgument
  ) {
      bar();
  }
Once you start using this kind of format, it no longer matters whether you use a monospaced or proportional font. It doesn't even matter whether you use tabs or spaces! The notion of "tabs for indentation, spaces for alignment" goes away when you don't use alignment.

I think every programmer should try using proportional fonts for a while. Even if you decide you prefer monospaced after all, it's an educational experience to see that monospaced fonts are just not necessary for most programming, and that tabs work fine once you stop using alignment.

Re:Can I use a non-monospaced font in either Vim or gVim? by wruza on Saturday August 04, 2018 @04:18AM (#17685921)
VCS diffs are broken by design (in a sense of this subthread). Remove a single “if” around a block of code, reindent it, and now you got all lines changed. I wish VCS had special modes for source code that would compare lextoken-wise and show only what actually changed, leaving formatting to personal tastes. Yeah, no more style wars: tab/space, space/newline/none, trailing comma – all become irrelevant. Sigh.

Edit: a worst nightmare is a diff that removed “if” and also fixed a mistype in one of 20 reindented lines.

Re:Can I use a non-monospaced font in either Vim or gVim? by jobigoud on Saturday August 04, 2018 @10:00AM (#17686866)
You can do "ignore spaces" in your diff of choice to fix this shortcoming.
Re:Can I use a non-monospaced font in either Vim or gVim? by wruza on Saturday August 04, 2018 @10:32AM (#17686980)
Omg. Thanks for pointing that out, I can’t believe that I missed this option in svn manual for so many years. Such a shame...
Re:Can I use a non-monospaced font in either Vim or gVim? by jonhendry18 on Saturday August 04, 2018 @10:40PM (#17689410)
You only need a monospaced font if you want to use column alignment. But it's really quite rare that column alignment is necessary. It can almost always be replaced with simple indentation.

I suspect that most programmers have tried a proportional font for coding and found it unpleasant.

Re:Can I use a non-monospaced font in either Vim or gVim? by Stratoscope on Saturday August 11, 2018 @01:12PM (#17740537)
Do you really think so? My experience has been that most developers who see me using proportional fonts are surprised that it's even possible to work productively with them. I haven't run into anyone who said, "Oh yeah, I tried proportional fonts too but I didn't like them."
Re:Can I use a non-monospaced font in either Vim or gVim? by geezerjay on Saturday August 04, 2018 @03:55AM (#17685869)
> Many programmers believe that it is impossible, or at least impractical, to code effectively in a monospaced font.

Your post was the very first place I've ever saw that assertion in any shape or form. I never heard anyone come close to make that assertion ever.

Moreover, modern IDEs started featuring functionalities that rely on monospace fonts, such as selecting blocks of text by both rows and columns.

You should pass off your personal opinion as your own personal opinion instead of posting baseless assertions wrapped in an unbelievable appeal to popularity.

Re:Can I use a non-monospaced font in either Vim or gVim? by Stratoscope on Saturday August 11, 2018 @01:09PM (#17740519)
I'm sorry, I meant to get back to you a week ago.

As pmoriarty pointed out, that was indeed a typo, and a rather embarrassing one!

The funny thing was that as I was writing that sentence, I first wrote:

"The vast majority of programmers believe..."

And then I decided to tone down the language a bit. But my initial wording would have made the typo fairly obvious. So it goes. :-)

> functionalities that rely on monospace fonts, such as selecting blocks of text by both rows and columns.

I use that "column selection" mode with proportional fonts too. It works fine, even though the selected block has ragged right edges.

Re:Can I use a non-monospaced font in either Vim or gVim? by pmoriarty on Saturday August 04, 2018 @04:46AM (#17685983)

  > > Many programmers believe that it is impossible, or at least
  > > impractical, to code effectively in a monospaced font.
  >
  > Your post was the very first place I've ever saw that assertion in
  > any shape or form. I never heard anyone come close to make that
  > assertion ever.
That's almost certainly a typo, and the GP almost certainly meant to say "without a monospace font" or "in a proportional font".

In fact, 2 sentences later he/she says "You only need a monospaced font if you want to use column alignment." This is presumably meant to contradict the assertion in the first sentence.

Re:Can I use a non-monospaced font in either Vim or gVim? by geezerjay on Saturday August 04, 2018 @04:05AM (#17685895)
> but basically you're saying all the monospaced fonts out there used by default in a ton of code editors are there for no reason.

That assertion only makes sense if you assume that indentation or even indentation style have no relevance in software development, and thus there is no reason to consider those basic requirements in any activity related to coding.

Re:Can I use a non-monospaced font in either Vim or gVim? by metaphor on Saturday August 04, 2018 @03:46AM (#17685854)
Was curious what language(s) you regularly program in, and if you generally develop/maintain solo or as part of a team?

I don't agree with your disposition, but I don't think it's necessarily wrong either...perhaps subjectively driven based on your "norm" vs. what others have experienced, e.g. I ocassionally program in a niche language where the first 7 columns are strictly defined by BNF, uses relatively heavy ASCII art commenting by local coding convention, and will throw obscure errors if a character on any line exceeds the 80th.

Re:Can I use a non-monospaced font in either Vim or gVim? by ur-whale on Saturday August 04, 2018 @05:13AM (#17686061)
>There is no reason not to

If you've reached that conclusion, I suspect I would not enjoy reading your code very much.