6 ms·
It might have to do with the fact that people who use tabs have stronger principles (indentation should be one char!) and people with strong principles will gen
by FriedrichN 5y ago
It might have to do with the fact that people who use tabs have stronger principles (indentation should be one char!) and people with strong principles will generally have more conflicts with their colleagues and bosses. Usually conflict isn't good for salary negotiations or keeping a job.
That's my 100% unscientific, non-evidence based guess.
- gjulianm 5y agoWhy couldn't it be that the people who use spaces are the ones with stronger principles?
- DocTomoe 5y agoPrinciples are founded in reason. There are good reasons for using tabs. I am still to find a good reason for using spaces.
- _old_dude_ 5y agoIt's easy to forget that programming is an art and being soul crushed by the business side of it. Space bar is our chisel, to craft beautiful codes and reassure our mammal brain that being in the zone make us closest to god
- mlang23 5y agoName a few please. I can only think of garbled alignment when reading a diff of a file which used tabs to indent. And that is not really speaking for tabs.
- DocTomoe 5y ago- semantic coherency: use only one character to signify an indentation level - user preference of UI representation of code: decide for yourself how far a tab indents a codeblock. - less reformatting necessary during refactoring and rewriting - separation of keyboard keys for different functionality Just the first few that come to mind.
- hnedeotes 5y agoWell, the most basic one is that if I prefer that my code blocks indent on 4 visual "spaces", but you prefer that it does on 2, there's no way of representing that with spaces. Tab means, 1 indentation level. How you choose to display that is then a matter of personal preference. So you can have your cake and eat it too. Then if I or someone else needs to de-ident a line you remove 1 char. Plus, if your IDE&mode is worth its salt, hitting tab on an already indented line doesn't do anything, and because it has a simple meaning, hitting tab on a non indented line simply indents it. Of course, if people mix tabs and spaces without understanding them it will be garbled. Or if people just want the cake for themselves, greedy spacers!
- jcelerier 5y agoThat does not work in practice. Consider void foo() { connect(this, action, that, callback); } If the "that, callback);" line was indented with tabs, then any other tab length would make it go at any random place. Thus if you just use tabs your code is only readable with the tab length used for writing it. So instead you can introduce spaces for alignment ; now that you have spaces needed for alignment, why not just use spaces for everything instead of two characters ??
- eMSF 5y agoSo that anyone viewing the code can choose the indentation width according to their own preference? It really can't be that hard to grasp... It can still be argued that it's not worth the trouble, especially with the poor tooling available, but what I can't really understand is how supposedly smart people turn off their inner logic when it comes to such a simple concept.
- jcelerier 5y ago> So that anyone viewing the code can choose the indentation width according to their own preference? It really can't be that hard to grasp... but viewing that code with anything other than the tab length it was written for breaks it ! here are some screenshots: - I wrote the code with ts=4 and it looks as it must look: https://imgur.com/Bgr6Pvl https://imgur.com/Bgr6Pvl - if your editor is configured for two spaces tabs ? broken ! https://imgur.com/oxj2If7 https://imgur.com/oxj2If7 - if your editor is configured for eight spaces tabs ? broken ! https://imgur.com/puCqdL8 https://imgur.com/puCqdL8
- FriedrichN 5y ago> garbled alignment when reading a diff of a file which used tabs to indent I have never experienced this. Tabs are of consistent length, so how can the indentation be garbled?
- Aaargh20318 5y agoTabs are not of consistent length. A tab does not insert X spaces worth of whitespace. A tab moves the cursor to the next tab-stop. There can still be alignment issues if different people choose different tab-stop intervals.
- FriedrichN 5y agoThat's why tabs are used for indentation and not alignment. From col 0 on tabs are consistent.
- CannisterFlux 5y agoThe only case I can think of is when the patch has lines above or below indented with spaces and a modified line with tabs. It looks OK in an editor, but the extra +/-/space from the diff doesn't move the tabbed code, which still is indented to the tab-stop boundary (the tab "absorbs" the diff marker). The space-indented lines are moved 1 to the right by the diff marker, but the code on the tab line now looks to be 1 character too far to the left in the diff. The problem is not the tabs, instead it stems from trying to mix lines indented with tabs and lines indented with spaces.
- Zarel 5y agoSo I don't agree with GP poster that there's no reason to use spaces for indentation, but Rome recently switched to using tabs for accessibility reasons: https://github.com/rome/tools/issues/425 https://github.com/rome/tools/issues/425 (Especially look at the Reddit thread linked from that issue: https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/ https://www.reddit.com/r/javascript/comments/c8drjo/nobody_t... ) (The problem is that people with visual impairment disabilities benefit a lot from being able to customize tab widths.)
- rrrazdan 5y agoHow about all whitespace should be represented by one character to reduce ambiguity. I shouldn't have to figure out if 'l' is 'ell' or 'eye'. Same way I should not have see visually whitespace and wonder if it's tab or space. One visualization, one ascii representation.
- DocTomoe 5y agoI think this is where a lot of the trouble comes from: Tabs are misunderstood as "whitespace", as if code was some sort of DTP by a graphic designer. Code actually is a functional instruction to a machine - semantics matter, and this is where tabs shine: they are unambigious (did the developer decide to indent this this far, or not?) If tabs-as-whitespace trouble you, editors since the 1990s have allowed you to choose/configure other representations of tabs.
- rrrazdan 5y agoI could literally not use any indentation and the machine would still understand me. Not sure how they matter for machines? They do matter for humans though. The reason we write code and structure it the way we do is for human convenience. One of those conveniences is thinking of the layout of code as a visual help to scan and read it. As such I am very much organizing my code like a graphic designer would organize information. Edit: Indentations do matter in some languages and used to signify information. But not in a lot of them. The point still stands that most of the time we are using them for visual purposes not information to the compiler/interpreter.
- dTal 5y agoOnly in the sense that all characters are "for visual purposes". Tabs have a distinct meaning from spaces, and can be rendered however you want (arrows or chevrons, for instance); "whitespace" is a poor term for them.
- rusk 5y agoI thought they were for aligning columns in a table (hence “tab”), rather than indentation? This goes back to typewriters. Sure you could abuse it for indentation and perhaps that became common practice at one point but it doesn’t mean that’s what it’s “for” any more than spaces.
- TomSwirly 5y agoBecause if I use spaces I know exactly how my code will look on every output device, whereas if I put in tabs, I am at the merge of the viewer.
- FriedrichN 5y agoIf you believe very strongly that indentation should be >1 char then that is entirely possible.
- andyxor 5y agoor may be they just like to follow rules, including rules they impose on themselves, and apparently it pays off to not limit oneself with artificial constraints
- alias_neo 5y agoThere's a point I want to clarify. When we say tabs and spaces do we mean using Tab vs Space or not? I use Tab (the key) for indentation, but I have my editors configured to enter spaces and not tabs.
- phist_mcgee 5y agoTab character vs spaces characters is the debate, not the manner in which they are inputted
- alias_neo 5y agoGot it thanks. I suspected as much but I thought it would be insanity to actually use the Space key. My opinion is that it is split based on role/platform. The first half a decade of my career I used tabs, the past half a decade of my career I have used spaces. The difference? First half I was an Android app developer (Java). Now I'm a backend developer (Golang). I also lead the time so I get to make the decision on what the team uses. Hopefully spaces is the right one :D
- masonj188 5y agoGofmt rewrites spaces to tabs
- professoretc 5y agoI'm not familiar with the standard Go coding style. Does it correctly handle the case mentioned above, where you have a function call like connect(option1, option2, option3); That is, will the spaces from the column `connect` starts in be preserved as spaces, or will they be converted to tabs?
- alias_neo 5y agoIndeed it does. Well there you go, I'm full of sh*t because having just checked a few of our Go projects, they're all Tab indented. My editors use tabs when editing Go files, and spaces for others. YAML for example uses spaces. I guess it's so well handled, and transparently so that I hadn't even realised. Also the spaces thing was a joke, I don't tell my team to uses spaces or tabs, I just tell them to follow the Go programming standards/guidelines when writing Go.