Never use hard tabs

Update: This post has been updated to address some of the claims in the comments. Please note that most of these claims are wrong šŸ™‚

As there seems to be some confusion when hard tab characters (ASCII code 9) are appropriate in source code files here is a rule:

1) Never use hard tabs

1. 1) Unless your source code is hard tab sensitive (only such format I know is Makefile)

1. Reasons not to use hard tabs

  • Due to legacy, different text editors treat hard tabs different. UNIX text editors prefer hard tab is 8 spaces, Windows text editors and IDEs (Eclipse) prefer that a hard tab is 4 spaces.
  • The hard tab length agreement between different text editors cannot be reached
  • The hard tab length agreement between people cannot be reached
  • Thus, hard tabs may break source code readability and editability if there is more than a single person editing the file. They will open the file in an editor with different tab settings, edit it and next time you open the file it is ruined and all indentations are wrong.
  • This is even worse on white space sensitive languages (Python, CoffeeScript) as this might actually cause syntax errors or programming logic errors

However, you can avoid this problem in the first place if you do indentation using soft tabs (spaces) instead.

Even if you were the single person in the world editing the text file, even you might switch the text editor in some point and accidentally shoot yourself in the leg.

2. Using soft tabs for indentation and having no hard tabs should not be a problem because

  • All text editors can convert tabs to spaces in fly, when editing the file. Please note me if there are commonly used editors, besides Windows Notepad, which doesn’t do it yet.
  • Text editors usually have different settings to tab key length and indentation settings. The latter is what you really want to adjust.

3. Pseudo-arguments for using hard tabs

  • It makes the file size smaller: you really care about those twenty bytes on your gigabyte hard disks?
  • This one I made up: spaces count toward the file size in web stuff, because visitors download the files. However if those bytes really matter you that much you should be using a minimizer in the first place.
  • I like them arguments…: rationale not involved
  • The change resistance in human nature

You might have a legacy software project having its legacy style guides. If the project big, e.g. Linux kernel, the switching cost may be very high and not affordable. However, even with this kind of codebase, you can gradually replace hard tabs away.

4. Style guides (updated)

Hard tabs are required only in Makefile syntax and preferred only in Go style guides. This is because people have learn by experience that hard tabs cause mess when working with other people.

5. Tab character is not semantically the same as indent level (updated)

There is no style guide or coding conventions saying that the tab character should the indent. This assumption is easy to make because it allows you to stick your head into a sand, ignore the surrounding world and by singing “let the users pick their own tab width” mantra. However, though a cunning idea, this perceived simplicity causes compatibility and co-operation issues which this post tries to highlight.

6. The user should choose to their own tab width (updated)

To choose your own preference is the rationale many people claim is the reason for indentation by tabs. “Let the users pick their own preference for indentation” However if you indent to work with other people the recommendation is to stick to the programming language recommendation. This way people can be more easily pick up the codebase.

There is nothing gained by having “user chooseable indentation width by adjusting tab character width”. The most used indentation width is 4 spaces anyway, so it is extra effort to maintain the freedom to have a user pickable indent width number instead.

Try to go to tell some old UNIX admin that they must adjust their editor tab width (see below).

7. Tab width is 8 spaces and don’t mess with it (updated)

People who use tabs as indent assume tab one tab = one indent and they can freely adjust the tab width, so that the indentation looks nice. However

  • By legacy, the tab character width is 8 spaces and most of the software out there makes this assumption. If you use any other value for tab width you are breaking this legacy social contract and you are making it for other peoples more difficult to work with your project.

This really limits the ability of using tabs as indent, because 8 spaces tabs often don’t make sense as indent (exception in system style C programming like with Linux kernel).

It’s ok if you work with the code in only one text editor alone where you have this one setting for tab width and that’s the only setting in the world controlling the tab width in your source code project. But when someone else must read or edit the code

  • Others must adjust tab width to make your code more readable
  • Adjusting tab widths from 8 spaces might be very difficult when working with other toolchains (e.g. you are viewing the code in terminal using cat)

