Tabs versus Spaces in Source Code

Discussion in 'Perl Misc' started by Xah Lee, May 15, 2006.

  1. Xah Lee

    Xah Lee Guest

    Tabs versus Spaces in Source Code

    Xah Lee, 2006-05-13

    In coding a computer program, there's often the choices of tabs or
    spaces for code indentation. There is a large amount of confusion about
    which is better. It has become what's known as “religious war†—
    a heated fight over trivia. In this essay, i like to explain what is
    the situation behind it, and which is proper.

    Simply put, tabs is proper, and spaces are improper. Why? This may seem
    ridiculously simple given the de facto ball of confusion: the semantics
    of tabs is what indenting is about, while, using spaces to align code
    is a hack.

    Now, tech geekers may object this simple conclusion because they itch
    to drivel about different editors and so on. The alleged problem
    created by tabs as seen by the industry coders are caused by two
    things: (1) tech geeker's sloppiness and lack of critical thinking
    which lead them to not understanding the semantic purposes of tab and
    space characters. (2) Due to the first reason, they have created and
    propagated a massive none-understanding and mis-use, to the degree that
    many tools (e.g. vi) does not deal with tabs well and using spaces to
    align code has become widely practiced, so that in the end spaces seem
    to be actually better by popularity and seeming simplicity.

    In short, this is a phenomenon of misunderstanding begetting a snowball
    of misunderstanding, such that it created a cultural milieu to embrace
    this malpractice and kick what is true or proper. Situations like this
    happens a lot in unix. For one non-unix example, is the file name's
    suffix known as “extensionâ€, where the code of file's type became
    part of the file name. (e.g. “.txtâ€, “.htmlâ€, “.jpgâ€).
    Another well-known example is HTML practices in the industry, where
    badly designed tags from corporation's competitive greed, and stupid
    coding and misunderstanding by coders and their tools are so
    wide-spread such that they force the correct way to the side by the
    eventual standardization caused by sheer quantity of inproper but set
    practice.

    Now, tech geekers may still object, that using tabs requires the
    editors to set their positions, and plain files don't carry that
    information. This is a good question, and the solution is to advance
    the sciences such that your source code in some way embed such
    information. This would be progress. However, this is never thought of
    because the “unix philosophies†already conditioned people to hack
    and be shallow. In this case, many will simply use the character
    intended to separate words for the purpose of indentation or alignment,
    and spread the practice with militant drivels.

    Now, given the already messed up situation of the tabs vs spaces by the
    unixers and unix brain-washing of the coders in the industry... Which
    should we use today? I do not have a good proposition, other than just
    use whichever that works for you but put more critical thinking into
    things to prevent mishaps like this.

    Tabs vs Spaces can be thought of as parameters vs hard-coded values, or
    HTML vs ascii format, or XML/CSS vs HTML 4, or structural vs visual, or
    semantic vs format. In these, it is always easy to convert from the
    former to the latter, but near impossible from the latter to the
    former. And, that is because the former encodes information that is
    lost in the latter. If we look at the issue of tabs vs spaces, indeed,
    it is easy to convert tabs to spaces in a source code, but more
    difficult to convert from spaces to tabs. Because, tabs as indentation
    actually contains the semantic information about indentation. With
    spaces, this critical information is lost in space.

    This issue is intimately related to another issue in source code:
    soft-wrapped lines versus physical, hard-wrapped lines by EOL (end of
    line character). This issue has far more consequences than tabs vs
    spaces, and the unixer's unthinking has made far-reaching damages in
    the computing industry. Due to unix's EOL ways of thinking, it has
    created languages based on EOL (just about ALL languages except the
    Lisp family and Mathematica) and tools based on EOL (cvs, diff, grep,
    and basically every tool in unix), thoughts based on EOL (software
    value estimation by counting EOL, hard-coded email quoting system by
    “>†prefix, and silent line-truncations in many unix tools), such
    that any progress or development towards a “algorithmic code unitâ€
    concept or language syntaxes are suppressed. I have not written a full
    account on this issue, but i've touched it in this essay: “The Harm
    of hard-wrapping Linesâ€, at
    http://xahlee.org/UnixResource_dir/writ/hard-wrap.html
    ----
    This post is archived at:
    http://xahlee.org/UnixResource_dir/writ/tabs_vs_spaces.html

    Xah

    ∑ http://xahlee.org/
    Xah Lee, May 15, 2006
    #1
    1. Advertising

  2. Xah Lee

    Eli Gottlieb Guest

    Actually, spaces are better for indenting code. The exact amount of
    space taken up by one space character will always (or at least tend to
    be) the same, while every combination of keyboard driver, operating
    system, text editor, content/file format, and character encoding all
    change precisely what the tab key does.

    There's no use in typing "tab" for indentation when my text editor will
    simply convert it to three spaces, or worse, autoindent and mix tabs
    with spaces so that I have no idea how many actual whitespace characters
    of what kinds are really taking up all that whitespace. I admit it
    doesn't usually matter, but then you go back to try and make your code
    prettier and find yourself asking "WTF?"

    Undoubtedly adding the second spark to the holy war,
    Eli

    --
    The science of economics is the cleverest proof of free will yet
    constructed.
    Eli Gottlieb, May 15, 2006
    #2
    1. Advertising

  3. Eli Gottlieb wrote:

    > Actually, spaces are better for indenting code. The exact amount of
    > space taken up by one space character will always (or at least tend to
    > be) the same, while every combination of keyboard driver, operating
    > system, text editor, content/file format, and character encoding all
    > change precisely what the tab key does.


    What you see as tabs' weakness is their strength. They encode '1 level of
    indentation', not a fixed width. Of course tabs are rendered differently
    by different editors -- that's the point. If you like indentation to be 2
    or 3 or 7 chars wide, you can view your preference without forcing it on
    the rest of the world. It's a logical rather than a fixed encoding.


    > There's no use in typing "tab" for indentation when my text editor will
    > simply convert it to three spaces, or worse, autoindent and mix tabs
    > with spaces so that I have no idea how many actual whitespace characters
    > of what kinds are really taking up all that whitespace. I admit it
    > doesn't usually matter, but then you go back to try and make your code
    > prettier and find yourself asking "WTF?"


    Sounds like the problem is your editor, not tabs. But I wouldn't rule out
    PEBCAK either. ;)


    > Undoubtedly adding the second spark to the holy war,


    Undoubtedly. Let's keep it civil, shall we? And please limit the
    cross-posting to a minimum. (directed at the group, not you personally
    Eli).

    --
    Edward Elliott
    UC Berkeley School of Law (Boalt Hall)
    complangpython at eddeye dot net
    Edward Elliott, May 15, 2006
    #3
  4. Xah Lee

    jmcgill Guest

    If I work on your project, I follow the coding and style standards you
    specify.

    Likewise if you work on my project you follow the established standards.

    Fortunately for you, I am fairly liberal on such matters.

    I like to see 4 spaces for indentation. If you use tabs, that's what I
    will see, and you're very likely to have your code reformatted by the
    automated build process, when the standard copyright header is pasted
    and missing javadoc tags are generated as warnings.

    I like the open brace to start on the line of the control keyword. I
    can deal with the open brace being on the next line, at the same level
    of indentation as the control keyword. I don't quite understand the
    motivation behind the GNU style, where the brace itself is treated as a
    half-indent, but I can live with it on *your* project.

    Any whitespace or other style that isn't happy to be reformatted
    automatically is an error anyway.

    I'd be very laissez-faire about it except for the fact that code
    repositories are much easier to manage if everything is formatted before
    it goes in, or as a compromise, as a step at release tags.
    jmcgill, May 15, 2006
    #4
  5. Xah Lee

    mystilleef Guest

    I agree, use tabs.
    mystilleef, May 15, 2006
    #5
  6. Xah Lee

    Mumia W. Guest

    Xah Lee wrote:
    > Tabs versus Spaces in Source Code
    >
    > Xah Lee, 2006-05-13
    >
    > In coding a computer program, there's often the choices of tabs or
    > spaces for code indentation. There is a large amount of confusion about
    > which is better. It has become what's known as “religious war†—
    > a heated fight over trivia. In this essay, i like to explain what is
    > the situation behind it, and which is proper.
    >


    Thanks Xah. I value your posts. Keep posting. And since your posts
    usually cover broad areas of CS, keep crossposting. Don't go anywhere
    Xah :)


    > Simply put, tabs is proper, and spaces are improper. Why? This may seem
    > ridiculously simple given the de facto ball of confusion: the semantics
    > of tabs is what indenting is about, while, using spaces to align code
    > is a hack.
    >


    I wouldn't say that spaces are a hack, but tabs are superior.

    > Now, tech geekers may object this simple conclusion because they itch
    > to drivel about different editors and so on. The alleged problem
    > created by tabs as seen by the industry coders are caused by two
    > things: (1) tech geeker's sloppiness and lack of critical thinking
    > which lead them to not understanding the semantic purposes of tab and
    > space characters. (2) Due to the first reason, they have created and
    > propagated a massive none-understanding and mis-use, to the degree that
    > many tools (e.g. vi) does not deal with tabs well and using spaces to
    > align code has become widely practiced, so that in the end spaces seem
    > to be actually better by popularity and seeming simplicity.
    >


    Don't forget the laziness of programmers like me who don't put the
    tabbing information in the source file. Vim deals with tabs well IMO,
    but I almost never used to put the right auto-commands in the file to
    get it set up right for other users.

    > In short, this is a phenomenon of misunderstanding begetting a snowball
    > of misunderstanding, such that it created a cultural milieu to embrace
    > this malpractice and kick what is true or proper. Situations like this
    > happens a lot in unix. For one non-unix example, is the file name's
    > suffix known as “extensionâ€, where the code of file's type became
    > part of the file name. (e.g. “.txtâ€, “.htmlâ€, “.jpgâ€).
    > Another well-known example is HTML practices in the industry, where
    > badly designed tags from corporation's competitive greed, and stupid
    > coding and misunderstanding by coders and their tools are so
    > wide-spread such that they force the correct way to the side by the
    > eventual standardization caused by sheer quantity of inproper but set
    > practice.
    >
    > Now, tech geekers may still object, that using tabs requires the
    > editors to set their positions, and plain files don't carry that
    > information. This is a good question, and the solution is to advance
    > the sciences such that your source code in some way embed such
    > information.


    Vim does this. We just have to use it.

    > This would be progress. However, this is never thought of
    > because the “unix philosophies†already conditioned people to hack
    > and be shallow. In this case, many will simply use the character
    > intended to separate words for the purpose of indentation or alignment,
    > and spread the practice with militant drivels.
    >
    > Now, given the already messed up situation of the tabs vs spaces by the
    > unixers and unix brain-washing of the coders in the industry... Which
    > should we use today? I do not have a good proposition, other than just
    > use whichever that works for you but put more critical thinking into
    > things to prevent mishaps like this.
    >
    > Tabs vs Spaces can be thought of as parameters vs hard-coded values, or
    > HTML vs ascii format, or XML/CSS vs HTML 4, or structural vs visual, or
    > semantic vs format. In these, it is always easy to convert from the
    > former to the latter, but near impossible from the latter to the
    > former. And, that is because the former encodes information that is
    > lost in the latter.


    Nope. Conversion is relatively easy. I've written programs to do this
    myself, and everyone and his brother has also done this. Virtually every
    programmer's editor that I've ever used can do this, and a great, great
    many independent programs convert tabs to spaces. It's like saying,
    "it's near impossible to write a calculator program." :)

    I bet that someone has a Perl one-liner to do it.

    On any Debian system, try a "man expand" and see what you find. Also,
    emacs and vim do it. Perl has a Text::Tabs module. TCL's
    ::textutil::(un)?tabify routines do it. The birds do it, and the bees do
    it. Oh wait, that's something else :)

    > If we look at the issue of tabs vs spaces, indeed,
    > it is easy to convert tabs to spaces in a source code, but more
    > difficult to convert from spaces to tabs.


    Nope again. It's easy, you just keep track of the virtual character
    position as you decide whether to write a space or a tab. Computers do
    the "counting" thing fairly well.

    > Because, tabs as indentation
    > actually contains the semantic information about indentation. With
    > spaces, this critical information is lost in space.
    >
    > This issue is intimately related to another issue in source code:
    > soft-wrapped lines versus physical, hard-wrapped lines by EOL (end of
    > line character). This issue has far more consequences than tabs vs
    > spaces, and the unixer's unthinking has made far-reaching damages in
    > the computing industry. Due to unix's EOL ways of thinking, it has
    > created languages based on EOL (just about ALL languages except the
    > Lisp family and Mathematica) and tools based on EOL (cvs, diff, grep,
    > and basically every tool in unix), thoughts based on EOL (software
    > value estimation by counting EOL, hard-coded email quoting system by
    > “>†prefix, and silent line-truncations in many unix tools), such
    > that any progress or development towards a “algorithmic code unitâ€
    > concept or language syntaxes are suppressed. I have not written a full
    > account on this issue, but i've touched it in this essay: “The Harm
    > of hard-wrapping Linesâ€, at
    > http://xahlee.org/UnixResource_dir/writ/hard-wrap.html
    > ----
    > This post is archived at:
    > http://xahlee.org/UnixResource_dir/writ/tabs_vs_spaces.html
    >
    > Xah
    >
    > ∑ http://xahlee.org/
    >


    I've never thought of tabs-vs-spaces as a religious war. Anyway, the
    authority of the programming environment will determine which one is
    used. Have a good week Xah.
    Mumia W., May 15, 2006
    #6
  7. Xah Lee

    Big and Blue Guest

    Edward Elliott wrote:

    > What you see as tabs' weakness is their strength. They encode '1 level of
    > indentation', not a fixed width. Of course tabs are rendered differently
    > by different editors -- that's the point.


    Yes - it is the point. It is the point why you should never use them.
    The meaning of the tab is writer-dependent while the
    representation/interpretation of a tab is reader-dependent. What you think
    is lined up nicely will be mis-aligned for someone else.

    If you wish to allow your meaning to be changed by any and every reader
    then reconsider what you are writing.


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue, May 15, 2006
    #7
  8. Xah Lee

    Iain King Guest

    Oh God, I agree with Xah Lee. Someone take me out behind the chemical
    sheds...

    Iain


    Xah Lee wrote:
    > Tabs versus Spaces in Source Code
    >
    > Xah Lee, 2006-05-13
    >
    > In coding a computer program, there's often the choices of tabs or
    > spaces for code indentation. There is a large amount of confusion about
    > which is better. It has become what's known as “religious war†—
    > a heated fight over trivia. In this essay, i like to explain what is
    > the situation behind it, and which is proper.
    >
    > Simply put, tabs is proper, and spaces are improper. Why? This may seem
    > ridiculously simple given the de facto ball of confusion: the semantics
    > of tabs is what indenting is about, while, using spaces to align code
    > is a hack.
    >
    > Now, tech geekers may object this simple conclusion because they itch
    > to drivel about different editors and so on. The alleged problem
    > created by tabs as seen by the industry coders are caused by two
    > things: (1) tech geeker's sloppiness and lack of critical thinking
    > which lead them to not understanding the semantic purposes of tab and
    > space characters. (2) Due to the first reason, they have created and
    > propagated a massive none-understanding and mis-use, to the degree that
    > many tools (e.g. vi) does not deal with tabs well and using spaces to
    > align code has become widely practiced, so that in the end spaces seem
    > to be actually better by popularity and seeming simplicity.
    >
    > In short, this is a phenomenon of misunderstanding begetting a snowball
    > of misunderstanding, such that it created a cultural milieu to embrace
    > this malpractice and kick what is true or proper. Situations like this
    > happens a lot in unix. For one non-unix example, is the file name's
    > suffix known as “extensionâ€, where the code of file's type became
    > part of the file name. (e.g. “.txtâ€, “.htmlâ€, “.jpgâ€).
    > Another well-known example is HTML practices in the industry, where
    > badly designed tags from corporation's competitive greed, and stupid
    > coding and misunderstanding by coders and their tools are so
    > wide-spread such that they force the correct way to the side by the
    > eventual standardization caused by sheer quantity of inproper but set
    > practice.
    >
    > Now, tech geekers may still object, that using tabs requires the
    > editors to set their positions, and plain files don't carry that
    > information. This is a good question, and the solution is to advance
    > the sciences such that your source code in some way embed such
    > information. This would be progress. However, this is never thought of
    > because the “unix philosophies†already conditioned people to hack
    > and be shallow. In this case, many will simply use the character
    > intended to separate words for the purpose of indentation or alignment,
    > and spread the practice with militant drivels.
    >
    > Now, given the already messed up situation of the tabs vs spaces by the
    > unixers and unix brain-washing of the coders in the industry... Which
    > should we use today? I do not have a good proposition, other than just
    > use whichever that works for you but put more critical thinking into
    > things to prevent mishaps like this.
    >
    > Tabs vs Spaces can be thought of as parameters vs hard-coded values, or
    > HTML vs ascii format, or XML/CSS vs HTML 4, or structural vs visual, or
    > semantic vs format. In these, it is always easy to convert from the
    > former to the latter, but near impossible from the latter to the
    > former. And, that is because the former encodes information that is
    > lost in the latter. If we look at the issue of tabs vs spaces, indeed,
    > it is easy to convert tabs to spaces in a source code, but more
    > difficult to convert from spaces to tabs. Because, tabs as indentation
    > actually contains the semantic information about indentation. With
    > spaces, this critical information is lost in space.
    >
    > This issue is intimately related to another issue in source code:
    > soft-wrapped lines versus physical, hard-wrapped lines by EOL (end of
    > line character). This issue has far more consequences than tabs vs
    > spaces, and the unixer's unthinking has made far-reaching damages in
    > the computing industry. Due to unix's EOL ways of thinking, it has
    > created languages based on EOL (just about ALL languages except the
    > Lisp family and Mathematica) and tools based on EOL (cvs, diff, grep,
    > and basically every tool in unix), thoughts based on EOL (software
    > value estimation by counting EOL, hard-coded email quoting system by
    > “>†prefix, and silent line-truncations in many unix tools), such
    > that any progress or development towards a “algorithmic code unitâ€
    > concept or language syntaxes are suppressed. I have not written a full
    > account on this issue, but i've touched it in this essay: “The Harm
    > of hard-wrapping Linesâ€, at
    > http://xahlee.org/UnixResource_dir/writ/hard-wrap.html
    > ----
    > This post is archived at:
    > http://xahlee.org/UnixResource_dir/writ/tabs_vs_spaces.html
    >
    > Xah
    >
    > ∑ http://xahlee.org/
    Iain King, May 16, 2006
    #8
  9. Xah Lee

    numeromancer Guest

    numeromancer, May 16, 2006
    #9
  10. > Simply put, tabs is proper, and spaces are improper.
    > Why? This may seem
    > ridiculously simple given the de facto ball of confusion: the semantics
    > of tabs is what indenting is about, while, using spaces to align code
    > is a hack.


    The reality of programming practice trumps original intent of tab
    characters. The tab character and space character are pliable in that
    if their use changes their semantics change.

    > ... and the solution is to advance
    > the sciences such that your source code in some way
    > embed such information.


    If/when time comes where such info is embeded perhaps then tabs will be
    OK.

    ---------------------------------------------------------------

    I use spaces because of the many sources I've opened I have many times
    sighed on opening tabed ones and never done so opening spaced ones.

    I don't get mad, but sighing is a clear indicator of negativity.
    Anyway, the more code I write and read the less indentation matters to
    me. My brain can now parse akward source correctly far bettter than it
    did a few years ago.


    All the best,
    Opalinski

    http://www.geocities.com/opalpaweb/
    opalinski from opalpaweb, May 16, 2006
    #10
  11. " opalinski from opalpaweb" <> writes:

    >> Simply put, tabs is proper, and spaces are improper.
    >> Why? This may seem
    >> ridiculously simple given the de facto ball of confusion: the semantics
    >> of tabs is what indenting is about, while, using spaces to align code
    >> is a hack.

    >
    > The reality of programming practice trumps original intent of tab
    > characters. The tab character and space character are pliable in that
    > if their use changes their semantics change.
    >
    >> ... and the solution is to advance
    >> the sciences such that your source code in some way
    >> embed such information.

    >
    > If/when time comes where such info is embeded perhaps then tabs will be
    > OK.
    >
    > ---------------------------------------------------------------
    >
    > I use spaces because of the many sources I've opened I have many times
    > sighed on opening tabed ones and never done so opening spaced ones.
    >
    > I don't get mad, but sighing is a clear indicator of negativity.
    > Anyway, the more code I write and read the less indentation matters to
    > me. My brain can now parse akward source correctly far bettter than it
    > did a few years ago.


    And anyways, C-x h C-M-\ comes automatically after C-x C-f source RET
    Just add this to your ~/.emacs :

    (add-hook 'find-file-hook
    (lambda () (indent-region (point-min) (point-max)) (pop-mark)))



    --
    __Pascal Bourguignon__ http://www.informatimago.com/

    IMPORTANT NOTICE TO PURCHASERS: The entire physical universe,
    including this product, may one day collapse back into an
    infinitesimally small space. Should another universe subsequently
    re-emerge, the existence of this product in that universe cannot be
    guaranteed.
    Pascal Bourguignon, May 16, 2006
    #11
  12. Xah Lee

    Dale King Guest

    Iain King wrote:
    > Oh God, I agree with Xah Lee. Someone take me out behind the chemical
    > sheds...
    >
    > Xah Lee wrote:

    <more worthless nonsense>

    Please don't feed the troll!

    And for the record, spaces are 100% portable, tabs are not. That ends
    the argument for me.

    Worse than either tabs or spaces however is Sun's mixture of the two.
    --
    Dale King
    Dale King, May 16, 2006
    #12
  13. Xah Lee

    Kaz Kylheku Guest

    Xah Lee wrote:
    > Tabs vs Spaces can be thought of as parameters vs hard-coded values, or
    > HTML vs ascii format, or XML/CSS vs HTML 4, or structural vs visual, or
    > semantic vs format. In these, it is always easy to convert from the
    > former to the latter, but near impossible from the latter to the
    > former.


    Bahaha, looks like someone hasn't thought things through very well.

    Spaces, under a mono font, offer greater precision and expressivity in
    achieving specific alignment. That expressivity cannot be captured by
    tabs.

    The difficulty in converting spaces to tabs rests not in any bridgeable
    semantic gap, but in the lack of having any way whatsoever to express
    using tabs what the spaces are expressing.

    It's not /near/ impossible, it's /precisely/ impossible.

    For instance, tabs cannot express these alignments:

    /*
    * C block
    * comment
    * in a common style.
    */

    (lisp
    (nested list
    with symbols
    and things))

    (call to a function
    with many parameters)
    ;; how do you align "to" and "with" using tabs?
    ;; only if "to" lands on a tab stop; but dependence on specific tab
    stops
    ;; destroys the whole idea of tabs being parameters.

    To do these alignments structurally, you need something more expressive
    than spaces or tabs. But spaces do the job under a mono font, /and/
    they do it in a completely unobtrusive way.

    If you want to do nice typesetting of code, you have to add markup
    which has to be stripped away if you actually want to run the code.

    Spaces give you decent formatting without markup. Tabs do not. Tabs are
    only suitable for aligning the first non-whitespace character of a line
    to a stop. Only if that is the full extent of the formatting that you
    need to express in your code can you acheive the ideal of being able to
    change your tab parameter to change the indentation amount. If you need
    to align characters which aren't the first non-whitespace in a line,
    tabs are of no use whatsoever, and proportional fonts must be banished.
    Kaz Kylheku, May 16, 2006
    #13
  14. Xah Lee

    achates Guest

    Kaz Kylheku wrote:

    > If you want to do nice typesetting of code, you have to add markup
    > which has to be stripped away if you actually want to run the code.


    Typesetting code is not a helpful activity outside of the publishing
    industry. You might like the results of your typsetting; I happen not
    to. You probably wouldn't like mine. Does that mean we shouldn't work
    together? Only if you insist on forcing me to conform to your way of
    displaying code.

    You are correct in pointing out that tabs don't allow for 'alignment'
    of the sort you mention:
    (lisp
    (nested list
    with symbols
    and things))
    But then neither does Python. I happen to think that's a feature.

    (And of course you can do what you like inside a comment. That's
    because tabs are for indentation, and indentation is meanigless in that
    context. Spaces are exactly what you should use then. I may or may not
    like your layout, but it won't break anything when we merge our code.)
    achates, May 16, 2006
    #14
  15. Xah Lee

    achates Guest

    argh, sorry; missed the cross-post. Was replying from comp.lang.python..
    achates, May 16, 2006
    #15
  16. Mumia W. wrote:
    > Xah Lee wrote:
    > >
    > > In coding a computer program, there's often the choices of tabs or
    > > spaces for code indentation. There is a large amount of confusion about
    > > which is better. It has become what's known as "religious war" -
    > > a heated fight over trivia. In this essay, i like to explain what is
    > > the situation behind it, and which is proper.
    > >

    >
    > Thanks Xah. I value your posts. Keep posting. And since your posts
    > usually cover broad areas of CS, keep crossposting. Don't go anywhere
    > Xah :)


    <barf> I hope that is sarcasm. The public licking of troll's arses is
    rather unedifying.


    > > Simply put, tabs is proper, and spaces are improper. Why?


    I find it hard to pay much attention to someone who aspires to lecture
    the masses yet is unable to grasp rudimentary English language concepts
    such as singular and plural. I think Xah should start with the correct
    use of the plural form before he moves on to a study of tabs and
    spaces.


    > > This may seem ridiculously simple given the de facto ball of confusion:


    Yeah but what about the cube of confusion? How about other platonic
    solids of confusion?


    > > the semantics of tabs is what indenting is about,


    And I thought indenting was about the semantics of the *program* not
    the *tabs*. I do wonder whether Xah is able to express fully the
    meaning of the tabulation character through the indenting of his
    source code.


    > > Now, tech geekers may object this simple conclusion because they itch
    > > to drivel about different editors and so on.


    Xah is a prime example of a "tech geek" driveling about this sort of
    trivia.


    > > In short, this is a phenomenon of misunderstanding begetting a snowball
    > > of misunderstanding, such that it created a cultural milieu to embrace
    > > this malpractice and kick what is true or proper.


    A fine example of convoluted self parody.


    > > Situations like this happens a lot in unix.


    Ooh ooh lets have an example ...

    > > For one non-unix example, is the file name's suffix known as "extension",


    Err, not Unix.

    > > Another well-known example is HTML practices in the industry, where
    > > badly designed tags


    Err, still not Unix.

    <snip: Xah's recipe for world peace>
    > > This would be progress. However, this is never thought of
    > > because the "unix philosophies" already conditioned people to hack
    > > and be shallow. In this case, many will simply use the character
    > > intended to separate words for the purpose of indentation or alignment,


    The first typewriters had a space-bar but no tabulation key. Therefore
    we can see that the space character was invented for indentation and
    alignment as well as for separating words.

    >From it's name we can deduce that the tabulation key was intended

    primarily for laying out tables of information in typewritten
    documents. It wasn't named "the indentation key".


    > > and spread the practice with militant drivels.


    Unlike Xah?, who wouldn't post "militant drivel?"


    > > Which should we use today?
    > > I do not have a good proposition


    Few should be surprised at this.


    > > Because, tabs as indentation
    > > actually contains the semantic information about indentation.


    Xah asserts that an indentation of n * char(x) carries more meaning
    than an indentation of n * char(y)?


    Mumia - repent!
    foo bar baz qux, May 16, 2006
    #16
  17. Xah Lee

    Kaz Kylheku Guest

    achates wrote:
    > Kaz Kylheku wrote:
    >
    > > If you want to do nice typesetting of code, you have to add markup
    > > which has to be stripped away if you actually want to run the code.

    >
    > Typesetting code is not a helpful activity outside of the publishing
    > industry.


    Be that as it may, code writing involves an element of typesetting. If
    you are aligning characters, you are typesetting, however crudely.

    > You might like the results of your typsetting; I happen not
    > to. You probably wouldn't like mine. Does that mean we shouldn't work
    > together? Only if you insist on forcing me to conform to your way of
    > displaying code.


    Someone who insists that everyone should separate line indentation into
    tabs which achieve the block level, and spaces that achieve additional
    alignment, so that code could be displayed in more than one way based
    on the tab size without loss of alignment, is probably a "space cadet",
    who has a bizarre agenda unrelated to developing the product.

    There is close to zero value in maintaining such a scheme, and
    consequently, it's hard to justify with a business case.

    Yes, in the real world, you have to conform to someone's way of
    formatting and displaying code. That's how it is.

    You have to learn to read, write and even like more than one style.

    > You are correct in pointing out that tabs don't allow for 'alignment'
    > of the sort you mention:


    That alignment has a name: hanging indentation.

    All forms of aligning the first character of a line to some requirement
    inherited from the previous line are called indentation.

    Granted, a portion of that indentation is derived from the nesting
    level of some logically enclosing programming language construct, and
    part of it may be derived from the position of a character of some
    parallel constituent within the construct.

    > (lisp
    > (nested list
    > with symbols
    > and things))
    > But then neither does Python. I happen to think that's a feature.


    Python has logical line continuation which gives rise to the need for
    hanging indents to line up with parallel constituents in a folded
    expression.

    Python also allows for the possibility of statements separated by
    semicolons on one line, which may need to be lined up in columns.

    var = 42; foo = 53
    x = 2; y = 10

    > (And of course you can do what you like inside a comment. That's
    > because tabs are for indentation, and indentation is meanigless in that
    > context.


    A comment can contain example code, which contains indentation.

    What, I can't change the tab size to display that how I want? Waaah!!!
    (;_;)
    Kaz Kylheku, May 16, 2006
    #17
  18. Xah Lee

    Aaron Gray Guest

    I was once a religous tabber until working on multiple source code sources,
    now I am a religious spacer :)

    My 2bits worth,

    Aaron
    Aaron Gray, May 17, 2006
    #18
  19. Xah Lee

    Bill Pursell Guest

    Xah Lee wrote:
    > Tabs versus Spaces in Source Code
    >
    > Xah Lee, 2006-05-13
    >
    > In coding a computer program, there's often the choices of tabs or
    > spaces for code indentation.

    <snip>
    > (2) Due to the first reason, they have created and
    > propagated a massive none-understanding and mis-use, to the degree that
    > many tools (e.g. vi) does not deal with tabs well


    :set ts=<n>

    Yeah, that's really tough. vi does just fine handling tabs. vim does
    an even better job, with mode-lines, = and :retab.

    In my experience, the people who complain about the use
    of tabs for indentation are the people who don't know
    how to use their editor, and those people tend to use
    emacs.
    Bill Pursell, May 17, 2006
    #19
  20. Xah Lee

    Big and Blue Guest

    Bill Pursell wrote:
    >
    > In my experience, the people who complain about the use
    > of tabs for indentation are the people who don't know
    > how to use their editor, and those people tend to use
    > emacs.


    So, the people who do use tabs are those who think they should be able
    to force their view/setting onto others.

    I prefer to work *with* people, not *against* them. My experience is
    that tabs can (and hence do) cause problems. Spaces do not. It's seems
    that those who work with code from many sources, rather than just their own,
    prefer spaces.


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue, May 17, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xah Lee
    Replies:
    42
    Views:
    1,379
    Oliver Wong
    May 23, 2006
  2. Xah Lee

    Tabs versus Spaces in Source Code

    Xah Lee, May 15, 2006, in forum: Python
    Replies:
    135
    Views:
    3,678
    Oliver Wong
    May 23, 2006
  3. Robert Hicks

    Re: Spaces and tabs messing up code

    Robert Hicks, Jan 9, 2008, in forum: Python
    Replies:
    1
    Views:
    334
    Ben Finney
    Jan 9, 2008
  4. rantingrick

    Tabs -vs- Spaces: Tabs should have won.

    rantingrick, Jul 16, 2011, in forum: Python
    Replies:
    95
    Views:
    1,831
    Roy Smith
    Jul 19, 2011
  5. Paul Butcher
    Replies:
    12
    Views:
    708
    Gary Wright
    Nov 28, 2007
Loading...

Share This Page