Slashdot Mirror


400,000 GitHub Repositories, 1 Billion Files, 14TB of Code: Spaces or Tabs? (medium.com)

Here's a debate that refuses to die: given a choice, would you rather use spaces or tabs? An episode of Silicon Valley last season had a bit on this. Now we have more data to analyze people's behavior. A Google developer has looked into 400,000 GitHub repositories -- 1 billion files, 14 terabytes to find that programmers with interest in specific languages do seem to prefer either tabs or spaces. Spoiler alert: space wins, like all the time.

259 of 391 comments (clear)

  1. Tabspaces? by PCM2 · · Score: 5, Insightful

    Yeah, OK, I get it. Spaces make it easier to cut and paste your code into whatever and have it look the same. But does anybody seriously type all those spaces? You don't just set the Tab key to expand to spaces?

    --
    Breakfast served all day!
    1. Re:Tabspaces? by Anonymous Coward · · Score: 4, Insightful

      Any IDE can be configured to use spaces instead of when you indent.

    2. Re:Tabspaces? by godrik · · Score: 1

      But does anybody seriously type all those spaces? You don't just set the Tab key to expand to spaces?

      or most likely, the editor enforces formatting with whatever parameters you configure it with. That's emacs default setting in C for instance: pressing tab indents this line consistently with the one above.

    3. Re:Tabspaces? by sumsguy · · Score: 1

      No. Depending on the editor, you can substitute tabs with x number of spaces, so every tab is actually two spaces; I prefer two spaces/tab.

    4. Re:Tabspaces? by somenickname · · Score: 2

      I imagine that most people have their editor set to do smart spacing. The editor is smart enough to properly line up the next line based on the content of the previous line. So, it's not really onerous to use spaces and has the added benefit of being unambiguous.

      Amusing anecdote: Some very old Unix software is fanatical about using tabs. Not because of style considerations, because it's old enough that the extra disk space consumed by using spaces was unacceptable when the software was first written.

    5. Re:Tabspaces? by Austerity+Empowers · · Score: 3, Insightful

      But does anybody seriously type all those spaces? You don't just set the Tab key to expand to spaces?

      Not unless you are using notepad. Everything from vim to atom.io will let you choose hard tabs or spaces, almost all of them know to use hard tabs in makefiles. All of them can auto-indent too with either hard tabs or spaces.

      I worship the religion of spaces, but the religion of spaces still derives from the pantheon of indentation, we all use the tab key but will absolutely crucify anyone from the other religion.

    6. Re:Tabspaces? by Viol8 · · Score: 2

      " The editor is smart enough to properly line up the next line based on the content of the previous line."

      That is one of the most annoying things an editor can do IMO (and if someone has put it as a default in the global .vimrc they need to die a slow painful death). If my next line is in an outer block it means i have to delete the damn indentation which is a lot more labour intensive than putting some in in the first place!

      Also with tabs I can change the indentation width to suit my needs, with spaces I can't without doing a global search and replace which will probably fuck something else up (eg spaces inside a string).

    7. Re:Tabspaces? by PCM2 · · Score: 4, Insightful

      Do you really think people using spaces are sitting there tapping the spacebar 12 times for every line?

      Well no, so that's kind of my point. It's really tabs for everybody, because nobody has given a shit about the ASCII contents of text files for years.

      --
      Breakfast served all day!
    8. Re:Tabspaces? by sumsguy · · Score: 1

      Meh, if(this) { //stuff here }

    9. Re: Tabspaces? by PCM2 · · Score: 1

      And these are source code files, yes?

      --
      Breakfast served all day!
    10. Re:Tabspaces? by EndlessNameless · · Score: 2

      What is this tab-expansion black magic that you're talking about?

      You know, this mystery thing that Silicon Valley apparently knows nothing about.

      Otherwise known as "the feature which makes their entire analysis meaningless".

      --

      ---
      According to the latest ruleset, this post should be modded as Vorpal Flamebait +5.
    11. Re:Tabspaces? by johnw · · Score: 3, Insightful

      That is one of the most annoying things an editor can do IMO (and if someone has put it as a default in the global .vimrc they need to die a slow painful death). If my next line is in an outer block it means i have to delete the damn indentation which is a lot more labour intensive than putting some in in the first place!

      Your average editor which does auto-indentation like this generally has enough smarts to realise it needs to go back a level when you finish a block. You keep typing and your desired and configured indentation just happens.

      Even if it didn't (and why would you use an editor which couldn't manage it?) it would still be less work to reduce by one level of indent than to insert N-1 levels.

    12. Re:Tabspaces? by JoeMerchant · · Score: 1

      I don't care how you get the spaces in there, my editor does "smart spacing" for me, just as long as the saved file has spaces, not tabs.

      One calorie Tab soda would be a good logo for tabs in files: 1 as in: only good for use in a single editor.

    13. Re: Tabspaces? by Anonymous Coward · · Score: 1

      In Python, tabs -vs- spaces matter. Yes, the whitespace has syntactic meaning in that language. You can use either spaces OR tabs, but whatever you use, must be used consistently.

    14. Re:Tabspaces? by lgw · · Score: 2

      Well no, so that's kind of my point. It's really tabs for everybody, because nobody has given a shit about the ASCII contents of text files for years.

      Except for all the version control tools and diff viewers out there that still aren't very sophisticated. This is why we insist people normalize to spaces (and normalize line endings). You don't want that shit in your way when you've got a cryptic, urgent bug at 3 AM.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    15. Re:Tabspaces? by Hognoxious · · Score: 2

      I do. I find the rat-atat-rat-atat-rat-atat-rat-atat very therapeutic.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    16. Re:Tabspaces? by JimToo · · Score: 1

      No, I've set space key to contract to tabs so I can retain the joy of meaningless button pressing.

      Oh right ... that describes this whole response.

    17. Re: Tabspaces? by PCM2 · · Score: 4, Insightful

      Also, please stop moving the goal posts, first you said "text files" and now you suddenly shift to "source code files". Not cool.

      Sorry, I forgot about the combination of not reading the stories and the autism spectrum. My bad.

      --
      Breakfast served all day!
    18. Re: Tabspaces? by gfxguy · · Score: 5, Interesting

      Python is my go-to scripting language when possible, but it's the one thing about it that bothers me - the anal retentive way it forces you to follow Guido's formatting standards. Yes, there is some choice, but when you figure out that tabs make more sense you become an outcast in the python community.

      --
      Stupid sexy Flanders.
    19. Re:Tabspaces? by Z00L00K · · Score: 2

      And then you can use an auto-formatter in the editor that cleans up stuff for you and replaces any tabs for indentation with spaces.

      A tab is usually 8 spaces, but the editor may be configured otherwise. For small programs the 8 space tab is good enough, but as soon as stuff grows it has a tendency to cause the need for a very wide screen and refactoring help to break down things.

      So I imagine that if you look at the size of the program you will see that in small programs the tab is more common than spaces for indentation. Often because you can live with using notepad, edlin, vi or even "cat > src.c" for the small snippets.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    20. Re: Tabspaces? by gfxguy · · Score: 2

      The problem is you're confusing languages and editors, and it depends on the editor, and yes, after it inserts "x" number of spaces when I hit the tab - and then I need to unindent, it's annoying. Why on earth so many programmers decided to standardize on spaces instead of tabs is baffling until you understand that they are anal retentive nut bags who insist on "x" number of spaces per indent with no choice.

      --
      Stupid sexy Flanders.
    21. Re:Tabspaces? by hermitdev · · Score: 2

      This is why I generally prefer to keep hard tabs for indentation, and uses spaces for alignment. Different people have different preferences. I've seen 2, 3, 4 and 8 in the wild. This really sucks when you have all 4 types working on the same project. Any decent editor (I'm scowling at you, notepad) allows you to configure the rendered size of a tab.

    22. Re:Tabspaces? by Rob+Y. · · Score: 1

      Okay, so smaller indents are nice for displaying complex code without a huge monitor. But my problem is when a coder sets a non-standard small tab stop and then mixes spaces and tabs for indentation. Then anybody else that opens that file in an editor set for 8-character tab stops has to deal with an utter mess of stuff that doesn't line up. Anyone who does this should be shot - unless, of course, they're your boss...

      --
      Posted from my Android phone. Oh, I can change this? There, that's better...
    23. Re:Tabspaces? by Anonymous Coward · · Score: 1

      If my next line is in an outer block it means i have to delete the damn indentation which is a lot more labour intensive than putting some in in the first place!

      In that case, just type CTRL-D to go back one level.

      That always works regardless of whether "expandtab" is on or off.

      (and if someone has put it as a default in the global .vimrc they need to die a slow painful death)

      Instead of asking people who are knowledgeable about vim to die a slow and painful death, it might be more constructive if you learned about vim's various features and conveniences.

    24. Re:Tabspaces? by dfghjk · · Score: 1

      The debate isn't about what key you press on your keyboard, it's about what characters are written to the text file. It's not surprising, though, to see such a shallow misunderstanding of the issue combined with a willingness to argue about it. If people would actually think this argument would be put to sleep.

      Good editors will translate tabs to spaces on load (and maybe even back to tabs on save) and most will auto-indent. This has been true since before many here were born. It's not about effort, its about code having a consistent appearance for every programmer in every tool. That cannot be accomplished with tabs since everyone reserves the right to corrupt the true meaning of a tab (every 8th column, never anything else).

    25. Re: Tabspaces? by dfghjk · · Score: 4, Insightful

      As objectionable as it sounds, python's odd approach to white space doesn't present problems in practice nor does anyone using any reasonable editor have problems with "tabs vs spaces" in Python. It's a non-issue.

      The real violator is make. It actually requires tabs where spaces would otherwise work. It is an actual problem yet no one claims make is for "faggots" except perhaps AC a-holes like you.

    26. Re:Tabspaces? by Z00L00K · · Score: 4, Interesting

      That's when it's time to run the code through a formatter an check it in again.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    27. Re: Tabspaces? by dfghjk · · Score: 1

      You should be become an outcast in every community since you can't think clearly. Nevertheless, Python itself restricts formatting choices *almost* none, only that blocks share a common indention (and that blocks can't share a line with other code in most instances). A far greater formatting offense in the "python community" is the restriction to 80 column lines which has been dead since the 80's.

    28. Re:Tabspaces? by dfghjk · · Score: 1

      Exactly. Source code control tools plus the realization that you have to work with others changes the issue completely. Of course, the person you're responding to thinks the argument is over which key you press...

    29. Re:Tabspaces? by dfghjk · · Score: 1

      Anyone who defines how an editor should behave by what vim does gets what he deserves. Same is true for emacs since both are 40+ years old. We've made some progress since then.

      Controlling indention, auto-indenting, and even reflowing of code blocks is pretty easy in a good tool. You should try one.

    30. Re:Tabspaces? by Cederic · · Score: 2

      Wait? Automated prettify-on-check-in isn't standard these days?

      Shit, had that set up 15 years ago and felt embarrassed about taking so long then.

    31. Re: Tabspaces? by bobmajdakjr · · Score: 1

      Yes i love the arguement of how the ide does it for them blah blah blah tab key = auto spaces - ok then stop being bad and let it insert real tabs. Its pretty douchey to enforce a tab width via spaces in the code if everyones ide is just going to show what they configure anyway.

    32. Re: Tabspaces? by Joviex · · Score: 1

      If you do this then you can't easily set a conditional break point.

      Sure you can, use a better IDE.

    33. Re:Tabspaces? by AmiMoJo · · Score: 1

      Every editor I've ever found that tried to help with indentation and formatting, I ended up hitting backspace at least once after about 50% of block opening characters.

      Just indent the same as the last line, I'll handle everything else. It's slower to have the cursor move somewhere unexpected than for me to just press the tab key.

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    34. Re:Tabspaces? by viperidaenz · · Score: 1

      My source files are encoded in UTF-8, you insensitive clod!

    35. Re: Tabspaces? by viperidaenz · · Score: 2

      TAB is short for "Horizontal Tab", which is code point 9 in the ascii table.
      Space is point 32

      Python has no problem with tab characters for indenting, as long as the source file consistently uses the tabs or spaces.

    36. Re:Tabspaces? by viperidaenz · · Score: 1

      Ctrl-D is delete line in Eclipse and Duplicate line in Notepad++
      Do you mean Shift-Tab?

    37. Re: Tabspaces? by KiloByte · · Score: 1

      Depends on the editor. I for one use jstar where, if indent mode is on (default for C/etc files), pressing backspace gets me back one level of indentation, even guessing the right thing if the file uses something non-standard.

      No idea about more widespread editors, but it's not so hard to handle spaces conveniently.

      --
      The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    38. Re:Tabspaces? by allo · · Score: 1

      :set expandtab

    39. Re: Tabspaces? by allo · · Score: 2

      > Python has no problem with tab characters for indenting, as long as the source file consistently uses the tabs or spaces.
      You don't need to. You can indent one line with 1 space and the next one with 1 tab.
      If you want to, you can make debugging the hell for the next person, when the less indented 2-space line is logical indented to the 1-tab line before.

    40. Re:Tabspaces? by jrumney · · Score: 1

      A tab is usually 8 spaces

      And that right there is why space wins. A space isn't usually 1 space, it is always 1 space. And my experience editing other peoples' code is that modern tabs are usually 4 spaces, sometimes 2 or 3, almost never 8.

    41. Re:Tabspaces? by jrumney · · Score: 1

      The answer to your dilemma is to stop using Python, and use a language with proper block delimiters instead.

    42. Re:Tabspaces? by lgw · · Score: 1

      There's lots of stuff you can do in a small shop that you can't control in a team of 50-100, with all the VCS stuff controlled by a totally different group providing git repos for thousands of devs. Heck, that's why you have such different perspectives and skills in startup guys vs big company guys.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    43. Re: Tabspaces? by brantondaveperson · · Score: 1

      Well, if your definition of a "reasonable editor" is one that can handle python's whitespace madness, then sure. However, there are plenty of editors that don't, or don't quite handle it fully, or don't squiggly-underline whitespace that isn't correct. In my opinion, those editors are perfectly reasonable for all other programming tasks, but are suddenly unreasonable for python.

      I posit that the problem is with python, not with these editors.

    44. Re: Tabspaces? by brantondaveperson · · Score: 1

      Oh man, that's mean.

    45. Re: Tabspaces? by brantondaveperson · · Score: 1

      if (this) { __asm( INT #3 ); /* blah */ }

    46. Re: Tabspaces? by undefinedreference · · Score: 1

      I hate that 80 character limit so much. It's probably my biggest beef with PEP8, right before the four-space indentation rule (2 spaces are so much better).

    47. Re:Tabspaces? by Cederic · · Score: 1

      Working with a team providing Git to over 40 development groups, some of them over a hundred developers strong.

      Absolutely can and do expect good software engineering, and if they want to label it DevOps then go for it.

    48. Re: Tabspaces? by godefroi · · Score: 1

      This is why whitespace-significant languages are bad.

      --
      Karma: Poor (Mostly affected by lame karma-joke sigs)
    49. Re:Tabspaces? by godefroi · · Score: 1

      Why should my coworker get to decide how many spaces my tab is?

      --
      Karma: Poor (Mostly affected by lame karma-joke sigs)
    50. Re:Tabspaces? by Austerity+Empowers · · Score: 1

      BLASPHEME!

      FOUR shalt be the number of spaces thou shalt count, and the number of spaces upon hard tab shall be FOUR. Five shalt thou not count, neither count thou two, excepting that thou proceed to FOUR. Eight is right out.

    51. Re:Tabspaces? by shutdown+-p+now · · Score: 1

      There is one mixing scheme that does not have this problem. Namely:

      - use tabs for indentation only
      - use spaces to align everything else (after indenting with tabs)

      This way, changing tab size only affects indent level, but other things will remain lined up.

      In practice, though, it's still not worth the bother. Spaces all around is easier.

    52. Re: Tabspaces? by shutdown+-p+now · · Score: 1

      In Python 3, you cannot mix tabs and spaces like that - it's specifically forbidden, and will result in a syntax error.

    53. Re: Tabspaces? by allo · · Score: 1

      Do they allow tabs at all? .oO( python3 will never really start )

    54. Re: Tabspaces? by shutdown+-p+now · · Score: 1

      They allow either, so long as they aren't mixed.

  2. Systematic Suppression by Anonymous Coward · · Score: 1

    All this proves is that we Tabbers are being universally and systematically supressed by the Spacers (except in the Go community).

    1. Re:Systematic Suppression by Anonymous Coward · · Score: 2, Funny

      All this proves is that we Tabbers are being universally and systematically supressed by the Spacers (except in the Go community).

      That's because when the Spacers kick the Tabbers out of the building they shout "Just go!", and the Tabbers think that's a language recommendation.

  3. I always use tabs... by QuietLagoon · · Score: 3, Funny

    ... except for the times I use spaces.

    1. Re:I always use tabs... by AmiMoJo · · Score: 3, Insightful

      It's all these Java and HTML heathens skewing the results. If you look a C files the majority use the correct tabs for indentation and optionally spaces for alignment later.

      If god wanted us to use spaces for indentation he wouldn't have made keyboards with tab keys. Also, they reduce wear on your space bar and fingertips.

      TABS!

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    2. Re:I always use tabs... by serviscope_minor · · Score: 1

      Tabs definitely.

      Oh except for the GNU indentation style which is eye-clawingly hideous and is a mockery of both spaces and tabs.

      --
      SJW n. One who posts facts.
    3. Re:I always use tabs... by goose-incarnated · · Score: 1

      If god wanted us to use spaces for indentation he wouldn't have made keyboards with tab keys.

      TABS!

      Here, use an editor that handles both at the same time, in the same file, without confusing the reader:

      :set listchars=tab:\ ,trail:

      Noobs :-)

      --
      I'm a minority race. Save your vitriol for white people.
    4. Re:I always use tabs... by allo · · Score: 1

      doesn't work in my vim ... are you sure its correct that way?

    5. Re:I always use tabs... by Big+Hairy+Ian · · Score: 1

      I only use tabs in bars

      --

      Build a Man a Fire, and He'll Be Warm for a Day. Set a Man on Fire, and He'll Be Warm for the Rest of His Life.

    6. Re:I always use tabs... by goose-incarnated · · Score: 1

      doesn't work in my vim ... are you sure its correct that way?

      /. ate the unicode characters. Replace A and B below with the unicode chars you want to represent tabs and spaces. I use right->arrow for tabs and a dashed bendy line for trailing spaces.

      :set listchars=tab:A\ ,trail:B

      --
      I'm a minority race. Save your vitriol for white people.
    7. Re:I always use tabs... by allo · · Score: 1

      hmm, vim doesn't complain, but it doesn't seem to work either -.-

    8. Re:I always use tabs... by goose-incarnated · · Score: 1

      hmm, vim doesn't complain, but it doesn't seem to work either -.-

      Very odd - it works in both vim and gvim (although in my vimrc I leave out the colon at the beginning of the line). Might be a good idea to do :set noet once vim has opened (to turn tabs on).

      --
      I'm a minority race. Save your vitriol for white people.
    9. Re:I always use tabs... by allo · · Score: 1

      I will read some docs, thank you anyway.

  4. what he said by cellocgw · · Score: 2

    You may "use" tabs, but plenty of editors are set to translate the tab into N spaces.

    Worse, plenty of editors import text documents and **change** the tabs to N spaces whether you wanted to or not.

    Usually this results in a totally garbled python script.

    --
    https://app.box.com/WitthoftResume Code: https://github.com/cellocgw
    1. Re:what he said by gaudior · · Score: 4, Insightful

      Usually this results in a totally garbled python script.

      This is why I avoid Python. Program logic should not be governed by invisible things.

    2. Re:what he said by TangoMargarine · · Score: 4, Informative
      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    3. Re:what he said by Anonymous Coward · · Score: 1

      Level of indentation is literally the most direct visual representation of execution hierarchy I could imagine. It is far from "invisible".

      Also, leaving brackets out of the equation means when you screw it up (let's face it, you will screw it up in either case), all you have to do is realign the statements so they fit logically. No wrestling with levels of brackets, which require at minimum the diversion of attention to the beginning and end of a block, rather than simply the position of the block above it.

    4. Re:what he said by dromgodis · · Score: 1

      Even worse, plenty of developers automatically perform a global re-indent (and re-format, and re-adjust imports) without even thinking as soon as they open a file to make a change. This makes it harder to track the actual changes through source control annotation.

      The discussions about tabs vs spaces is a silly, bike-shed habit some developers fall into when they don't have anything important to discuss. Use whatever you feel like. Mix if you must (unless Python), it is no big deal (there, I said it). But please, please, please don't automatically change parts of the source files that you are not conciously touching.

    5. Re:what he said by swillden · · Score: 1

      Usually this results in a totally garbled python script.

      This is why I avoid Python. Program logic should not be governed by invisible things.

      It's only invisible if your editor sucks. Personally, my editor displays tabs as bright red when I'm looking at python files, because tabs in python files are bugs.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    6. Re:what he said by VAXcat · · Score: 1, Funny

      "Program logic should not be governed by invisible things." Funny, that statement also sums up my attitude about religion...

      --
      There is no God, and Dirac is his prophet.
    7. Re:what he said by dfghjk · · Score: 1

      Python is entirely governed by visible things. All you demonstrate is poor understanding.

    8. Re:what he said by Paco103 · · Score: 1

      So, Whitespace is a bad language? Back to school I go. . . .

    9. Re:what he said by Xtifr · · Score: 1

      The level of indentation is plainly visible, but it looks the same (unless you're using an editor that specially marks tabs somehow) whether you're using spaces or tabs. Therefore, the tab characters are effectively invisible.

      As for your comment about "wrestling with levels of brackets", what? Do you use Notepad to write code? As someone who likes Python a lot, but is also familiar and comfortable with several other languages, that is utter nonsense. Indenting is fairly straightforward in Python, but outdenting is insane! Let's see, I've got the try block and the for block and the if and the if, and now I need to outdent to match up with...one of those. Which is positioned...somewhere. With braces, it's easy to count the braces, or (in most editors), simply put your cursor on the brace and have the editor automatically show you where the block starts. Furthermore, re-indenting with braces is easy, because the editor has braces to guide it. (Unless, again, you're using notepad or something else unsuitable for the task of programming.) With Python, you have to manually inspect the locations of the previous blocks, and god help you if you outdent improperly, because nothing will offer you any hint that you've done so, except the misbehavior of your code at run-time.

      (Let's not even get into what happens in Python if you indent by four, and then by three, and then outdent by eight, or some other doesn't-quite-add-up combination. Python is a great language, but its indentation stuff is its biggest flaw, by far.)

    10. Re:what he said by shutdown+-p+now · · Score: 1

      The level of indentation is plainly visible, but it looks the same (unless you're using an editor that specially marks tabs somehow) whether you're using spaces or tabs. Therefore, the tab characters are effectively invisible.

      Python prohibits mixing spaces and tabs for indentation. So while you don't know whether that indent is using spaces or tabs, what you do know is that all indents that look the same in the same file have the same meaning.

  5. The article conveniently ignores Python by ribuck · · Score: 2

    The article conveniently ignores Python, a 100% tabbed language.

    1. Re:The article conveniently ignores Python by Anonymous Coward · · Score: 4, Informative

      Wrong: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces

    2. Re:The article conveniently ignores Python by LordLucless · · Score: 1

      Uh, it does include python, and PEP8 (which I, as a tabber, ignore) recommends using spaces, not tabs.

      --
      Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
    3. Re:The article conveniently ignores Python by friedmud · · Score: 1

      Definitely wrong. In our (medium sized) project all of our Python is space indented just like our C++ (consistency is key).

      Of course... we all use editors that do the correct spacing by pressing the TAB key... but make no mistake _spaces_ are used. We actually enforce this with automated testing that runs on every pull request... any TAB characters will immediately cause your PR to fail tests...

    4. Re:The article conveniently ignores Python by ausekilis · · Score: 2

      Python isn't a "tabbed language" it merely relies on levels of indentation. Consistent type/count of whitespace in front of code is used to differentiate namespaces. It could be 'n' spaces or 'n' tabs, just prepare for pain if you mix them within a file.

    5. Re:The article conveniently ignores Python by hcs_$reboot · · Score: 1

      There is a 'py' line...

      --
      Slashdot, fix the reply notifications... You won't get away with it...
    6. Re:The article conveniently ignores Python by fnj · · Score: 1

      The article conveniently ignores Python, a 100% tabbed language.

      Bzzzzzzt. Absolutely wrong. Google "PEP8". "Spaces are the preferred indentation method."

    7. Re:The article conveniently ignores Python by fnj · · Score: 1

      100% of my *.py files use two spaces to indent...

      Ah, a man after my own heart. I also use two spaces per indent level. Any more than two is kindergartenish. And yes, I realize that Guido hates me for this, but none of the stuff I write is ever seen by anybody except me, so I don't have to care about catering to those with bad taste. Whenever I used to work on Python code in a team, or made something somebody else might have to maintain later, I did adhere to the dreary prevailing bad taste.

      Know what? I use the same 2 spaces in shell scripts, Perl, C, C++, and everything else, too.

    8. Re:The article conveniently ignores Python by cdrudge · · Score: 1

      It also conveniently ignores (older) COBOL compilers that required spaces. You and your modern languages that get to use tabs...

    9. Re:The article conveniently ignores Python by Hognoxious · · Score: 1

      In my first proper programming job the standard was four spaces. Beurk! You run out of space more easily (some old systems limit you to 80 chars because punch cards) and I find it more jarring to read.

      If you can't see a two space indent you should let your dog do the typing.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    10. Re:The article conveniently ignores Python by buchner.johannes · · Score: 1

      As I said above, PEP8 only applies to the Python project, not all projects written in Python. There is no recommendation for Python code other than consistency.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    11. Re:The article conveniently ignores Python by ribuck · · Score: 1

      Yes, I got that completely wrong. Sorry about that! I don't know what I was thinking.

      And thanks to those who replied in order to correct my unintentional misinformation.

    12. Re:The article conveniently ignores Python by swillden · · Score: 2

      As I said above, PEP8 only applies to the Python project, not all projects written in Python. There is no recommendation for Python code other than consistency.

      PEPs are also generally considered good style recommendations for other Python code.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    13. Re:The article conveniently ignores Python by dfghjk · · Score: 1

      While true, it doesn't argue that Python is "100% tabbed", the specific issue to which you are responding and a gross falsehood.

    14. Re:The article conveniently ignores Python by naris · · Score: 1

      Only the masochistic would use tabs in python...

  6. Doesn't matter who "wins" by LordLucless · · Score: 4, Insightful

    Popularity is a poor measure of quality. Otherwise McDonald's would be Michelin starred.

    --
    Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
    1. Re:Doesn't matter who "wins" by hcs_$reboot · · Score: 1

      McDonald's would be Michelin starred.

      Sorry, Michelin doesn't have negative stars

      --
      Slashdot, fix the reply notifications... You won't get away with it...
    2. Re:Doesn't matter who "wins" by Cederic · · Score: 1

      Think of it this way. Would you want to have a $100 steak every night for dinner?

      Fuck no. Sometimes I want the lamb, or a good bit of gammon. Maybe something lighter like scrambled eggs on toast.

      Well, you may want to, but how long until you end up in the poor house?

      Ah. Ok, maybe I _am_ well paid.

  7. C programmers clearly some kind of deviants by stx23 · · Score: 1

    And go programmers appear not to have space bars.

    1. Re:C programmers clearly some kind of deviants by hcs_$reboot · · Score: 1

      The reason may depends on the respective IDEs (spaces/tabs conversion when saving/loading the file).

      --
      Slashdot, fix the reply notifications... You won't get away with it...
    2. Re:C programmers clearly some kind of deviants by serviscope_minor · · Score: 1

      And go programmers appear not to have space bars. ... or a decent type system!

      (or generics)

      --
      SJW n. One who posts facts.
    3. Re:C programmers clearly some kind of deviants by serviscope_minor · · Score: 2

      The type system is absolutly fine.

      It's tiny and incredibly primitive.

      If you think you need generics, you're doing it wrong.

      I don't think I need generics, I know they make my life easier and so I want them. I've programmed for years both with and without them.

      The funny thing of course is that go has certain generic structures, such as arrays, and maps clearly indicating that generic structures are worthwhile. It's jsut you can't define your own so if your problem domain doesn't map well on to the built in generics, it's a much worse language than if your problem does.

      --
      SJW n. One who posts facts.
    4. Re:C programmers clearly some kind of deviants by GuB-42 · · Score: 1

      And go programmers appear not to have space bars.

      ... but they appear to have a lot of space drinks.

  8. Spaces are for people who don't understand tabs by Viol8 · · Score: 5, Insightful

    The whole point of a tabstop is you can change its width so a file can be indented to the preference of the person reading/editing it (set ts=[width] in vi). With spaces you're stuck with the (often poor) indentation the author chose who is essentially saying "Fuck you, you're going to read the code indented the way I want, not the way you want"

    1. Re:Spaces are for people who don't understand tabs by mrun4982 · · Score: 1, Insightful

      The problem with tabs is you pretty much have to format your code to use a certain tab width, else things won't always line up correctly when using a different sized width. I see this all the time with code that uses hard tabs. Thus, you might as well just use spaces. Unless you're a novice programmer, the coding style the author chose shouldn't affect your ability to read the code and modify it. Such things don't matter.

    2. Re:Spaces are for people who don't understand tabs by johnw · · Score: 4, Insightful

      It's a nice idea in theory, but it's never worked - nor is it the point of tabs.
      If all indents were always solely at the beginning of a line, and always an exact multiple of whatever N you've chosen then it might have a chance, but they aren't and so it just breaks.

      Don't mess with the size of a tab character - you'll just cause pain.

    3. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 2, Informative

      > a file can be indented to the preference of the person reading/editing it

      No, fuck that. I shouldn't have to mess with my editor to get sane spacing. Code is text, not binary. Get the binary out of the code. What if my editor isn't able to do that, and what if I need to use a text mode or command line? Fuck all that hassle.

      And to flip it: if you really need to see it with some OTHER number of spaces than are actually there, I bet there's a text transform you could apply to the spaced file too. We don't need to start putting tabs places to get this.

      What if you EVER need to indent something, but less than the full amount? You are outta luck with tabs.
      What if you are writing something where you want a character to exist directly underneath another, but one is preceded by non-whitespace, and the other by whitespace? With spaces, you just do that, with tabs, fuck you.
      A tab means very different things to different programs. Unless your code is just for you, you don't know the future use case of future programmers. You don't know if it will be output in a shell, in an editor where tab is interpreted, not as a number of spaces, but as instructions to go to a tab stop (you know, the actual intended use of tab in formatting), or as some other thing completely.

      But really its simple: a space is a space. A tab is a formatting instruction that every coder from that point must deal with in every display device that the code is viewed on, taking it from a simple text file to some binary file that requires everyone tweak settings for, as well as the unspoken condition that certain types of formatting become impossible (line A has a standard indent followed by the word "Quintuple", line B is supposed to have a character underneath the "p"- can't do that with tabs and have it be display independent anymore)... Tabs work for the tabber, and the tabber alone. Spaces work for everyone.

    4. Re:Spaces are for people who don't understand tabs by somenickname · · Score: 1

      The issue is that a lot of code has traditionally been 80 characters wide. That way anyone who looks at it in a standard size terminal will see the exact thing that the author saw when he wrote the code. Tabs are ambiguous in that, in a traditional 80 character wide display, you may have to guess what tab size the author used and changing that tab size may have unintended consequences.

    5. Re:Spaces are for people who don't understand tabs by serviscope_minor · · Score: 4, Insightful

      Ick no!

      Use only tabs to indent to the beginning of the indent level. Use spaces for all other alignment, including if you want to go a little further in than the indent level for some reason.

      Then, it all works perfectly and in 99.9999% of cases, someone can change the width of the tab character to whatever they like and it'll look right.

      Then silly people can use tab=8, weirdos can use tab=2 sick fucks can use tab=3 and the rest of us can view it as the gods decreed with tab=4. Feel free to permute that as per your preference except for the tab=3 clause.

      --
      SJW n. One who posts facts.
    6. Re:Spaces are for people who don't understand tabs by diamondmagic · · Score: 1

      If you're using NOTEPAD to edit code then that means you have to hit the space bar or backspace multiple times to indent code one level, and you risk highlighting or indenting only a fraction of an indent. So even in that case, tabs are STILL preferable!

      Most developers aren't writing on very small screens anymore, and even if you are, you should know better than to write spaghetti code that goes more than a few levels deep (the "Inception Rule" of don't go more than four levels deep).

    7. Re:Spaces are for people who don't understand tabs by MobyDisk · · Score: 1

      While I agree, there are two remaining issues: Cases where it still doesn't work, and tool support.

      Tool support:
      Do you know of an editor that replaces spaces with tabs only at the beginning of the line? That would make this problem moot. But every editor I've ever seen either puts tabs everywhere it can, or never puts them in. None seem to use them intelligently.

      Special indent cases:
      tab-tabvoid LongFunctionNameWithManyArgumentsWithLongNames(int argumentNumber1,
      tab-tab-spaces-morespaces-std::hash_map> argumentNumber2
      In this scenario, the author's intent was to align the second argument with the first. But if the length of a tab varies, then there is no fixed number of tabs that will produce this alignment. It must use only 2 tabs, then spaces after that. But the editor probably doesn't know that.

      ** Hoping Slashdot doesn't overly filter my code example.

    8. Re:Spaces are for people who don't understand tabs by dromgodis · · Score: 1

      If the width of indentation is a major hurdle for your development, maybe you have greater issues. It may not look pretty in your eyes. Get over it. Focus on writing good code instead. If you write it first, you get to decide the indentation. :)

    9. Re:Spaces are for people who don't understand tabs by UnknownSoldier · · Score: 1

      The conventional wisdom is "Tabs for indentation, spaces for alignment."

      The problem is the people _mis-using_ tabs -- which SUCKs. When people use tabs for everything it completely screws you over with formatting unless you use _also_ use the exact same tab settings.

      The tab solution would be great IF (text) editors implement elastic tabs:
      http://nickgravgaard.com/elast...

      Until then, spaces solved the problem of perfect alignment and indentation 100% of the time. Tabs don't. Hence "spaces are the lowest common denominator".

      I don't like most people's code formatting anyways spaces vs tabs doesn't solve the problem. Usually they have crappy variable names, piss-poor design with bad locality, don't understand multi-column alignment, over-engineer the simplest algorithms. Whitespace is only a small problem compared to the bigger problems.

    10. Re:Spaces are for people who don't understand tabs by AikonMGB · · Score: 1

      This is why I indent with tabs, and then do alignment/tabulation/etc with spaces. Precise relative-positioning of elements is maintained, but the user can set the tab width to whatever they desire without breaking anything except maximum line width.

      It works great, and I even change the tab width periodically myself depending on what exactly I'm doing at any one time, as it lets me change focus from overall program structure to detailed tight blocks without reformatting everything.

    11. Re:Spaces are for people who don't understand tabs by Solandri · · Score: 1

      When do you use tabs outside of the beginning of a line? The only time I've seen them elsewhere is when people are trying to align columns. And that's a problem with the editor not properly supporting column formatting, not a problem with tabs.

      Any time tabs are solely at the beginning of a line, they always work for variable N sizes, just as OP says. The only time they don't is when someone tries to put spaces in between leading tabs (which turns the following tabs into not-leading tabs). I usually end up just writing a short script to convert leading spaces into an appropriate number of tabs when I get a piece of code written by someone who seemed to like single-space indents or overly-large indents and hard-coded it with spaces.

      I agree with OP. Tab-challenged people either never learned how to use them properly and make up arguments to excuse their ignorance/misuse, or just want to force their formatting preferences onto other people. When I was a kid we used tab stops on mechanical typewriters (clips you put into the teeth of the track the platen rides upon). When word processors came along, the ability to instantly change the number of spaces in a tab and have the text auto-format to match the new tab size was a godsend.

    12. Re:Spaces are for people who don't understand tabs by dfghjk · · Score: 1

      Your attitude is actually the cause of the problem, you're the one saying "Fuck you". Tabs only work consistently up to the first non-whitespace character on a line.

      You cannot change the definition of a tab and get code alignment to actually work right. It only works for the specific choice made by the programmer when he made the file. It's utility is an illusion, tabs as a solution for code formatting are as worthless as the opinions that defend them.

      Once upon a time tabs were good in source files because they saved space. That no longer matters. That's why people who really understand the issue insist on spaces only in source files.

      If you want a solution to the "often poor" indentation problem, use and editor that can fix it for you. Many can trivially.

    13. Re:Spaces are for people who don't understand tabs by dfghjk · · Score: 1

      A tab character means move to the next 8th column. There is no other valid definition, and those who think otherwise are the cause of the problem. Once people understand and accept it, there is no longer any argument for the use of tabs.

      Perhaps tab users have never added a comment to a source file.

    14. Re:Spaces are for people who don't understand tabs by johnw · · Score: 1

      When do you use tabs outside of the beginning of a line? The only time I've seen them elsewhere is when people are trying to align columns. And that's a problem with the editor not properly supporting column formatting, not a problem with tabs.

      But how do you expect the editor to support column formatting? That is, not how does the editor effect it on screen, but how does it then save the result in a file?

      Contrary to what the OP said, column formatting is precisely the whole point of tabs. That's what they were designed for, going right back into the days of mechanical typewriters.

      I agree with OP. Tab-challenged people either never learned how to use them properly and make up arguments to excuse their ignorance/misuse, or just want to force their formatting preferences onto other people.

      Bollocks! It's not a question of being tab-challenged, or ignorance or misuse. The whole idea of varying the size of tabs to produce an indent which adjusts to personal preference is terminally broken. Yes, it would theoretically be possible, but it requires incredible discipline from your entire programming team, keeping careful track of something which they can't even see! In practice, it just doesn't work.

      As a wise other poster said, tabs work purely in theory - in practice they're a mess.

      As soon as people started varying tabs from their default value of 8 spaces they lost their usefulness. Their only real value was as a primitive form of data compression, and it really isn't needed now.

    15. Re:Spaces are for people who don't understand tabs by Cederic · · Score: 1

      you can't handle properly using tabs and spaces, we won't hire you. If you can't handle and follow such a simple concept, how can we trust your programming skills?

      Maybe because I automated the fuck out of this shit a long time ago and you'd get my salary back with dividends just for the productivity gains I'd force onto your backward fuckwit team.

    16. Re:Spaces are for people who don't understand tabs by goose-incarnated · · Score: 1

      Use only tabs to indent to the beginning of the indent level. Use spaces for all other alignment,... the rest of us can view it as the gods decreed with tab=4.

      And the very first time you ever try to read your own code in a diff, or a grep, or some other automated tool, your code is going to span much more than the comfortable 68-78 characters per line that humans read best at.

      Unless you're very very new at this, you'll be reading code much more than you'll be writing it. When reading, you don't really have control over what the tools like grep and others will do.

      --
      I'm a minority race. Save your vitriol for white people.
    17. Re:Spaces are for people who don't understand tabs by serviscope_minor · · Score: 1

      Well, I tend to use an editor based diff, such as gvimdiff which of course respects my tab settings.

      As for the other tools, sure you can only read 68-78 characters (that's awfully specific) but the blank ones at the beginning have about as much effect on me as the potentially infinite number of blank characters at the end.

      Anyway I do everything from xterm more or less and I still like tab=4

      --
      SJW n. One who posts facts.
    18. Re:Spaces are for people who don't understand tabs by goose-incarnated · · Score: 1

      Well, I tend to use an editor based diff, such as gvimdiff which of course respects my tab settings.

      Sure it does, but that's only a single tool. Due to fuckery that came from before I was employed, I regularly do things like:

      for X in `find . | grep -v \.svn | grep -i "\.[ch]$"`; do grep $SEARCHTERM $X; done

      To make things manageable I usually use sed to replace all tabs in the utilities' output with a few spaces.

      As for the other tools, sure you can only read 68-78 characters (that's awfully specific)

      Well, that's because it's what humans read best at. It's why the default for LaTeX is what it is, and why newspapers are printed in columns, etc.

      but the blank ones at the beginning have about as much effect on me as the potentially infinite number of blank characters at the end.

      Anyway I do everything from xterm more or less and I still like tab=4

      The xterm work is why I can't deal with tabs - a single line output from grep, diff, cut, etc overflow making it hard to visually match the thing you were looking for with the line it occurs on. A large number of tabs could place the search term, for example, three lines below the actual line it was found on. I don't read the output, I scan it.

      --
      I'm a minority race. Save your vitriol for white people.
    19. Re:Spaces are for people who don't understand tabs by Cl1mh4224rd · · Score: 1

      Use only tabs to indent to the beginning of the indent level. Use spaces for all other alignment, including if you want to go a little further in than the indent level for some reason.

      It pains me that "tabs for indentation, spaces for alignment" seems to be such a minority. The combination seems to solve nearly every complaint I've seen from both camps.

      It's as if the desire for purity is fundamental in human nature, but manifests itself differently in each person. For some it's race; for others it's use of tabs/space. :-)

      --
      People will pass up steak once a week, for crap every day.
    20. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      I can't believe your drek was modded insightful. If you use tabs to indent- which means you are a monster- and then use spaces to align- it will ONLY look correct if you know what the hell the tabs were.

      If the tabs meant "go to a multiple of five" (many editors, and generally what a tab actually is), then this definitely fails, because many editors instead convert tabs to a (variable number) of spaces.

      If the tabs meant "four spaces on the developers screen", then he may use one, two, or three spaces to indent something (at his whim). So, three tabs followed by three spaces may look correct for him as 15 spaces, while above it four tabs followed by no spaces would be 16 spaces. He intended to put a 3 space indent. But this super-friendly-hey-everyone-link-hands stuff breaks the moment someone wants two-spaced tabs- now the one that is supposed to be more indented (the original 15) is now 9 spaces in, and the less indented one (the original 12) is now 8 spaces in- their positions are now incorrect.

      If you already have an idea about how many spaces a tab is, JUST FUCKING USE THAT MANY SPACES. Don't force everyone else to use your own precious IDE, and be living in your own head.

      Tabs are binary. They are type setting instructions. Do you put form feeds in code to advance to the next page?

    21. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      > When reading, you don't really have control over what the tools like grep and others will do.

      Some tabmonkey will come along and provide some command line option for grep that you have to memorize next. And heaven help you if you want to look for something like (space)ttyTime to find just ttyTime and not NaugttyTime or whatever. Now it doesn't fucking search up, because there's a fucking tab in the way.

    22. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      > Well, I tend to use an editor based diff, such as gvimdiff which of course respects my tab settings.

      Cool, now everyone has to use your fucking IDE too, with your exact settings, as well as knowing how many fucking spaces to a tab. The joy of tabs truly never ends.

    23. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 2

      > It pains me that "tabs for indentation, spaces for alignment" seems to be such a minority.

      (tab)(tab)(tab)(space)(space)(space)Word1
      (tab)(tab)(tab)(tab)Word2

      Which one should be further to the right?

      Tabs + spaces is not even salvageable with a goddamned sed. You need to line by line that horseshit. At least I can fix a tab-damaged file with a script and a git command, your advice will cost serious time.

    24. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      > nor is it the point of tabs.

      Tabs are a binary character encoding a type setting command, meaning to advance to the next tab stop. That's the point of tabs. They are trivially unsuitable for code.

    25. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      > Precise relative-positioning of elements is maintained, ...but only for certain tab widths. If you used spaces, your users wouldn't have this issue at all.

    26. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      Wait, now tabs are good because they make it hard to indent? The guy is in notepad editing shit with a tight deadline, and your solution is "rewrite the code- if it has that many indents, it is probably written badly".

      God damn. Just. Use. Fucking. Space.

    27. Re:Spaces are for people who don't understand tabs by cfalcon · · Score: 1

      > The tab solution would be great IF (text) editors implement elastic tabs:

      Hold up, right now, the actual intended purpose of a tab is to advance to a tab stop. Some editors have it move the cursor a fixed number of spaces. Other editors let you set that fixed number, with an implementation specific thing. Command line tools just have a default and maybe there's a shell variable to override it.

      So tabs already mean two completely different things to professionals.

      You want to add a third.

      Also, once you add that third thing, everyone is now tied to whatever IDE uses that.

      Or just don't be an asshole, and use spaces.

    28. Re:Spaces are for people who don't understand tabs by serviscope_minor · · Score: 1

      WTF are you talking about?

      Tabs are semantic, spaces are not. If everyone uses tabs properly then you can view my code with whatever indent you choose. If I use spaces, you have to view it at the indent I choose. It's not complicated.

      --
      SJW n. One who posts facts.
    29. Re:Spaces are for people who don't understand tabs by serviscope_minor · · Score: 1

      I can't believe your drek was modded insightful. If you use tabs to indent- which means you are a monster- and then use spaces to align- it will ONLY look correct if you know what the hell the tabs were.

      Nope. The only exception is if you want to align something with a different indent level. Take for example:


      [tab][tab]if(we_need_a_block)
      [tab][tab][tab]i = a + very + long
      [tab][tab][tab]''''expression + more + crap + blah
      [tab][tab][tab]''''the + end;

      Now redo it with tabs as 8 spaces:

      [taaaaab][taaaaab]if(we_need_a_block)
      [taaaaab][taaaaab][taaaaab]i = a+ very + long
      [taaaaab][taaaaab][taaaaab]''''expression + more + crap + blah
      [taaaaab][taaaaab][taaaaab]''''the end;

      That is how tabs work.

      If the tabs meant "go to a multiple of five" (many editors, and generally what a tab actually is), then this definitely fails, because many editors instead convert tabs to a (variable number) of spaces.

      Well, shit, then turn that fucking setting off because it's amazingly stupid.

      If you already have an idea about how many spaces a tab is, JUST FUCKING USE THAT MANY SPACES. Don't force everyone else to use your own precious IDE, and be living in your own head.

      Christ alive. It's not complicated. No one has to use my "IDE" (I don't use an IDE). My indent scheme will look good in ANYONE's editor. That's the point. It encodes the semantic indent level, not whatever you personally feel looks good.

      --
      SJW n. One who posts facts.
    30. Re:Spaces are for people who don't understand tabs by GuB-42 · · Score: 1

      Elastic tabs are not perfect, there are some cases where it messes up the formatting. For example if you make an "alignment" tab followed by an "indentation" tab on the next line.
      The idea behind elastic tabs is that the tab character is like a column delimiter in a table. However it has to use heuristics to know when the table starts and ends. The way it is done works most of the time but that's not 100%.

    31. Re:Spaces are for people who don't understand tabs by shutdown+-p+now · · Score: 1

      The scheme that he described doesn't require this. Code will look properly lined up for any tab size from 1 to infinity. The only problem is that if you develop with 4-space tabs, say, and then open it in an editor configured for 8-space tabs, that extra indentation will cause the lines to be longer than they otherwise were. But you don't need to know how many spaces he used when writing the code - you configure it with your own preferences for tab-size, that are probably less than the default 8 spaces.

    32. Re:Spaces are for people who don't understand tabs by shutdown+-p+now · · Score: 1

      Code is text, not binary. Get the binary out of the code.

      That makes no sense at all. Do you also avoid LF? It's just as "binary" as TAB is.

      I shouldn't have to mess with my editor to get sane spacing.

      Any sane code editor comes preconfigured for sane spacing, whether it uses tabs or spaces. If it doesn't, you probably have to configure it for space-based indentation the way you want anyway, so you might as well change the tab size to the same amount, too.

      if you really need to see it with some OTHER number of spaces than are actually there, I bet there's a text transform you could apply to the spaced file too.

      Not really. Well, it depends on the coding style. If you only ever use full-size indents for everything, and never e.g. align function arguments or struct members, then yes, you can transform like so - just grab the leading whitespace on every line and replace it.

      But if your coding style is to line things up beyond indent levels - which is the convention for some languages like, say, Haskell - then you have two semantically different kinds of whitespace - indentation proper, and then extra whitespace to line things up. If you use all spaces (or all tabs) for both, that distinction is lost in code, and there isn't really any reliable way to recover it by parsing that code. On the other hand, if you use tabs for indentation, and spaces to line things up, then changing the tab size will change indentation without affecting alignment.

      Note that this requires a fairly disciplined approach - you can only use tabs at the beginning of the line, and you have to be careful to never ever use them to align things beyond nested blocks and such. So, for example, if you write something like:

      struct foo {
        int bar,
            baz;
      };

      for "int bar", you use a single tab to indent. But for "baz", you must not use two tabs, even if that gives the desired alignment at your tab settings. You must use one tab, same as the previous line and all other lines inside the same block, and then the requisite amount of spaces to line things up. Then, even if tab size changes, those spaces will still make sure that "bar" and "baz" appear exactly under each other.

      So this scheme works and doesn't have any issues that you have listed. However, it does add mental overhead for the person writing the code. Whether it's worth it or not is a subjective decision of the person (or the team).

    33. Re:Spaces are for people who don't understand tabs by johannesg · · Score: 1

      This is the 21st century, and I demand the right to use fractional tabs! I want my tabs to align to 3.78 spaces for the optimum combination of readability and screen space use!

    34. Re:Spaces are for people who don't understand tabs by plastbox · · Score: 1

      I don't get it.. serviscope_minor took time out of his/her day to explain this to you not once, but twice already, and still you insist on repeating your obviously erroneous claim.

      I threw together a jsfiddle to demonstrate what is meant by "tabs for indentation, spaces for alignment". Please don't judge it to harshly.

      https://jsfiddle.net/5ncvn52h/...

      The code serves no other purpose than to get the point across, namely that we are all geeks who should be better than to argue from emotion and habit when there is an answer which is objectively better.

  9. Skewed by s.petry · · Score: 1

    I happen to use Sublime today, Nedit previously, and both replace tab characters with spaces. I'd be willing to bet that other applications do the same thing. Obviously this skews the result because the author may use tab but tabs get converted without knowledge. Additionally, many places strip tabs from files on commits. Again, this skews the result. TFA didn't bother to mention a pre commit hook as that would change the fakerovercy (sorry, it may be funny for a TV show but pretty stupid to argue outside of that).

    When I write code (not my primary job but often enough) I use tabs much more than spaces. Most coders I know do the same thing.

    --

    -The wise argue that there are few absolutes, the fool argues that there are no probabilities.

    1. Re:Skewed by Qzukk · · Score: 2

      The argument was never about what button you push on your keyboard, it has always been about how fucked up your shit gets when someone else opens it in a different editor.

      --
      If I have been able to see further than others, it is because I bought a pair of binoculars.
    2. Re:Skewed by BringsApples · · Score: 1

      I'm pretty sure, judging by the linked video, that it's about pressing a button 8 times, or pressing a button 1 time, and the reduced file size that results from using TAB.

      --
      Politics; n. : A religion whereby man is god.
    3. Re:Skewed by BringsApples · · Score: 1

      Lazy is as lazy does.

      I, for one, have always been using space, but only because I thought TAB moved to many spaces. After reading a few comments here, I learned that I can actually adjust the amount of spaces created by TAB. I could have probably already learned that by way of reading man pages. ...but I'm lazy!

      --
      Politics; n. : A religion whereby man is god.
    4. Re:Skewed by NewWorldDan · · Score: 1

      Which is why I favor spaces over tabs. There can be a mix of spaces and tabs and it will display in an unpredictable fashion. Spaces always display the same. Then again, I use the autoformat in my IDE, and I have no idea what that outputs (nor do I really care). I figure the boffins who created Visual Studio know more than I do, but I've been wrong before. I mean, I use the tab key, but I'd like that to just be shorthand for entering 4 spaces.

    5. Re:Skewed by kwbauer · · Score: 1

      No, the tabbers care about levels of indentation and then let everyone set their own value for how wide a level-of-indentation is. Spacers are all about making everyone use only what they want. Spacers are narcissistic and tabbers are caring.

  10. Interesting by hcs_$reboot · · Score: 1

    C is more tabby and C++ is more spacy. Different IDEs I presume.

    --
    Slashdot, fix the reply notifications... You won't get away with it...
    1. Re:Interesting by GuB-42 · · Score: 1

      I suspect some of it comes from the linux coding style rules, which requires tabs.

  11. Theory vs. Practice by rockmuelle · · Score: 5, Insightful

    In theory, tabs are the right solution. In practice, spaces are the right solution.

    -Chris

    1. Re:Theory vs. Practice by TFlan91 · · Score: 4, Interesting

      I disagree.

      I disagree with the whole debate entirely...

      Tabs for indentation, spaces for alignment AFTER indentation... Tabs so that people can choose whatever width they want, but after that width (meant for indentation of blocks) use spaces to align whatever you want...

      It really isn't that hard and it pleases everyone.

    2. Re:Theory vs. Practice by phorm · · Score: 1

      I've used a couple editors which pretty much represent a tab as a certain number of spaces at the line beginning, but as a tab later in the line. It looks *beautiful* in the editor.

      Then I opened it in vim, and discovered that it was still inserting actual tabs but just visually formatting them to look nice and uniform. I'm pretty sure people wonder why my code looks like ass.

      I do like the idea of space-from-the-left, tab-on-the-right though

      e.g. spaces for function/comparison/loop/etc indents, tabs for things like lining up variable definition as

      function somefunct {
          $bob = 1;
          $sam = 2;
      }

      p.s. Next coding holy-war, brackets in the function definition or the following line?

    3. Re:Theory vs. Practice by Kjella · · Score: 2

      In theory, tabs are the right solution. In practice, spaces are the right solution.

      I disagree. I disagree with the whole debate entirely... Tabs for indentation, spaces for alignment AFTER indentation... Tabs so that people can choose whatever width they want, but after that width (meant for indentation of blocks) use spaces to align whatever you want... It really isn't that hard and it pleases everyone.

      1. Congratulations, you win the "theoretically correctest" award
      2. I'd be happy if functions and variables had sane names
      3. Except those who have to write it, they're not pleased

      --
      Live today, because you never know what tomorrow brings
    4. Re:Theory vs. Practice by eyenot · · Score: 1

      i always end the definition with the opening bracket so that there is absolutely no fucking way it goes missing. if it's not at the end of the line it hasn't been entered.

      and then i usually close bracket in the exact same indentation as the code it's closing. this way when you're looking at a huge set of subroutines and starting to wonder where this or that set of lines was defined, you just find the closing bracket and follow the line up until your vision literally collides with the definition. ta-da, no missing the definition.

      otherwise you can look up and actually miss the definition if you're skimming too fast, and maybe end up with the bracketed definition before it in the same indentation.

      --
      "Stratigraphically the origin of agriculture and thermonuclear destruction will appear essentially simultaneous" -- Lee
    5. Re:Theory vs. Practice by dromgodis · · Score: 1

      In theory, tabs are the right solution. In practice, spaces are the right solution.

      -Chris

      This! From experience.

    6. Re:Theory vs. Practice by FrankHaynes · · Score: 1

      As always, the difference between theory and practice is greater in practice than it is in theory.

      --
      slashdot: A failed experiment.
    7. Re:Theory vs. Practice by jcdr · · Score: 1

      +1
      That's the right way for sure.
      Any editor should automatically use this rule by default.

      I will add that with the today screen width, 8 spaces tab is really not an issue.

    8. Re:Theory vs. Practice by naris · · Score: 1

      That is not a valid argument. You should always use only space, or have spaces expanded to tabs, because a space is always a space. A tab might be 4 spaces or 3 spaces or 2 spaces or default to 8 spaces (or columns every 2,3,4,8,etc columns) depending on the settings of the editor. If there are multiple people working on the same set of files with different settings for tabs, it rapidly becomes an incomprehensible mess.

    9. Re:Theory vs. Practice by naris · · Score: 1

      *always* the following line!

    10. Re:Theory vs. Practice by phorm · · Score: 1

      That's funny, because I've tended to see that as the opposite in most cases (not saying it's better, just the coding-style I've seen and it seems fairly clean), e.g.

      sub foo
      {
          $var = 22;
          $anothervar = 23;
          if ( $var == $anothervar )
          {
              return $var1;
          }
      }

    11. Re:Theory vs. Practice by Cl1mh4224rd · · Score: 1

      That is not a valid argument. You should always use only space, or have spaces expanded to tabs, because a space is always a space. A tab might be 4 spaces or 3 spaces or 2 spaces or default to 8 spaces (or columns every 2,3,4,8,etc columns) depending on the settings of the editor. If there are multiple people working on the same set of files with different settings for tabs, it rapidly becomes an incomprehensible mess.

      This makes no sense. Tab widths aren't encoded into the file; they're editor-specific. Jim could use ts=2 and Bob could use ts=8, look at the same file, and not notice anything screwy; they'll each see indentation at their preferred width.

      --
      People will pass up steak once a week, for crap every day.
    12. Re:Theory vs. Practice by phorm · · Score: 1

      I tend to prefer aligned braces (e.g. following-line so that it matches the closing brace).

      It seems that lately programming courses are teaching the "following the function-definition" version.

      I'll admit that I sometimes do a hybrid. Inline for the function definition, next-line for any operators etc

      sub foo(){
          if ( $bob == 1 )
          {
                  #do something
          }
      }

    13. Re:Theory vs. Practice by jdschulteis · · Score: 1

      I will add that with the today screen width, 8 spaces tab is really not an issue.

      It's not just a matter of screen real estate. At least one study (see the book "Code Complete") found that test subjects scored lower on code comprehension when indent widths were smaller than 2 or greater than 4 spaces.

    14. Re:Theory vs. Practice by jcdr · · Score: 1

      "At lest one study" is nowhere near to be an argument. You can probably find "at least one study" that claim whatever you wants on a so width subject as the style used by individuals. I can either say that at least 3 well known projects (Linux, Git, PHP) uses 8 spaces tabs for indentation.

      Now the cool stuff about tabs is that it allow to be very easily adjusted in a perfectly reliably way by the user editor without touching the file content.
      I will add that 8 spaces tabs make code with too many indentations look wrong faster, and I found this a good feature in my experience.

    15. Re:Theory vs. Practice by jcdr · · Score: 1

      And this is also very clear:

      sub foo {
              $var = 22;
              $anothervar = 23;
              if ($var == $anothervar) {
                      return $var1;
              }
      }

      While wasting a line for each open brace is not so a problem for the functions, this make code really annoying to read if there is a lot of consecutive if-then blocks. K&R coding style is widely used for a reason.

  12. Tabs are redundant these days by johnw · · Score: 1

    A long, long time ago, in a data centre far, far away...

    Back in the day, a multi-user system might have had a single 4.8M hard disk, shared between the operating system and all its users. It made sense to use tabs instead of lots of spaces for indents, because each tab saved you 8 spaces - a pretty good compression ratio, and a worthwhile saving in disk usage.

    Then came a period of chaos, where people started muddling up their desired indent with the size of a tab. Decent editors always let you separate the two, but poor quality editors confused them, and so you ended up with tabs being re-defined as 4 characters, or even sillier things.

    Given today's disk capacities, there is really no point in bothering with characters in your source files to achieve indents. Be specific, and have however many spaces you want. A decent text editor will let you configure the Tab key to give you whatever indent you want, but for goodness sake configure it to do it by way of spaces.

    Back before the sizes of tabs got confused, I've used editors which would do the following:

    First press of Tab - insert 4 spaces.
    Second press - remove the 4 spaces and insert a hard TAB
    Third press - add 4 spaces.

    etc. It was all very clever, but unnecessary now.

    1. Re:Tabs are redundant these days by johnw · · Score: 1

      s/bothering with characters/bothering with TAB characters/

    2. Re:Tabs are redundant these days by flargleblarg · · Score: 1

      Back in the day, a multi-user system might have had a single 4.8M hard disk, shared between ...

      I believe you mean 4.8 MiB, not 4.8 MB.
      Standard disk size then was 5 MB, which was about 4.8 MiB.

    3. Re:Tabs are redundant these days by johnw · · Score: 1

      I believe you mean 4.8 MiB, not 4.8 MB.

      Back then, the term mibibyte hadn't been invented, but yes, when they were referred to as 4.8 it was a binary and not a decimal unit.

      Standard disk size then was 5 MB, which was about 4.8 MiB

      When? The disks I'm thinking of came as a removable platter with a published capacity of initially 2.4 MB (or what would now be called mibibytes), increasing with later models to 4.8 MB.

    4. Re:Tabs are redundant these days by flargleblarg · · Score: 1

      Back then, the term mibibyte hadn't been invented, but yes, when they were referred to as 4.8 it was a binary and not a decimal unit.

      I believe you mean mebibyte, not mibibyte.

      https://en.wikipedia.org/wiki/Mebibyte

      When? The disks I'm thinking of came as a removable platter with a published capacity of initially 2.4 MB (or what would now be called mibibytes), increasing with later models to 4.8 MB.

      I was confused. I was thinking of machines like the IBM 305 RAMAC, which stored 5 million 6-bit characters (which is only about 3.75 MB).

  13. Spaces... by __aaclcg7560 · · Score: 1

    Only because I use Python.

    1. Re:Spaces... by __aaclcg7560 · · Score: 1

      Makes even less sense to use spaces in Python or whitespace sensitive languages. Lots of frustration here from merging code bases from multiple people who decided to use a different # spaces to define a tab.

      PEP 8 recommends spaces over tabs. Most IDEs will default to four spaces.

      https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces

    2. Re:Spaces... by serviscope_minor · · Score: 1

      I like to mix spaces and tabs when I use python because I like to use pedantic arsing around to troll people who claim Python is easy to read.

      --
      SJW n. One who posts facts.
    3. Re:Spaces... by gfxguy · · Score: 1

      It doesn't matter what the PEP says - I use python a lot, but it's heinous that a language enforces a certain style of indenting. In this case, if I work in an editor with 2 space indents, and you use 4, and we cut and paste between, it's all fubarred. If we'd just use tabs, and set our editors of choice to display tab widths we like, then there's ZERO problems combining code. I get that python works on indent levels instead of braces/brackets, and it is actually visually more appealing to me, and so I understand why not to mix spaces and tabs in the same file - but the standard should have always been tabs so that anal retentives couldn't screw others by forcing the number of spaces they insist on. If we all used tabs instead of spaces, everybody could view the code however they want - and no complaining your editor won't do that. Unless you're using notepad (which won't even translate tabs to spaces to begin with, let alone define a space width), then your editor of choice likely can display (and hey, even print) whatever tab width you want.

      --
      Stupid sexy Flanders.
  14. Both. by fahrbot-bot · · Score: 1

    I use Emacs with a function bound to the Return Key that performs a and the re-indent function indents with tabs and spaces as appropriate -- meaning 10 spaces would be indented using 1 tab and 2 spaces.

    (defun smart-newline ()
    "(reindent-then-newline-and-indent) if in a mode listed in smart-newline-modes. Otherwise just (newline)."
    (interactive)
    (if (memq major-mode smart-newline-modes)
    (reindent-then-newline-and-indent)
    (newline)))

    --
    It must have been something you assimilated. . . .
    1. Re:Both. by WallyL · · Score: 5, Insightful

      Ew. That's an unusual combination of tabs and spaces.
       
      ...and also because of Emacs.

    2. Re:Both. by quintus_horatius · · Score: 2

      meaning 10 spaces would be indented using 1 tab and 2 spaces.

      That is truly the worst of both worlds. If you're going to use tabs, then tabs should be used for indenting (i.e. the block-level of the code) and spaces for formatting after the appropriate indent has been achieved, and the two should not mix.

      Doing it your way will improperly display in any other editor or viewer, including Emacs, that has a different-width tab -- which is pretty much all of them, since the 4-space tab-width is so popular.

    3. Re:Both. by fahrbot-bot · · Score: 1
      Not so.

      As long as the indenting method is consistent, there's generally no problem regardless of the displayed tab-width -- which people should just fucking leave at 8 spaces and don't use so many of them. (People that indent using only tabs should simply be killed.) In addition, I've been doing this since 1985 and neither I or my co-workers have *ever* had any problem with my code. To the contrary, code that has been edited (usually) in vi, indented using just tabs, but with a smaller tab-width is much more problematic and ugly (and requires either tweaking the editor to display correctly or simply re-indenting the code properly).

      My 30 years of experience, millions of lines of code generated and edited, in about 20 languages, on just about everything from PCs to Cray computers (using and administrating) stands pretty solidly.

      --
      It must have been something you assimilated. . . .
    4. Re:Both. by fahrbot-bot · · Score: 1

      Bzzzzzt. Combining tabs and spaces to make up a single indent level is BRAIN DEAD.

      Actually no. Indenting w/just tabs is brain dead and indenting w/just spaces is counter-productive. Your low UID aside, I'll stack my 30 years of experience using Emacs like that against that any day.

      --
      It must have been something you assimilated. . . .
    5. Re:Both. by fahrbot-bot · · Score: 1

      That is truly the worst of both worlds. If you're going to use tabs, then tabs should be used for indenting (i.e. the block-level of the code) and spaces for formatting after the appropriate indent has been achieved, and the two should not mix.

      Also, to follow up, Emacs has language-specific mode styles and knows how to indent code properly. It just uses a mix of tabs and spaces to achieve that indenting. All of this is configurable, but I always use the default style settings. Many of the posts for this article mention editors doing smart indenting rather than people just using tabs/spaces willy-nilly.

      --
      It must have been something you assimilated. . . .
    6. Re:Both. by flargleblarg · · Score: 1

      Bzzzzzt. Combining tabs and spaces to make up a single indent level is BRAIN DEAD.

      Actually no. Indenting w/just tabs is brain dead and indenting w/just spaces is counter-productive. Your low UID aside, I'll stack my 30 years of experience using Emacs like that against that any day.

      Actually, yes. Mixing tabs and spaces to make a single indent level (e.g., 0x09 0x20 0x20 0x20 0x20 0x09 0x20 0x20 0x20 0x20) is about the most braindead, stupid, foolish, retarded, dumb thing you could ever do in a text file. It ruins things for everyone.

    7. Re:Both. by fahrbot-bot · · Score: 1

      Actually, yes. Mixing tabs and spaces to make a single indent level (e.g., 0x09 0x20 0x20 0x20 0x20 0x09 0x20 0x20 0x20 0x20) is about the most braindead, stupid, foolish, retarded, dumb thing you could ever do in a text file. It ruins things for everyone.

      Emacs auto-indenting doesn't do it that way. It uses tabs then spaces. So (by default) an indent of 4 would be (4 spaces), an indent of 10 would be (1 tab + 2 spaces) an indent of 17 would be (2 tabs + 1 space) ... People (including myself) have been using this indent behavior in Emacs for about 30 years w/o problems. You don't seem to be speaking from a point of experience here, as I am. Code formatted this way displays correctly in Vi, and other editors, regardless of the tab-width setting. In addition, the actual indent levels are language dependent and the Emacs mode styles are completely configurable.

      --
      It must have been something you assimilated. . . .
    8. Re:Both. by flargleblarg · · Score: 1

      Ah. I mis-remembered. Thank you for the correction. Yes, I encountered some code once that a coworker had written which had indentation like 0x09 0x09 0x09 0x09 0x20 0x20 0x20 0x20. I wanted to pour coffee on his keyboard. God, that shit is awful to deal with. Spaces are for alignment, not indentation.

  15. Probably not accurate by hcs_$reboot · · Score: 1

    Even when the user requests tabs, when the number of visible spaces is less than, say, 8 spaces, some IDEs save that indent with spaces, then convert as tabs if necessary when loading the file. This because most users set the tabs at 3 or 4 spaces. This way the user has its tabs when working in the IDE, and may still 'cat' the file that visually looks the same. The method used to consider a file 'tab' or 'space' based on the number of indents in either category is therefore (probably) inaccurate.

    --
    Slashdot, fix the reply notifications... You won't get away with it...
  16. Re:Deterministic behavior by NiteMair · · Score: 1

    And neither are spaces (with proportional fonts)

  17. In a world, where tabs were the right size... by Maltheus · · Score: 2

    I think there'd be less of a debate if tabs were 4 chars in width, out of the box. Not sure they'd even bother with a tabstop setting had that been the case. Granted, you're always gonna have your freaks, like this one guy I worked for who insisted on 3 spaces for indentation, but they would have gotten nowhere had the default tabstop been reasonable from the start.

    That being said, spaces for work code, tabs for personal code.

    1. Re:In a world, where tabs were the right size... by dfghjk · · Score: 1

      3 characters is the perfect indentation amount and is curiously the standard in use at the company I joined a few years ago. 2 is not visually distinctive enough and 4 wastes screen space.

    2. Re:In a world, where tabs were the right size... by Maltheus · · Score: 1

      This right here, is why tabs are best though. I get that it can mess with cut & paste (people shouldn't be doing that anyway), and the lining up up split lines, but it's worth it to let everybody use the width they're most comfortable with.

  18. not where i thought this headline was going! by eyenot · · Score: 1

    i was really expecting the argument to go,

    "well, look at how much damn code is amassing through the collective efforts of all of us dumbasses.

    "well considering how enormous the collective code base is getting,

    "NOW how do you feel about using three times as much character data in your whitespace, HUH?!"

    but instead it was just an enormous poll.

    (i'm disappointed because it seemed like it would be an interesting debate.)

    --
    "Stratigraphically the origin of agriculture and thermonuclear destruction will appear essentially simultaneous" -- Lee
  19. Re: Deterministic behavior by Anonymous Coward · · Score: 2, Insightful

    If you use proportional fonts for programming, you deserve every bad thing that happens to you.

  20. Shell scripts + copy&paste by tbuskey · · Score: 1

    I write shell and will copy code from my scripts to paste & run. Leading spaces are no problem. Tabs will invoke bash completion. No tabs! No capes! Remember Thunderhead? Sucked into a vortex!

  21. Re:Deterministic behavior by johnw · · Score: 1

    And neither are spaces (with proportional fonts)

    But editing source code using a proportional font is a way to drive yourself insane.

  22. Spaces are the Betamax of coding. by RightSaidFred99 · · Score: 2

    And by this, I mean spaces are inferior, just like Betamax actually was.

    Tabs are, of course, more logical because it lets the person viewing/editing the code decide how it looks. You can set your tab width to 2 chars for super tight code, 3 for a bit more obvious indentation, or a more standard look with 4. You can even go nuts and go with 8 spaces.

    A tab semantically means "indent this one level". Two tabs = 2 indentations, etc... What the _fuck_ does 8 spaces mean? Is that one indentation or two? Oh, that's right, you have to look at the rest of the existing code to figure it out.

    It's god damn ridiculous and to hell with the Spacers.

    1. Re:Spaces are the Betamax of coding. by Yunzil · · Score: 2

      As a Spacer, you Tabbers will be the first against the wall when the revolution comes.

    2. Re:Spaces are the Betamax of coding. by swilver · · Score: 2

      Except those annoying tabbers don't know how to tab properly. They use them everywhere, in comments, at the end of a line, etc. See how well that lines up when you change the tab size...

      Only tab for indentation at the start of a line. Never mix tabs/spaces for identation. Then it might work.

      Since most people don't have the time to care about this, teams decide to use spaces so it looks uniform everywhere. It's much easier to explain how to space properly than how to tab properly.

    3. Re:Spaces are the Betamax of coding. by diamondmagic · · Score: 1

      You also can't accidentally highlight half an indent when using tabs!

      I prefer 3-space tabs myself, but this is pretty unheard of in the space-indent world.

    4. Re:Spaces are the Betamax of coding. by gfxguy · · Score: 1

      I'm kind of wondering what idiots tab at the middle/end of lines. I guess I see some people lining up all the "=" in a block of assignments, but that's always just been idiotic anyway. Point being, if I'm using tabs for indenting levels, it's exactly what they are useful for. Spaces work, but only anal retentives who insists on "x" spaces per indent really need spaces. I prefer generically allowing other programmers to view/edit the code as they see fit instead of insisting on my format. If they want to ruin it for everybody, they can go ahead and change tabs to spaces.

      --
      Stupid sexy Flanders.
    5. Re:Spaces are the Betamax of coding. by jrumney · · Score: 1

      And by this, I mean spaces are inferior, just like Betamax actually was.

      I can't tell if your argument was supposed to be sarcastic, or just flawed.

  23. ansi terminal code has some cool stuff by eyenot · · Score: 1

    honestly i'd prefer if lines indented past 3 spaces were indented using some delimiter and integer.

    i hate backspacing over numerous tabs and the more indented your code gets the more you're working with a falling apart mountain of tabs. sure, code manager, blah blah, what ever. the only reason we're talking about this is because enough of us are manually maintaining our code through traditional key bindings.

    i prefer spaces only because i don't want to store tabs and deal with different editors treating tabs different ways. especially if they are 'smart' editors and are going to take those tabs to mean something other than 'get out of my sight and go sit with your friends.'

    but column selecting and backspacing spaces gets to be just as tedious. hell, moreso. it's 3-8 times as many keypresses. (3 for me, _thanks_!!!)

    and most editors don't seem to get it goldilocks-just-right when it comes to assuming what i want when i'm starting a new line or removing an indentation. most of them either try too hard or force me into a weird hybrid of styles. i still haven't found an editor for windows that i can force to behave according to the style i came up with years ago and still prefer to use today, and i have tried some pretty configurable editors.

    what i would really like is a standard that just says 'the indentation of this line is this many space', just have an integer and delimiter and hide them from view. i want the option to backspace all of it away without the behaviour being both tied to (parsing) and part of (outputting) the space and tab characters. especially if i decide to use a tab or several space in an unorthodox comment space.

    i think it would be a lot easier for most editors to handle during their 'smart' indenting behaviour, as well. and there is already a notable standard for this in the old ansi terminal code definition. i'm always up for revitalizing the use and even advancement of that old shit.

    --
    "Stratigraphically the origin of agriculture and thermonuclear destruction will appear essentially simultaneous" -- Lee
    1. Re:ansi terminal code has some cool stuff by jader3rd · · Score: 1

      i hate backspacing over numerous tabs

      I hate backspaces over 8x the spaces vs. what there would have been if tabs instead.

    2. Re:ansi terminal code has some cool stuff by eyenot · · Score: 1

      *grips own face, pulls downward, with ever increasing force while reading this*

      *croaking*

      read what i fucking wrote before replying please

      --
      "Stratigraphically the origin of agriculture and thermonuclear destruction will appear essentially simultaneous" -- Lee
  24. You have to use tabs in the Linux Kernel by mallyn · · Score: 1

    Folks: You have no choice. In the Linux kernel, you have to use tabs and the tabs have to be set to eight spaces.

    --
    Most Respectfully Yours Mark Allyn Bellingham, Washington
    1. Re:You have to use tabs in the Linux Kernel by serviscope_minor · · Score: 3, Insightful

      You have to use tabs, sure, but how on earth are they going to know what width you set them to?

      --
      SJW n. One who posts facts.
    2. Re:You have to use tabs in the Linux Kernel by houghi · · Score: 1

      Set them to whatever you want. Mine are not fixed. I set them to the with of the terminal I am working on.

      --
      Don't fight for your country, if your country does not fight for you.
  25. When arguments like this start! by wbtittle · · Score: 1

    It is time to turn around and walk the other way, unless you are entertained by stupid arguments.

    Mac vs PC. Run the other way. I can get around in all of them. I swear less at Macs. I praise Microsoft for guaranteeing that I will continue to be employable till I die.

    iPhone vs Android: Run the other way. I can get around in both. I swear at both of them equally for being moronic in different places.

    Spaces vs Tabs: WTF? I don't worry about it... Sublime, textmate, etc do what they do. The only time I start crying is when Excel decides it cannot figure out quoted comma delimited content on text to column. (which I finally learned to paste, text to column, undo, undo, paste again and everything is fixed)...

    Curly brace underneath function or to the right of the params parens? You can get me started on this in a meeting, but I will follow whatever the practice guidelines say for the company. I like to see the curly braces line up though.

    Butter vs Margarine? Salted vs Unsalted? I prefer Butter. I prefer Unsalted.

    --
    God: "I don't leave footprints!"
    1. Re:When arguments like this start! by gfxguy · · Score: 1

      The problem is that most of those arguments are meaningless because it simply comes down to personal choice - I don't argue mac vs pc or android vs ios, because you should just pick whatever you want and I honestly don't care. But when we're working on code together, I like consistency - so things like tabs vs spaces and where to put curly braces actually matter. I also don't much care, like you, and will just do whatever the current guidelines are - but that doesn't mean the guidelines aren't up for debate, or that it doesn't make more sense to use tabs for indenting so that you don't have to anally follow someone else's guidelines for amount of space to indent (because the other programmers can set whatever tab widths they want).

      So... yeah, I get your argument - most of those things just come down to personal choice, but the programming styles involve working with others. The only reason to run the other way is because people have staked out their position and nobody will change anybody else's mind.

      --
      Stupid sexy Flanders.
  26. one thing the tabs and spaces folks agree on by dlang_rocks · · Score: 5, Funny
    1. Re:one thing the tabs and spaces folks agree on by fnj · · Score: 1

      Correctimundo. The one standout brain-dead no-no.

    2. Re:one thing the tabs and spaces folks agree on by swillden · · Score: 1

      https://www.emacswiki.org/emac...

      EMACS can deal quite nicely with both. With smart-tabs mode, it uses tabs for indentation and spaces for alignment which, as a couple of people above have pointed out, always keeps things properly aligned regardless of tab size.

      That said, most EMACS users have been around long enough to know that regardless of how theoretically nice the approach is, it's a Bad Idea. It works great until it doesn't. In contrast, using spaces only works, even without editor support (though it's better with editor support), and the only real downside is that files are a tiny bit larger.

      Personally, my approach to indentation these days is to construct a reasonable .clang-format file, bind "clang-format -style=file -i" to a key combination (I use <Ctrl><Alt><Tab>, struck as a chord with my left hand's thumb, pinky and ring finger, with the hand automatically bouncing back to home row), and hit it regularly. There are rare corner cases where the formatting it produces is sub-optimal, but weighed against being able to Just Ignore Formatting, I'll pay that price all damn day. I write code without bothering with spaces or line breaks except when my fingers happen to randomly insert them, then let clang-format fix it all up for me. I don't think about where to break lines, where to line things up, when to put spaces around expressions, etc. The tool does that, does it right 99% of the time and I can live with the 1% of the time it doesn't.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    3. Re:one thing the tabs and spaces folks agree on by cfalcon · · Score: 1

      > EMACS can deal quite nicely with both. With smart-tabs mode, it uses tabs for indentation and spaces for alignment which, as a couple of people above have pointed out, always keeps things properly aligned regardless of tab size.

      And then someone else has to edit the code, and fuck them in the peehole if they don't use your exact version of EMACS right? Also, fuck them if they need to use the command line. And fuck them if they have to use a different diff tool. And fuck them if they need to search for the next instance of (space)axe, because it might actually be (tab)axe, and now they have to do a regex or something.

      Basically, every tab solution is "fuck everyone else forever".

    4. Re:one thing the tabs and spaces folks agree on by swillden · · Score: 1

      You didn't read the post you replied to.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    5. Re:one thing the tabs and spaces folks agree on by cfalcon · · Score: 1

      ...

      Apparently not all of it!

  27. Free-form code is too often a mess... by KonoWatakushi · · Score: 1

    Expanded tabs are a waste of space. The reasonable solution is using tabs for leading indent, and space otherwise. Tabs provide proper semantic meaning for indent, allowing editors to respect user preference.

    Fundamentally though, the question shouldn't even need to be considered. Code is necessarily structured and should have a canonical format, enforced by a tool like gofmt, which makes mechanical transformations of code much simpler. The amount of time wasted on formatting, both for writing and reading code is absurd.

    I'll even suggest that a free-form text editor is an annoyingly primitive tool for programming. Given a suitable language and a canonical representation of the code, a contextually aware coding environment with full knowledge of the syntax could allow a significantly better development experience.

    1. Re:Free-form code is too often a mess... by fnj · · Score: 1

      No. May I repeat myself? HELL NO.

    2. Re:Free-form code is too often a mess... by dfghjk · · Score: 1

      "Expanded tabs are a waste of space. The reasonable solution is using tabs for leading indent, and space otherwise. Tabs provide proper semantic meaning for indent, allowing editors to respect user preference."

      A laughably broken solution for many reasons. Mixing tabs and spaces on the same line will be broken 100% of the time and the "semantic meaning for indent" does not occur just at the beginning of a line so your solution does nothing.

      It's not surprising that someone who gets the issue so wrong would subsequently argue for a tool that forces such poorly conceived solutions on everyone. There is already a perfect solution...spaces.

    3. Re:Free-form code is too often a mess... by cfalcon · · Score: 1

      > I'll even suggest that a free-form text editor is an annoyingly primitive tool for programming.

      So, everyone else is wrong, and fuck every extant tool for coding, and fuck them for not doing the right thing (which in this case is, "use an editor that doesn't even exist yet").

      Coincidentally, you also recommend tabs. Hrm. Coincidence?

      (tab)(tab)(tab)(space)(space)(space)Word1
      (tab)(tab)(tab)(tab)Word2

      Which one is further to the right? Oh, it depends on the tab setting.

      Does the tab mean a tab stop? In that case, where are the tab stops? Note: this is the intended use of tab.
      Does the tab mean "go forward N spaces"? In this case, N=4 and N=2 flip the indentation of Word1 and Word2

      Guess what a space means? IT MEANS SPACE
      JUST USE THAT

      ffffffffffffff

  28. Whitespace programming language by anchovy_chekov · · Score: 1

    I know it's not popular, so it would never make the list. But disappointed nonetheless that Whitespace didn't get scrutinised. That data would have meant something!

  29. Statistics! by sshir · · Score: 1

    One billion files?! That's why adults use statistics. Relatively small random sample would have given the same result.

    1. Re:Statistics! by Cederic · · Score: 1

      Making the sample representative of the population would probably take longer than scanning the full set.

      Write it, start it running, go out on the piss, black out, wake up, shower, start to cook breakfast, scream in agony, pull on clothes, dash to take the fried egg out of the pan before it overcooks, eat breakfast, go out for the day, get home, check results.

      Or you could've skipped the entertainment and worked out how to pick a representative sample.

  30. Tabs in web-development is an absolute must. by Qbertino · · Score: 1

    Tabs with PHP, HTML and other web programming languages. Not using them at least triples your filesize.
    I remember replacing space with tabs and reducing outbound web documents from 90 kb to 30 kb with one simple search and replace.
    Pretty much settling the argument at least in this field.

    If I catch you using spaces in your web output, I will hurt you. Bad. And you will deserve it.

    If you're using spaces in a compiled language - go right ahead. The compiler is a must and fixes it all.

    Just as bad or maybe even worse as using spaces in web code is *mixing* spaces and tabs and indent depth.
    That should be punishable with jailtime or something.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:Tabs in web-development is an absolute must. by dfghjk · · Score: 1

      "Tabs with PHP, HTML and other web programming languages. Not using them at least triples your file size."

      LOL I don't think so.

      So your average line length is more than ¾ leading spaces?

      I find it humorous that people think of the web as "programming".

    2. Re:Tabs in web-development is an absolute must. by radish · · Score: 1

      Or...you could just minify & gzip like anyone sensible already does. The format for the human developer does not need to be the same as the format for the browser.

      --

      ---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"

  31. People use spaces four times as often as tabs! by Richard+Kirk · · Score: 4, Funny

    (snigger)

    1. Re:People use spaces four times as often as tabs! by ben_kelley · · Score: 1

      Don't you mean 8 times?

    2. Re:People use spaces four times as often as tabs! by NotInHere · · Score: 1

      No, its two times!

  32. Well, that proves it! by zieroh · · Score: 2

    This was an analysis of files on github, yes? And by definition, those files are managed by git, yes?

    And thus, the files were created by all the young punks that rushed to git, because reasons, yes?

    In light of those conditions, yeah. I can see why there's a prevalence of spaces. The analysis only considers the work output of (mostly) young idiots.I'll bet there's a prevalence on github of non-plumb braces, too.

    --
    People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
    1. Re:Well, that proves it! by zieroh · · Score: 1

      Put your hearing aid back in grandpa and go read your COBOL manual again. Nobody cares about your old, useless tech and "non-plumb braces" isn't a real term, your dementia is showing again. Git is superior to all version control tools.

      I wrote parts of the operating system you're typing on right now, you asshat.

      --
      People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
  33. Re:Deterministic behavior by mattventura · · Score: 3, Insightful

    But that's what I like about tabs. They can be set to display as however many columns each individual wants, rather than requiring everyone to agree on the same number. 4? 3? 8? Pi?

  34. another religious war by Shorts+Eater · · Score: 1

    pea-can vs. p-khan
    potato vs. potatoe
    space vs. tab
    vim vs emacs

    Spoiler alert: vim wins, like all the time.

    --
    Don't allow yourself to dream away time. Be productive. -- Some fortune cookie
  35. Spaces are better, Tabs COULD be better (elastic) by tbttfox · · Score: 1

    From the link:
    The solution - move tabstops to fit the text between them and align them with matching tabstops on adjacent lines

    http://nickgravgaard.com/elast...

  36. Bad Regex = Invalid Results by Anonymous Coward · · Score: 3, Insightful

    The regex used for determine tab vs. space is r'[ \t]', which matches the first space or tab in a line, not whether or not the first character in a line is a space or tab. Thus, for example, a using statement in C# (using System;) would count towards the spaces total where it shouldn't count towards either (unless preceded by spaces or tabs for some reason).

    Fix the regex (r'^[ \t]') and rerun it, i doubt it will allow tabs to win (tabs rule spaces drool), but it would give more accurate results for the charts.

  37. Re:Tab stops too far apart by gfxguy · · Score: 1

    But it depends what you're doing - you're writing code, you're viewing code in the editor of your choice. You might be printing code from the editor of your choice. If your code editor can't vary tab display/print widths, then it's your choice to not use one of the billions of modern editors or IDEs that can.

    --
    Stupid sexy Flanders.
  38. Please Tell me these folks aren't idiots by wbtittle · · Score: 1

    Quick show of hands!

    How many people use the tab key and how many use the space bar?

    Wait I use both, except I don't use the space bar to line up my code.

    --
    God: "I don't leave footprints!"
  39. A couple of things... by erapert · · Score: 2

    1. .json files shouldn't be counted because they're frequently generated by tools rather than by humans (or even human tools...)

    2. Making an argumentum ad populum (i.e. an argument for or against spaces) is really just embarrassing yourself.

    3. Arguing that everyone should use spaces for indentation just because that's how the rest of the project is formatted is nothing more than an appeal to tradition-- furthermore we have tools these days which can automatically transform the whole project to use tabs so it's not like it would amount to re-writing every single file by hand to make the change.

    4. About the flame war... Here's a blog post that sums it up nicely. Spaces for indentation are objectively inferior, provide no improvement over tabs, and are more difficult to work with. If your reason for using them is just to force everyone else to do things (i.e. read and write code) your way then screw you: you're literally one of the reasons the world sucks.

  40. Re:Deterministic behavior by Anonymous Coward · · Score: 1

    until you try moving to a different editor and now all the alignment is messed up.

  41. Don't waste your time on this by Ace17 · · Score: 1

    It turns out codingstyle-related debates become mostly inexistent when people don't have to manually enforce the stylistic rules themselves.
    So just hook uncrustify or astyle at the beginning of your build process, and commit the configuration file. Problem solved.

  42. Re:We need to move to ASTs by OrangeTide · · Score: 1

    It would be pretty easy to represent a parse tree as XML.
    I'm not sure how old greybeard C programmers would feel about keeping source code in XML.
    (actually I'm very sure, and I was tempted to post AC to avoid the pitchforks)

    --
    “Common sense is not so common.” — Voltaire
  43. Tabs by jader3rd · · Score: 1

    They're the character which exist for indentation.

    1. Re:Tabs by cfalcon · · Score: 1

      Yea, they move your type to predefined tab stops. I don't know why you'd want them in a text file though.

    2. Re:Tabs by jader3rd · · Score: 1

      Because I intent my text for clarification to the reader. At least when I'm typing something which has scopes.

  44. Bracket war by Comboman · · Score: 1

    Obviously we must place the starting brackets in the function definition as you have done, because:

    1) if the bracket starts on the following line then it might accidentally line up in the same column with the closing bracket and make the code block too easy to visually identify.

    and

    2) there is a world-wide shortage of carriage returns and they must be carefully rationed.

    --
    Support Right To Repair Legislation.
    1. Re:Bracket war by FrankHaynes · · Score: 1

      The war to fight before this is the naming war:

      () parenthesis

      {} braces

      [] brackets

      I'd be happy if coders could simply get those right.

      Then we can move on to the unwashed masses calling the slash / as in slashdot and web URLs a "backslash". You have to pick your battles.

      --
      slashdot: A failed experiment.
    2. Re:Bracket war by Comboman · · Score: 1

      Technically, they are all brackets. You can subdivide them into round brackets (AKA parenthesis), curly brackets {AKA braces} and square brackets [AKA crotchets]. There are also angle brackets <used commonly in HTML>, as well as other types of brackets used less commonly such as corner brackets and double brackets (which Slashdot won't display correctly). The word 'bracket' by itself may refer to any or all of these but shouldn't be assumed to refer to a specific type.

      --
      Support Right To Repair Legislation.
    3. Re:Bracket war by FrankHaynes · · Score: 1

      Wonderful! One word to refer to multiple types. That should go swimmingly.

      --
      slashdot: A failed experiment.
  45. fibonacci indent by OrangeTide · · Score: 2

    on many of the old video terminals you could set arbitrary points for the tab stops. tab would jump your cursor to the next tab column on the current line.
    There is usually a command to set a tab at the current column, clear at tab at the current column and to clear all tabs. (VT100 and maybe VT52, probably no tab support in something ancient like ADM-3A)

    so you could setup 2 space for the first tab, 4 spaces for the next four, 8 spaces for the remaining.
    a the most elegant tab stop setup would be: 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

    --
    “Common sense is not so common.” — Voltaire
    1. Re:fibonacci indent by cfalcon · · Score: 1

      > There is usually a command to set a tab at the current column, clear at tab at the current column and to clear all tabs.

      Or you could just use spaces, instead of forcing everyone who has to read your code to figure out how to parse your binary, what you meant by it, etc.

  46. Uh oh by bobmajdakjr · · Score: 1

    If spaces can win then anything is possible. Trump presidency here we come.

  47. Pristine Code by zifn4b · · Score: 1

    I have two things to say about code style nazis:

    1) If you totaled up all the money spent on trying to make code pristine in code reviews, you probably could have solved world hunger
    2) You can have all the pristine code you like, but if it doesn't work, it's absolutely worthless. It's a big, shiny you know what.

    Summary: this discussion and my post consequently are a complete and utter waste of time that I can now never get back. :P

    Obligatory XKCD: https://xkcd.com/974/

    --
    We'll make great pets
  48. Doesn't Matter by StormReaver · · Score: 1

    Most IDE's (and some better text editors) have options to convert from spaces to tabs, and from tabs to spaces. Choose your preference, select "reformat" and get on with the job of writing software.

    The debate was interesting back when all we had were dumb text editors, but it's entirely pointless now.

    1. Re:Doesn't Matter by cfalcon · · Score: 1

      > Most IDE's (and some better text editors) have options to

      "Fuck anyone who doesn't use my IDE or one I deem suitable" -> Every pro-tab argument in every thread about this.

  49. Re: Deterministic behavior by bobmajdakjr · · Score: 1

    Which is the entire point. I like my tabs wider than most people it seems. I find it helps me notice when something is getting too complex for a single unit.

  50. Re:Deterministic behavior by goose-incarnated · · Score: 1

    But that's what I like about tabs. They can be set to display as however many columns each individual wants, rather than requiring everyone to agree on the same number. 4? 3? 8? Pi?

    Only for indentation, not for alignment. If you care about writing readable code you'll use spaces.

    --
    I'm a minority race. Save your vitriol for white people.
  51. spaces ftw by tehlinux · · Score: 1

    Spacers are going to convert the tabs to spaces. Tabbers don't covert them back. -> eventually, it will all be spaces.

    --
    Most linux users don't know this, but the man pages were named after Chuck Norris. Chuck Norris fsck'ing hates noobs!
  52. Re:We need to move to ASTs by goose-incarnated · · Score: 1

    It would be pretty easy to represent a parse tree as XML. I'm not sure how old greybeard C programmers would feel about keeping source code in XML. (actually I'm very sure, and I was tempted to post AC to avoid the pitchforks)

    It's been done. That still didn't solve the problem of indentation and alignment:

    (defunc f (n)
    ........(if (eq n 1)
    ............1
    ............(* n (f (- n 1)))))

    --
    I'm a minority race. Save your vitriol for white people.
  53. Re:Deterministic behavior by jon3k · · Score: 1

    What kind of idiot would code without fixed width fonts? That's the stupidest thing I've ever heard in my life. Is that a real thing? Is someone actually that stupid?

  54. Indent vs align by phorm · · Score: 1

    Personally, I prefer spaces for indentation, and tabs for alignment.

  55. Learn a real language. by kaybohmont · · Score: 1

    If this is something that's a real problem for you, it's your fault. Even VIM can handle 'tabcount=4'. Assembly, x86 & AT&T, needs actual tabs in one's code. If your IDE out you can't figure that out and really find this to be an issue? Try Qbasic, Gambas, or actually evolve to real languages. Python is and always will be a teaching/learning language. I would hope coding gets better. But in my 20 years engineering what goes for 'code' is to script kitty to even be engineering. No python doesn't count, php barely, Perl?okay:sure, C/C++, Java, and more. - yes I ranted more than a bit. This is a huge pet peeve of mine. Because NO it makes no difference unless you're so dumb you shouldn't be writing code at all.

  56. Re:We need to move to ASTs by OrangeTide · · Score: 1

    a rule is all you need for indentation and/or alignment once you have the language in a generalized form.

    --
    “Common sense is not so common.” — Voltaire
  57. Well into the 21st century, and we still... by Larsen+E+Whipsnade · · Score: 1

    ...use ASCII text files for source code?

    If we used some smarter format, the IDEs could just display the formatting to individual taste. No more format wars.

    Of course, all current revision control systems would be obsolete, but they're kludges anyway, because text files.

  58. Re:We need to move to ASTs by NotInHere · · Score: 1

    Yeah. Best there should be a systemd module that stores the code for us.

  59. Re:Tabs. by cfalcon · · Score: 1

    > Because your shitty text editor should be able to handle cutting and pasting them.

    Like all tabbers, you begin by dismissing every editor you don't personally like, and taking joy in hurting those who don't use your exact solution. How excellent. What a team player. It's fine that your code can only be edited properly in your own personal IDE.

    What a joke.

  60. Re:We need to move to ASTs by cfalcon · · Score: 1

    > It would be pretty easy to represent a parse tree as XML.

    Well, you definitely came up with something worse than tabs. Now the file just fucking starts as garbage for everyone. And everyone who doesn't use your exact IDE can get bent, I guess. And uh oh, there was a bug in the XSL, and now we have a goto fail bug.

    I definitely admire your dedication to finding novel ways to insert bugs into C code. We have so many already, and the elders told us that all the ways had been discovered. And here you go proving them wrong!

  61. Re:We need to move to ASTs by goose-incarnated · · Score: 1

    a rule is all you need for indentation and/or alignment once you have the language in a generalized form.

    Lisp s-expressions *are* the generalised form for all programming languages. XML, for example, is syntactically a limited and crippled but more verbose representation of s-expressions. All XML can be run through a regex that will spit out conforming s-expressions, but not all s-expressions can be regexed to XML.

    --
    I'm a minority race. Save your vitriol for white people.