Skip to content
loading...

re: Tabs VS Space VIEW POST

FULL DISCUSSION
 

Tabs are the correct choice. I've covered this in my article, Lingering Spaces and the Problems of Overformatting

The key points are:

  • Tabs offer coders flexibility in how their code appears to them. Indentation can play a role in personal productivity. Tabs work well with proportionally spaced fonts.
  • Spaces encourage a lot bad code style where people line up symbols in random places on the line, which makes reading more difficult and can mess up version control.

Projects that use spaces inevitably make it harder for some coders to contribute to their project. And if they fall victim to the second point they make maintenance as a whole harder.

 

My big concern has always been what the Tabs Are Evil article calls "continuation lines". I think code like this (from that article) is ugly and hard to read.

int f(int x,
      int y) {
    return g(x,
             y);
}

Instead, why not structure it like this?

int f(
    int x,
    int y
) {
    return g(
        x,
        y
    );
}

Isn't that much easier to read? With indentation levels you know exactly what everything is.

 

Yes, exactly. If you wish to align things just start them all on the next line.

The space approach is entirely annoying, not because they're spaces, but because all functions have different alignments.

int go( int f,
        int y );

int somewhatLongerName( int f,
                        int y );

This sucks for readability, but also has a very real cost in maintenance and source control. If you wish to rename a function you have to modify the alignment of all the parameters again, this needless increases the patch size, thus wastes reviewer capacity.

code of conduct - report abuse