Friday, June 14, 2013

Code indentation

4-column tab

Consistency > your feelings about code indentation.

Spaces will never be consistent and require a lot of text-processing on commits and reads, etc. with no added benefit.

Tabs are semantically correct: one tab indents, where some number of spaces could mean anything.

When you set your own column width preference for tabs, the view is altered. This is logically correct.

When your editor transforms four-space-indents into 2-space-indents, the content is altered. This is incorrect.

8-cols are obviously a joke, as one can only imagine the result of 8-col tabs, 32-col TTY and 4 levels of indentation.

2-cols are rather unclear considering how people like adding "one space" everywhere for "clarity".

3-cols is not a power of 2, so it doesn't work.

4-cols is the best answer, it's both clear, not too wide and a power of 2.

No comments:

Post a Comment