Stories
Slash Boxes
Comments

SoylentNews is people

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 5, Insightful) by Anonymous Coward on Thursday March 24 2022, @12:48AM (3 children)

    by Anonymous Coward on Thursday March 24 2022, @12:48AM (#1231567)

    What is the argument for spaces? What does it actually bring? The ability to force others to read the code with your preferred indentation? If that is your motivation, you're kind of a control freak.

    I am firmly in the camp of tabs instead of spaces for indentation prior to the first printable character of a line. But sometimes people try to line up things after the first printable character, for instance:

    foo("Alice",    1);
    foo("Bob",      2);
    foo("Charlie",  3);
    foo("David",    4);
    foo("Elephant", 5);

    For something like this, tabs are terrible, because many editors don't treat tabs as a fixed width but rather a variable width up to the next "tab stop". With a tab width of 8, the above example lines up with exactly one tab after each comma. But with a tab width of 4, the indentation after Bob gets messed up because the content before the tab is short enough that it doesn't poke into the next tab stop, something like this (although here I am using spaces to force others to see the same indentation as the example I am trying to communicate):

    foo("Alice",    1);
    foo("Bob",  2);
    foo("Charlie",  3);
    foo("David",    4);
    foo("Elephant", 5);

    Inserting a second tab for "Bob" lines things up with a tab width of 4, but then it's messed up with a tab width of 8. Though my preferred solution to the above problem is, don't try to line things up like that. But if there's a need to do so, spaces are preferred.

    I seem to recall there was a text editor that tried to treat tab characters as table column separators instead of spacing out to the next tab stop, and I thought it seemed like a good idea to avoid issues like the above, but I can't remember what the editor was called and it seems it never took off.

    Another negative of trying to line things up after the first printable character is it can introduce unnecessarily changed lines if someone adds whitespace to line up an existing line with a newly added line - at best this fouls up `git blame` output, at worst it can result in merge conflicts over differing whitespace.

    Also the above assumes fixed width fonts. I've thought about switching to coding with non-fixed width fonts for the sole purpose of preventing myself from ever considering lining things up after the initial indentation, though it probably wouldn't be worth it for many other reasons.

    Starting Score:    0  points
    Moderation   +5  
       Insightful=3, Interesting=1, Informative=1, Total=5
    Extra 'Insightful' Modifier   0  

    Total Score:   5  
  • (Score: 0, Disagree) by Anonymous Coward on Thursday March 24 2022, @07:57PM

    by Anonymous Coward on Thursday March 24 2022, @07:57PM (#1231832)

    "don't try to line up things like that".
    yeah. good luck with any math beyond primary school.

    tabs don't belong in source code, unless they're written as "\t" inside a string.

    the "tab" key is useful because you can switch between different text boxes, or document elements in general.

    but please don't try to translate it to any kind of actual white space.
    white space is just that: SPACE.
    LaTeX provides ways to control text location that have nothing to do with tabs.
    I don't use wysiwyg, but those things should provide markers that you can place where needed. If they want to use "Tab" in order to switch between different markers, fine.

  • (Score: 0) by Anonymous Coward on Friday March 25 2022, @08:53AM

    by Anonymous Coward on Friday March 25 2022, @08:53AM (#1231989)

    I'm firmly in the first camp, because source code and config files should be priority human readable, especially when you have a lot of lines. I get a severe case of the murder impulse twitches when I see someone's mount list not line up properly.

    Speaking of human readable, anyone got any ideas on how to make nano etc, have alternate lines with different shades, bit like those old types of printer paper? And I'm not just talking about the current line, but all lines alternating between, say, black background and a greyish background, just to create a contrast between lines.

  • (Score: 1) by pTamok on Tuesday March 29 2022, @11:10AM

    by pTamok (3042) on Tuesday March 29 2022, @11:10AM (#1233190)

    As well as that problem, when you get more than 9 elements.

    Do you choose (a)

    foo("Alice",     1);
    foo("Bob",  2);
    foo("Charlie",   3);
    foo("David",     4);
    foo("Elephant",  5);
    ...
    foo("Jackana",  10);

    or (b)

    foo("Alice",     1);
    foo("Bob",  2);
    foo("Charlie",   3);
    foo("David",     4);
    foo("Elephant",  5);
    ...
    foo("Jackana",   10);

    And what does your text editor choose?