Re: Tab indentions on different platforms?



* Ben Finney (Sun, 30 Dec 2007 15:36:12 +1100)
Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
On Sat, 29 Dec 2007 15:29:25 +0000, Thorsten Kampe wrote:
I'd personally go for spaces because:

1. I don't like things I cannot see (control characters)

You can see spaces but not tabs? Your editor is pretty weird. In all
the editors I've every used, both spaces and tabs show up as empty
white space. (Or coloured space if I set the editor to use a
coloured background.)

Though Thorsten could have been clearer, "thing that is not a space
character but shows up as white space" is a near-enough approximation
of "thing I cannot see".

2. I never had problems with spaces but plenty with tabs

Periodically, I ask on this list what problems people have with
tabs. (I'm fully aware that mixing tabs and spaces is a Bad Thing.)
I've had little luck getting any answer except "Tabs are bad,
m'kay?".

Posit: White space is most often achieved by the user inserting a
sequence of space characters (U+0020).

Posit: Tab characters (U+0009) are, in a majority of environments,
rendered visually indistinguishable from a sequence of space
characters.

Corollary: most readers will, when seeing a stretch of white space on
a line, default to assuming that it represents a sequence of space
(U+0020) characters.

Corollary: So when a file containing either spaces or tabs is edited
in such an environment, the common way chosen by the user to get to
the same indentation level as existing lines is to prepend space
characters (using the spacebar or the Tab key or whatever facility the
editor provides) until the indentation lines up visually --
remembering the caveat that tabs and space-sequences are visually
indistinguishable in many environments.

Argument: The user will get an unexpected result when they do the
obvious thing (prepend space characters) in a tabs-only file. With
existing spaces-only files, the obvious way to get matching
indentation gives the expected result.

Conclusion: Thus, using tabs-only is inferior to using spaces-only for
indentation, because it violates the Principle of Least Astonishment
<URL:http://en.wikipedia.org/wiki/Principle_of_least_astonishment>.

Man, how did you know what I wanted to say (but failed to to express)
:-) ? Anyway: the consequence of your well done argumentation is that
someone editing Python code has to use a specialised editor to prevent
screwing up tab indented code - and that's bad.

Thorsten
.



Relevant Pages

  • Re: AfxGetApp() returns NULL
    ... VS to edit my code, it gets the identation right, following my indentation ... OPTION of whether to use spaces or tabs. ... me, and written using my editor, and given away free to others as a courtesy, I see no ... of my automation; worse still, the creators of VS think that there is no ...
    (microsoft.public.vc.mfc)
  • Re: reformat to tool/editor-compliant C style?
    ... convert 0x09 into whatever tabspace you've defined in your editor. ... anywhere that the code was written with tab-width 4. ... If someone writes this with tab-width = indentation = 4, ... no. *remove* all the tabs. ...
    (comp.lang.c)
  • Re: Coding Style: indenting with tabs vs. spaces
    ... While I respect you opinion about tabs, I find tab indentation the most ... Tabs become "logical indentation". ... isn't forced on anotherone's editor. ... any patches to the Linux kernel will have tabs used correctly. ...
    (Linux-Kernel)
  • Re: Using TABs vs. spaces II. (the Philosophy flamewar reloaded ;-))
    ... I read somewhere that good-style Ruby code is indented by 2 spaces. ... code if the indentation is only at 2 spaces. ... spaces or just tabs rather than switching between the two. ... You can alter tab length in your editor (for at least most editors, ...
    (comp.lang.ruby)
  • Re: A stylistic question.
    ... spaces of indentation is almost too little for my taste. ... something other than 8 means that anything containing tabs will look ... My preferred text editor, vi, has ... I don't "mess around with spaces"; ...
    (comp.lang.c)