News for hackers. Stuff that matters.
Re:Poll: Spaces or tabs? by hboon on Saturday February 02, 2013 @10:37AM (#5156187)
I've never understood what are real good reasons to use spaces if it isn't existing code or there's a style guide recommending it.

Nor why style guides recommend it.

Any one have a good reason?

Re:Poll: Spaces or tabs? by udp on Saturday February 02, 2013 @11:16AM (#5156327)
At least in C, I like to line things up sometimes:

    void function_with_lots_of_arguments (int arg_a,
                                          int arg_b,
                                          int arg_c);
If I was to use tabs and someone had a different tab width to me, they might end up with:

    void function_with_lots_of_arguments (int arg_a,
                                  int arg_b,
                                  int arg_c);
Re:Poll: Spaces or tabs? by dylan-m on Saturday February 02, 2013 @11:41AM (#5156425)
If you're trying to line things up with tabs, you're doing it wrong. Tabs are for indentation. Lining up columns is not indenting. (I'd also argue that trying to line stuff up like that is, nine times out of ten, doing it wrong: it inevitably leads to an if statement where the consequent is indented as much as the last line of conditions. If people are swearing by a style guide that says "always do this," and it's that, at least some of their code will end up being messy anyway).
Re:Poll: Spaces or tabs? by wolfgke on Saturday February 02, 2013 @11:21AM (#5156345)
In this case you use spaces for the parts that shall be lined up and tabs for the rest. Example:

  class Foo
  {
  \tint bar(int a,
  \t        int b);
  };
Re:Poll: Spaces or tabs? by cheradenine01 on Saturday February 02, 2013 @03:01PM (#5157111)
Yes, but you can't tell in your editor if you've got

\t int b);

or

\t\t int b);

Because they'll look the same to you, but not to anyone else without 4-space-tabs.

Re:Poll: Spaces or tabs? by pan69 on Saturday February 02, 2013 @03:23PM (#5157192)
That is correct. But you do know the indentation rule so you know that the int b only has 1 tab followed by spaces.
Re:Poll: Spaces or tabs? by wolfgke on Saturday February 02, 2013 @04:08PM (#5157328)
There are editors that have such a feature (for example called "show whitespace" or "show spaces and tabs").
Re:Poll: Spaces or tabs? by markokocic on Saturday February 02, 2013 @11:26AM (#5156367)
That's where one single rule helps: use only tabs for indentation and only spaces for alignment.
Re:Poll: Spaces or tabs? by sp332 on Saturday February 02, 2013 @11:28AM (#5156371)
I have vim configured with 4-space tabs, but less(1) on my box uses 8-space tabs. I could reconfigure everything on my box to use 4-space tabs but it's easier to just have vim save tabs as spaces.

If I type with 4-space tabs:

  username    admin
  port        22
  importance  3
And then print it with 8-space tabs:

  username        admin
  port                22
  importance  3
but if I had saved the tabs as spaces, it would still line up.
Re:Poll: Spaces or tabs? by implicit on Saturday February 02, 2013 @11:41AM (#5156427)
If your team has more than one person in it, you have two choices for indentation:

You can use spaces only, or you can have a random invisible mish-mash of tabs and spaces.

Nobody EVER gets it right, and if you're coding in something whitespace-sensitive, you're in for a wild ride.