News for hackers. Stuff that matters.
Re:Controversial Programming Opinions (2012) by recursive on Friday December 04, 2020 @02:37PM (#25306687)
Spaces for indentation work perfectly fine without fixed-width fonts. If you indent code with leading spaces, things will "line up" with any font.

By the way, what's the misunderstand with lining things up?

Re:Controversial Programming Opinions (2012) by gsoto on Friday December 04, 2020 @05:27PM (#25309129)
Spaces work well for indentation. You could argue here that typing one character (tab) is more efficient and maintainable than writing N (also semantically more powerful).

The real problem comes when people start aligning things on the middle of the line.

Re:Controversial Programming Opinions (2012) by u801e on Saturday December 05, 2020 @12:33AM (#25312067)
I think the solution is to rely on hanging indents rather than trying to align with the column of the previous opening parenthesis, bracket, etc.

So instead of this:

  def some_method(param1
                  param2):
      statement1
you do this:

  def some_method(
          param1,
          param2):
      statement1
Hanging indents work regardless of whether you use tabs or spaces for indentation.
Re:Controversial Programming Opinions (2012) by Supermancho on Saturday December 05, 2020 @02:02PM (#25317276)
My IDE types 4 spaces when I hit tab shrug
Re:Controversial Programming Opinions (2012) by rhn_mk1 on Friday December 04, 2020 @03:38PM (#25307558)
I'll demonstrate using periods due to the forum eating spaces. The parts after the dots line up in a monospaced font.

Fixed width:.good

Flexible:....not good

.............so not good

Re:Controversial Programming Opinions (2012) by recursive on Friday December 04, 2020 @04:41PM (#25308467)
This doesn't make any sense. Indented code does not have non-whitespace characters to its left.
Re:Controversial Programming Opinions (2012) by rhn_mk1 on Saturday December 05, 2020 @04:49AM (#25313174)
Sure it does.

  const ONE      = 1;
  const MILLION  = 1_000_000;
Even without non-whitespace it's a problem:

def foo(arg1,

........arg2,

........arg3)

Re:Controversial Programming Opinions (2012) by recursive on Saturday December 05, 2020 @10:39AM (#25315311)
Your first example isn't what I'd call indentation. "Alignment" maybe. I don't think anyone would expect that to work in a proportional font.

For the second one, I'd write it this way.

def foo(

....arg1,

....arg2,

....arg3)

I prefer that even in a fixed width font.

Re:Controversial Programming Opinions (2012) by rhn_mk1 on Saturday December 05, 2020 @12:41PM (#25316461)
This still matches the parent's picture

> If you use spaces to indent code, or in any way rely on a fixed width font to "line things up", you have a fundamental misunderstanding.

As long as the limitations of lining things up "exactly" are avoided, spaces shouldn't be any different than whatever way comes from true understanding.

Re:Controversial Programming Opinions (2012) by recursive on Saturday December 05, 2020 @05:56PM (#25319242)
I do use spaces to indent code. And I still have no idea what my fundamental misunderstanding is supposed to be.
Re:Controversial Programming Opinions (2012) by rhn_mk1 on Sunday December 06, 2020 @11:59AM (#25324730)
My take on it is that (most) code isn't a picture, so drawing with it (alignment especially) is missing the point that code is a form of text instructions.

If anything, the editor should "render" the text in a form that is pleasant to the eye, divorcing the meaning from the presentation.

Lining up things too much is a "works for me" way of baking presentation into the data, where the writer assumes that because it looks good o their setup, it will look well for the reader too.

Similarities can be seen to building web pages on tables, sending around Word documents, or hard-wrapping emails.