If I try to analyse your post as a formal, logical argument
(http://en.wikipedia.org/wiki/Logical_argument), I get the following:
Premise 1: The tab character can be expanded differently in different editors.
Premise 2: Formatting code uniformly is very important for program comprehension.
Conclusion: You should not use tab.
Right? As quite common in logical arguments, there are some missing
premises. The conclusion is in no way valid without also including
the following:
Premise 3: Using tab will make the code display un-uniformly.
As you discuss in your post, indentation can be handled in three
different ways,
a) indentation is X spaces
b) tab is X spaces
c) indentation is tab (expanded to whatever number of spaces you prefer), alignment is space
where premise 3 is true for a) and b) but false for c). Since premise
3 is not always true, this means also that the above conclusion is not
always true.
Discussing premise 1 and 2 is almost like kicking in open doors;
there is no controversy with those. The controversy occurs when someone
decides we shall have such and such indentation behaviour and that
conflicts with the preferred display preference of some of the developers.
Specifying this as premises gives:
Premise 4: People have different preferences on what the optimal width of indentation is.
Premise 5: Reading code with a different indentation width than your preferred makes the code harder to read.
and the the complete argument then becomes
Premise 1: The tab character can be expanded differently in different editors.
Premise 2: Formatting code uniformly is very important for program comprehension.
Premise 4: People have different preferences on what the optimal width of indentation is.
Premise 5: Reading code with a different indentation width than your preferred makes the code harder to read.
Decision 1: Mr/Mrs/Miss/Group X decides that indentation is X spaces.
or Decision 2: Mr/Mrs/Miss/Group X decides that tab is X spaces.
Result: The code becomes uniformly formatted, but is harder to read than optimal for some of the developers.
I put argument in quotes and use result instead of conclusion since the
decisions are based on taste/personal opinion and this is not a proper
logical argument any longer.
In some cases this might be a fair enough strategy; it might be impossible to
make everyone happy. This consistent with what you write in your paragraph:
Choose tabs, choose spaces, choose whatever layout conventions make sense
to you and your team. It doesn’t actually matter which coding styles
you pick. What does matter is that you, and everyone else on your team,
sticks with those conventions and uses them consistently.
However, in some way this also signals screw those developers that have
a different indentation width preferences, and as the observant reader
have noticed there is a third possible decision which will make everyone
happy with regards to reading the code (although possibly not for writing
(but this is irrelevant)).
Consider the relation between reading and writing code. Code is written
in the range of 1-10 times by one person (including some editing and
possibly pair programming). It can however possibly be read by tens (or
hundreds/thousands) of other people, several (maybe hundreds of) times.
This gives that having code that is easy to read is several orders
of magnitude more important than code that is easy to write. I.e. how
simple or complex some issue is to write is is irrelevant if it increases
readability.
The overall goal of any formatting discussion is to increase readability.
In fact that is the only important factor, to let the code be readable.
As written in the preface to the first edition of SICP: Thus, programs
must be written for people to read, and only incidentally for machines
to execute…
The best result is therefore to write the code so that everyone can
use their own preferred indentation display width without forcing this
upon others.
Premise 1: The tab character can be expanded differently in different editors.
Premise 2: Formatting code uniformly is very important for program comprehension.
Premise 4: People have different preferences on what the optimal width of indentation is.
Premise 5: Reading code with a different indentation width than your preferred makes the code harder to read.
Decision 3: Mr/Mrs/Miss/Group X decides that indentation is tab, alignment is space.
Premise 6: Decision 3 makes the source code tab expansion width agnostic
and allow everyone to display the source code with their own preferred
indentation width.
Result: The code becomes uniformly formatted and optimal for everyone to read.
Side argument:
Premise 7: Easy to read is several orders of magnitude more important than easy to write.
Premise 8: Some people will feel that decision 3 makes the code difficult to write.
Conclusion: Premise 8 significantly less important than readability improvements and can be ignored.
Premises 1, 2, 4, 5, 6, 7 and 8 are always true. Always. Please verify,
try to think of some situation where it could be false (and should you
think you found one by all means let me know). Then verify my conclusions,
it could be that I have made some mistakes? However the only way I can
see that you should be able to reach some other conclusions is if I have
Ignored some premises. What should that be?