Also in the languages where the recommended indentation level is only two spaces it would make it little funny to use one tab character just to have two spaces.

8. Tabs cannot be used to format code multi-line functions (updated)

Some people prefer to format long argument lists like this. A Python example which would break because of mixed tabs and spaces if tabs are used as indentation

call_a_function(argument,
                very_long_argument="something",
                even_longer_argument="something_else)

Ā Or in C

   if (first condition
       second condition)

9. Text editors

If you are a text editor author, make sure your text editor ships with hard tabs turned off by default, especially for whitespace sensitive languages if you vary tab policy by file type.

Note that this blog post, and the situation, could have been avoided if

  • All text editors would have sticked to soft tabs by default
  • All text editors would have sticked to a hard tab is 8 spaces by default

But in some point (when?) someone (who?) decided to make our life little more complex.

10. Tools for managing hard tab policy in your software project

\"\"Ā Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

89 thoughts on “Never use hard tabs

  1. What a bullshit hipster blog post indeed. All your arguments against tabs are just opinion and personal preferences, the conclusion are not logical or even based on facts.

    Here is one gem: “There is nothing gained by having ā€œuser chooseable indentation width by adjusting tab character widthā€. The most used indentation width is 4 spaces anyway, so it is extra effort to maintain the freedom to have a user pickable indent width number instead.” — That’s no effort at all if you use tabs, it is when you use spaces. And every single dev has his own preference, so why not enable them to set it to their liking?
    (Oh btw, nice assumption that width 4 is used anyway. If that was the case, why should we be using spaces again?)

    Statements like “Thus, hard tabs may break source code readability and editability if there is more than a single person editing the file.” are just plain wrong. You also reason that those two points speak against using tabs:
    “- The hard tab length agreement between different text editors cannot be reached
    – The hard tab length agreement between people cannot be reached”
    … BECAUSE nobody can agree on on the ‘perfect’ length to indent, tabs are a great thing when working with many people. Anyone is free to use the width they like, which is not possible with spaces!

    If anything, the “3. pseudo-arguments for using hard tabs” you listed apply to YOU! All your “arguments” do not hold once you’re willing to set your freaking tab-width in your editor.

  2. It is much easier to move around file with tabs by arrows than in file with spaces-only (unless you force yourself to 2-spaces indentation or get used to Ctrl+Arrow …but using tabs is still more productive).

    It has nothing to do with file size and whatever pseudo-argument, it is purely about writing your own program and how fast can you be and how comfortable you feel.

    Actually, this article is filled with pseudo-arguments. One of them is that “every editor can replace tab with spaces” – yes, and most of the editors allow to specify tab-size šŸ˜‰ And some can even retab (yes, Vim: retab!) the file as you wish it šŸ˜‰

    Even GitHub can show your files as you want it, just add ?tab=4 to the URL šŸ˜‰ (I often use ?ts=4;w=1 to ignore white spaces and line endings completely … hmm, as I think of it, shoud I use Windows, Linux or Mac line endings?).

    Stupid article, selfish and arogant.

    Programmers: use whatever you want to, and if you create some editor or diff-like program, make sure to have settings for tab-size šŸ˜‰
    And if somebody is complaining about your source file, kick him and let him (or her) write their own source file instead of complaining about tab-size šŸ˜€

  3. There seem to be no legitimate reasons against tabs here.

    You mention that “people can’t agree on indentation size”, which is a plus for tabs because I can use 3-tabs, you can use 4-tabs, our friend can use 8-tabs, and we can all edit the same file and it will look good to each of us.

    You mention that some languages choke on mixed whitespace (things like Python). This does not seem to be a valid argument for or against tabs.

    You say “Tabs cannot be used to format code multi-line functions”, and then provide an example in Python showing how this would break things, however – this example functions – a perfect demonstration of the usefulness of tabs.

    You seem to repeat throughout the article that tabs will mess up indentation, but (Linux kernel development aside,) fail to actually detail any circumstances in which tabs are not the superior indenting choice.

    I need more actual arguments and less fluff about how people listing the arguments against your opinion are “sticking their heads into the sand, ignoring the surrounding world and singing ‘let the users pick their own tab width’ mantra”. Tell me why the USAGE of tabs is wrong; not why the USERS of tabs are wrong.

  4. “10 reasons why people should eat pears but not carrots” (example argument: if you try to eat a carrot but drop it, you might as well pick up a pear next time).

    “Never use yellow pencils” (example argument: if a member of your team is allergic to the color yellow, you’re screwed)

    “Always open the door using your right hand” (example argument: I once opened the door with my left hand and my the tab settings in my emacs changed)

    A tab means a tab, and every editor can render it according to the user’s choice. The only argument that makes any sense here, is that if one member of your team doesn’t play along, then integration is screwed. the rest is drivel.

  5. Spaces are not tabs. And your preference is not relevant here, it’s not like tabs are broken or anything. Customize your text editor if your preference is so important to you. I’ll stick to tabs simply because there’s nothing wrong with them.

  6. “Tabs cannot be used to format code multi-line functions” : That’s why we *ident* with tabs, and we *align* with spaces.
    Indentation is like color scheme: Everyone should be able to decide how it looks like in their text editor. By indenting with spaces, you’re bypassing people’s settings.

    This post is so stupid.

  7. more important than indent style is monotonic numbering of document parts.

    “1” -> “1.1” -> “1.”

  8. I feel like your points support the opposite conclusion that you’re arriving at.

    A major theme of your argument is that people vary in their preferences of how they want their code to look. To that end, isn’t using an abstract measure like tabs (which can be redefined to any arbitrary size a user chooses) far superior to spaces?

    In one case you’re essentially using a variable (1 tab can equal any amount of spaces you choose) to define indentation and in the other situation you’re hard coding the indentation into the file.

  9. Oh no, legacy editors will maybe render my react projects with an indentation of 8! Let’s quickly set an arbitrary indentation length and force it onto everybody! Yeah, that should be fun for sure!

  10. For me the tabs size undefinition are not the problem, are the solution, with tabulation I can set the size that I want, now if the project use white-spaces and the pattern is to use 4 spaces and I want a tabulation with size 2, what I will do? Fight with my boss to refactor all the project with thousand of lines?

  11. Cum on, this is single most dumbest article on the internets.
    You just worong at everything!

    >> Due to legacy, different text editors treat hard tabs different.
    So what?
    Different people is sized different too, is this a reason to not wear pants?

    >> The hard tab length agreement between different text editors cannot be reached
    So what?
    Different people can never agree on their ass width yet there is no problem.

    >> The hard tab length agreement between people cannot be reached
    They also have different penis length and somehow manage to reproduce.

    >> Thus, hard tabs may break source code readability and editability if there is more than a single person editing the file. They will open the file in an editor with different tab settings, edit it and next time you open the file it is ruined and all indentations are wrong.
    This is just nonsense bullshit.
    The only way to ruin indentation is to use spaces instead of tabs where tabs is used.

    >> This is even worse on white space sensitive languages (Python, CoffeeScript) as this might actually cause syntax errors or programming logic errors
    This is just moronic vullshit from person who never ever coded in python anything than helloworld.

  12. These views are stone aged. Anyone still using an editor that can’t properly handle a tab needs to get a life. We live in the world of advanced tools not cat and ed. Get a life and welcome to the new era.
    Tabs allow each developer to format spacing the way they read it best, it keeps things cleaned and easily lined up. Spaces tend to be problematic at best, and can be a big pain.
    As a programmer with 20 years experience, this is the one ignorant idea that always annoyed the hell out of me. We do not live in the year 1960 with teletype terminals, stop coding like we are.

  13. @Steve
    FYI: cat works properly with tabs.
    I use it every day.

  14. What does “should the indent” mean in “There is no style guide or coding conventions saying that the tab character should the indent.”

  15. I searched for “Preserve hard tabs in Emacs” in Google and was redirected to Poe’s Law instead. Okay.

    I’m so sick of the tabs VS spaces bullshit because it’s a war that will never be solved because it’s founded on aesthetics. I’ll just say this, though: every criticism made against hard tabs is founded on people not using them properly. If anybody gives a shit, [here’s how I indent my code](https://github.com/Alhadis/Coding-Style). Hard tabs for indentation, spaces for cosmetic alignment, and always keeping the two separated by non-whitespace characters. It takes self-discipline and a few stylistic sacrifices, but properly indented code can be a truly beautiful thing.

    Take it from somebody who can’t read 2-space indented code without getting eye-strain. Who are you to force your preferred indentation width on others? Would you like to decide the colour scheme of my IDE, too?

    Piss off.

  16. Linux kernel development requires hard tabs. Each tab has be 8 characters.

  17. 6 years and the comments are still coming! Wow!
    Speaking as a C++ and Python developer….
    If the developer is diligent in making absolutely sure that all indentation is 100% tabs and no spaces…then it’s not an issue…until the day that someone slips a space-indentation.

    The problem is that most editors don’t color tabs vs spaces by default, so the code will look okay to the originator, but then be an unholy mess to the next person. Hard tabs are an invisible enabler of messes. The concept of the hard-tab is alluring(I started with hard tabs), but it rarely works out as soon as more than one person is modifying the code. It’s just plain easier to say “everyone use 4-space indentation” and be done with it. All editors can handle it, and it looks the same for everyone.

    In any case, if you _really_ want different indentation, most IDEs will easily re-format code to your preference. Just make sure you change it back to the more-common 4-space standard when you commit it.

    – Jim

  18. Hi Jim,
    Wow indeed.
    What if you say “everyone use 4 space indentation” and somebody slips in a tab?

    As for “All editors can handle it” and “it looks the same for everyone” – the former is true for tabs and the latter is meaningless. Since when is “looks the same” a factor? Do you also enforce uniform fonts?

    Also, the very nature of coding is in line with using tabs. We always try to write what we mean, not focus on representations and side effects. Tabs are what you mean – indent one more level, indent one less.

  19. This debate looks pretty much like the one about versioning (ā€˜Shall we use the release date or a number?ā€™, ā€˜Shall we use floating-point numbers or not?ā€™, ā€˜Shall we use floating-point numbers or X.x.N.n rev. L format?ā€™ etc).

    I prefer hard tabs over soft tabs. Let’s take the most common exampleā€¦
    Suppose you and I arrive on a cheap stock text editor ā€” unset, pluginless and with few functionalities. I use 2-spaces-long indent, let’s say you use 3-spaces-long indent and the rest of the office use 4-spaces-long indent. If we use hard tabs, regardless of the length, it will count as one character. We just have to set the length we want hard tabs to look like. It’s more ‘automatic’ and flexible to me than soft tabs, which are similar to hardcoded stuff to me. By the way, it avoids to overload the file with characters without ‘compressing’ (remove meaningless characters) it (for big files only, though I admit that big files aren’t a good deal).
    Other good side-effects to hard tabs are that you use the keyboard less, preserving it a bit (small streams make big rivers) and ā€“ IMHO ā€“ less ‘neurotic’ (in the sense that it is not because you *want to see* 4-space-long indentation that you *need to have* 4 space characters). Indentation is just visual after all, it is technically useless (except in some cases, where it can often be replaced or simply set to behave as wanted).

    Of course, on a fully-featured custom text editor, you can install plugins to convert the other tabs type to yours. I bet there’s a way to either convert tabs back to the type they were when you write the file or simply display and make the other type of tabs behave like those you use without changing the file’s characters, unless no particular or your type was in use.

    What I mean is that indenting, like versioning, depends on people’s preferences much. There’s good and bad to both indentation styles.

  20. Season 3 of the awesome sitcom “Silicon Valley” actually focuses an episode on the “tabs vs spaces” issue (episode 6, “Bachmanity Insanity”).

    Personally, I prefer spaces to tabs, mostly because (1) the default tab with is different for different editors and (2) not all editors allow tab width to be configured.

    Copy-pasting tab-indented code between Netbeans, Gedit, JSFiddle, Stack Overflow, … easily becomes pretty annoying, especially considering (AFAIK) you can’t configure the tab settings of either JSFiddle and Stack Overflow, which both are different.

    StackOverflow is particularly nasty in inconsistently using 4 spaces in its traditional markup editor and 8 spaces for its more recent Stack Snippets. In StackOverflow, changing tab-indented code from one format to the other requires consistent editing of the indentation. Manually editing legacy code that mixes tab-indented and space-indented easily becomes a nightmare as I tried to illustrate @ http://meta.stackoverflow.com/questions/319377/inconsistency-of-indentation-of-tabs-between-markup-editor-code-samples-and-st.

    Consistently using the same number of spaces (I prefer 4) across different code-bases prevents issues like this. And why the f*** would I want people to personalize the indentation of my code anyway? I fail to see why we should allow everyone to use their own indentation standards, when we try to standardize almost everything else…

    When writing code, personal indentation preferences shouldn’t matter any more than choosing where you put your { and }. If we can have standards for the latter everyone is supposed to adhere to, why can’t we have standards for the former? And from that perspective, soft tabs (aka spaces) make most sense, because it provides the a consistent experience across different editors.

  21. Okay, I’m really trying not to get too involved in this, but when I see retarded logic like this, I feel impelled to speak up.

    > “And why the f*** would I want people to personalize the indentation of my code anyway?”

    Yeah, that’s another way of saying:

    > “I’m a myopic prick who expects all readers will share my indentation preference”

    Try setting your indentation size to 2 spaces and force yourself to work with that for an extended period of time.

    > (2) not all editors allow tab width to be configured.

    Seriously? You’re bringing THAT up as an issue…? Not all editors support soft-tabbing either, should we use that an argument against using spaces over tabs?

    > When writing code, personal indentation preferences shouldnā€™t matter any more than choosing where you put your { and }.

    That’s a load of shit. Indentation can affect one’s ability to digest unfamiliar code, because it helps to take in the outline of a program’s structure. It has a similar impact as changing the font-size of an editor. Everybody has a different setting they’re most comfortable reading at.

  22. > ā€œIā€™m a myopic prick who expects all readers will share my indentation preferenceā€

    That’s why there should be style guides written by authoritative organs to set the standards for the rest of us Muggles. That way, we can all easily read code that is written by other people in the same language, which makes collaboration more efficient.

    But wait… Such style guides already exist… and they typically require the use of exactly four spaces for indentation:
    * http://www.php-fig.org/psr/psr-2/
    * http://www.javaranch.com/styleLong.jsp#format

    So no, 4 spaces is not just some guy’s opinion.
    It’s the industry standard, set by people far more experienced than either you or me!

    ____________

    > “Try setting your indentation size to 2 spaces and force yourself to work with that for an extended period of time.”

    I’ve programmed in C, Java, PHP, JavaScript, Actionscript, ABAP, OpenEdge ABL, PL/SQL, PASCAL and a few other languages in my lifetime.

    I’m pretty sure I can handle going from 4 to 2 spaces in my indentation.

    ____________

    > “Seriously? Youā€™re bringing THAT up as an issueā€¦? Not all editors support soft-tabbing either, should we use that an argument against using spaces over tabs?”

    If your editor does not support “soft-tabbing”, you can always type 4 chars manually. You’re too lazy to do that?

    ____________

    > “Indentation can affect oneā€™s ability to digest unfamiliar code, because it helps to take in the outline of a programā€™s structure.”

    Exactly! That’s why there are guidelines and why everyone should follow them.

    If everyone would just learn to get used to indentations of 4 spaces (as eg. the Java & PHP guidelines require!), every programmer’s life would become easier!

  23. > “If everyone would just learn to get used to indentations of 4 spaces (as eg. the Java & PHP guidelines require!), every programmerā€™s life would become easier!

    >”If everybody coded the same way, there’d be no problems!”

    Lol, right. Get a load of this cunt. You probably let the radio dictate your music tastes, too.

    Fuck off. People’s preferences will unerringly and rightly differ. A language’s “guidelines” aren’t law, and project maintainers are by no means beholden to them.

    > “But waitā€¦ Such style guides already existā€¦ and they typically require the use of exactly four spaces for indentation”

    Really? Other styleguides require the use of TWO spaces (for reasons beyond me). E.g., JavaScript, Ruby, Pascal… Even if the tabs VS spaces debate will die out (which it never will), people will still be bickering about the “correct” tab-stop width (2 vs 4). What’s next? Everybody is required to set their editor’s point-size to 14px?

    Just use a fucking tab and those issues dissolve. The only arguments I’ve heard people raise against them are “styleguides tell you to use spaces” and “people have tabs set to different widths”. If the latter is ever an issue, it’s only because the person didn’t use tabs correctly (as in, for alignment). And that’s a human problem.

    To bottom-line it: correctly formatted and readable code will never reveal the preferred column width of its author.

  24. I used to think that tabs were exactly a programmer’s solution – an interface (declaring an indentation unit) which is indifferent to the implementation (number of visual spaces). To me, this was the most amazing part of the controversy – the fact that it went against the basic engineering approach of the very profession that spawned it.

    However, the last few posts convinced me otherwise. Two arguments in particular shook me:
    1. Some editors don’t support tab size configuration (wordpad for windows 98 immediately springs to mind)
    2. “If everyone would just learn to get used to indentations of 4 spaces”. This is priceless and doesn’t require any interpretation. If a developer is *this* passionate about an issue, to make such a ridiculous statement, I gotta side with them. Such zeal has to be based on a profound truth.

  25. HAHA, yeah.

    I switched to tabs because I was getting tired of repeatedly pressing the spacebar in Notepad, LEL.

  26. > “Other styleguides require the use of TWO spaces (for reasons beyond me). E.g., JavaScript, Ruby, Pascalā€¦”

    They all agree on spaces though… most likely because those who conceived those style guides have far more experience than you millennial twats (who sound like you only just got out of your diapers) and their experience made them aware of how utterly impractical tab spaces indentations are in real life, high collaboration, corporate contexts.

    ____________

    > “I switched to tabs because I was getting tired of repeatedly pressing the spacebar in Notepad, LEL.”

    Lazy, are you?!

    Why don’t you just apply the standards more experienced developers defined you make all our lives easier… and move the f*** on!

  27. I love how this cunt keeps falling back to the same argument of “more experienced people than you agree with me!” It’s like he wouldn’t believe his own argument otherwise.

    > “Why donā€™t you just apply the standards -”

    Heh. Why? I’m perfectly happy using hard tabs and using ’em responsibly, fully acknowledging that tab-widths are subject to personal preference. I’d rather make my code fluid and adjustable then fall deluded to the narcissistic pipe-dream that, someday, there’ll be a perfect standard everybody will follow.

    Get this through your head, junior: aesthetic standards are unicorns. The fact there are so many varying styleguides are proof of this. Go uses tabs, others use spaces, nobody fully agrees and nobody ever will.

    And that’s the truth that experience has taught me: that human beings will always differ, bicker and bikeshed. The only thing we can do is accept the fact there’ll always be people thinking and acting differently. Let them.

  28. > “Heh. Why? Iā€™m perfectly happy using hard tabs and using ā€™em responsibly, fully acknowledging that tab-widths are subject to personal preference.”

    Guidelines exist because they make everyone’s like easier… if everyone actually applies them.

    It’s ignorant, arrogant, millennial twats like you who make more life difficult for the rest of us by arrogantly thinking that you are too good to follow any coding guidelines, that your personal preferences are more important than writing code that’s easy to read for everyone in all editors and syntax highlighters.

    ____________

    > “The only thing we can do is accept the fact thereā€™ll always be people thinking and acting differently. Let them.”

    If you are writing code that only you are ever going to read or change, do as you please.

    If you are writing code other people are supposed to be reading and/or modifying, you and everyone else involved in the product should agree on certain coding standards / guidelines, so your code doesn’t turn into an unmaintainable, unreadable mess before you realize it.

    The more human or technical dependencies your project has, the more important it is to follow standards that are not specific to your team or your project.

    In an ideal world, the frameworks you use, the libraries you use, the code written by third party contractors and the code your team writes all follow the same standards, allowing everyone to be able to read and modify other people’s code.

    Thinking and acting differently is all fine. I totally approve. But when I writing code, I let go of that because I acknowledge the importance of standards over personal preferences.

  29. > … writing code thatā€™s easy to read for everyone in all editors and syntax highlighters.

    You *literally* just stated the reason I use tabs. You’re practically kicking your own arse for me. This is great.

    > Guidelines exist because they make everyoneā€™s like easierā€¦ if everyone actually applies them

    Yes, guidelines can be enforced at a project or company level. But c’mon, expecting the entire *world* to follow them? Seriously?

    Do you want to come into my house’s bathroom and tell me which way the toilet paper should be facing?

    > … and the code your team writes all follow the same standards, allowing everyone to be able to read and modify other peopleā€™s code.

    I wasn’t taking you seriously to begin with, but holy shit dude, now I’m rolling.

  30. Wow, I posted a comment back in 2012, and this debate is still getting so much heat!

    I used to promote hard tabs, and I still think they are the “ultimate” way of indenting. But let’s face it: people are usually not disciplined enough to use tabs for indentation, and spaces for vertical alignment.

    Since 2012, I worked on many collaborative projects, and having different styles of indentation in a single file is a freaking nightmare. So now I value consistency over personal preference. The industry standard (default value in modern IDE) is set to 4-spaces, so I’m using it. We lost a decade ago, hard tabs folks šŸ™

    BUT hard tabs should still be the way to go, if people were not such lazy asses…

    Now I think it’s the responsability of editors to make sure we stay consistent when editing a file.

  31. @Alhadis: Ease up a bit, would you? It’s difficult to take you seriously if you spit enough venom and hyperbole to match an anonymous 14-year-old playing Overwatch. We’re all programmers here. Make your point without the insults.

    If we could’ve started over and made sure that every editor/IDE provided background coloring to tabs so that it was obvious if tabs or spaces were used, then I think hard-tabs would’ve been a better solution. But that didn’t happen. Too many editors default so that a space or tab looks identical. Imagine if two characters both looked like an equal sign, but meant two different things? This is the situation for tabs&spaces with Python programmers. Don’t even get me started on Makefiles (seriously, whose idea was that, anyways?).

    Whatever the personal advantages, it simplifies things and reduces sharing-errors to take hard-tabs out of the equation, since it’s obviously not really feasible to remove all spaces.

    For delimited languages like C/C++/Java/etc, I think the tab/space issue is only really bad if someone re-formats the file and then checks it into GIT (ugh). Python is a more serious issue since white-space is part of the code, so the Python Foundation declared 4-space as the standard. Since Python laid down the hammer, and we use the same IDE for all our projects (Eclipse), it simplified things to make it ALL projects 4-space. But, that’s just our environment.

    Just be consistent within the project. If you contribute to a GitHub or SourceForge project, then match their standard. The code becomes a disaster if everyone is trying to push their personal preference into the existing code base.

    – Jim

  32. So lots of people talk about white space controlled language, such as python.
    While I agree that it becomes important at this time, don’t you want to go back and kick the people that thought “white space will be used to identify scope”.

    Anyhow, I think ultimately this should be less a discussion online and more a discussion in the shops.
    There are arguments such as game development where an 6 or 8 space tab makes sense more than anything. However trying to impose some globalize standard, or using tools to “force” style I think is ultimately ignorant.

    The purpose white space in real programming languages is to make the code more readable, and forcing one over the other (outside of things like python) is limiting that aspect.

    A shop may want to have a standard for reasons such as ensure people do not reformat the entire page on check in/out, or because someone read your blog post.

    There should be no universal standard ever, we are supposed to be smart people, we should be above forcing others to conform for no good reason.

  33. The worst aspect of this argument is that it exists at all and forever will (so long as we have text based languages, even then it will be replaced by some other long running dogmatic ding dong).

    It does my head in. Personally I don’t mind working in either as long as some idiot does’t start mixing up the two in mid sentence so to speak – that’s the worst thing. I have done Linux driver code and was only too happy to follow the tab style guide and programming style (3 indentations max etc). In Verilog, I personally use spaces. But when someone else (always someone else FFS!) tabs one line and then spaces the next in code, I (yes me) created, then I feel I should remove his orher presence from the face of the Earth.

    (workplace name supplied in case anyone wants to avoid)

  34. Seeing as how this thread is fully alive and well again, let’s stir the pot!
    http://www.businessinsider.com/google-silicon-valley-tabs-spaces-debate-2016-8

    Interestingly, it’s the C programmers that are neck and neck, and Go (for some reason) is almost entirely tabs. The rest are dominantly spaces. Python is not included since that would be pointless (you use spaces or you’re wrong).

    Granted, majority does not necessarily mean “right,” but I think it shows that there is a trend to using space indentation.

    In my son’s programming class, the instructor’s opinion was that explaining the difference of two distinct white-space characters to create the same effect was a recipe for trouble. 12-year-olds have a nasty tendency of switching between the tab key and the space-bar on a moment’s whim, so he set the editors to use spaces to avoid a tab/space mix. I imagine the students end up using what they’re used to, which would explain the trend towards spaces with new developers.

    – Jim

  35. Oops, turns out Python was included. And, it looks like a small number actually used tabs? I guess that’s proof that no amount of documentation or requirements will steer a developer to a standard, no matter how global it is. Many will use what they want to use and they will believe they are right to do so.

  36. Absolute, unadulterated nonsense. Tabs are superior to spaces in EVERY single way. Use tabs to indent, spaces to align. Beats me why people that call themselves software developers struggle to grasp such a simple concept.

  37. This article is obviously bullshit and I exclusively use tabs as well. However, that one argument that I keep reading in the comments – you indent with tab and align with space – is actually what fucks up the files. If you mix tabs and space, you inadvertently bind the tab size to your settings. Someone who uses a different tab size will have a fucked up indentation on those alignments. And that is exactly the reason why most guides recommend spaces.

    Linux Kernel developers don’t use retarded alignment, though. That’s why we can safely use the only logical character for indentation – a hard tab – without having to deal with asshats aligning their shitty arrays with fucking spaces.

  38. No, it’s dumb people who fucks up files. Using tabs and spaces for different reasons is not mixing. Reason for spaces is because of dumb people like you can’t realize that you have to use spaces for alignment and only for alignment.
    Aligning shitty arrays helps prevent shitty typos, which can prevent a lot of shitty stuff like root exploits. Which Linux Kernel have a lot of.

Leave a Reply

Your email address will not be published. Required fields are marked *