9 ms·
The Tabs vs. Spaces war is over, and spaces have emerged victorious
- tabs_or_spaces 1y agoFinally, I've been battling with this for ages!!
- ta8645 1y agoJust define Tab as 1 space, and they can be used interchangeably. Peace in our time.
- patrickmay 1y agoYou are a monster. I would like to buy you a beer.
- tfandango 1y agohe only drinks Tab.
- sidewndr46 1y agoWhy stop there? The tab nihilist would just define the tab to be 0 spaces. Then, tabs do not even matter
- em-bee 1y agothey still would in python.
- IncreasePosts 1y agoNot if they're inside a string
- mjburgess 1y agoThe point of the "tab" option is that there is no consensus on the number of spaces to use -- so by using tab, one uses a single character, and allows the developer to determine screen spacing to their comfort. "Tab" being a live option is a symptom of the war-never-over in absolute spacing degree -- since different people have different eye-sight, eye-strain, etc. constraints, different linguistic familiarities, code-density preferences, and so on.
- whoomp12342 1y agoAnd what say you about reaching a consensus on the number of tabs to use?!?!?!
- g-b-r 1y agoIf someone uses more than one tab per level of indentation he should be forbidden access to editors for life
- whoomp12342 1y agoAnd now you understand my method of driving nit picky code reviewers crazy! bwahahahahahhaha
- boomskats 1y agoDidn't you read the post? The WAR is OVER. End of discussion!!1 (golang converted me to tabs too)
- wslh 1y agoNot OP, but the article ends with the following question: > Is it truly over? ;-)
- smrq 1y ago"The war of accessible vs inaccessible is over; 90% of websites don't use ARIA attributes correctly, so the other 10% ought to give up already." That's how TFA reads to me. Never give up, never surrender.
- o11c 1y agoThere absolutely is a consensus: a hard tab is defined as 8 spaces in numerous standards (obviously this only applies to monospace fonts). The fact that people choose to reject this does not change the reality.
- 1y ago
- phplovesong 1y agoTabs are better, simply because you can view them as you like. Go obviously does this, and Haxe too (with default formatting options, even tho its configurable)
- gte525u 1y agoThis works until someone tries to vertically align something like a table or a line that is wrapped.
- marssaxman 1y agotabs for indentation, spaces for alignment
- skylurk 1y agoMeanwhile, I'm trying to get away from languages where whitespace has semantics.
- PaulDavisThe1st 1y agoIt's not about semantics at all. whitespace has (virtually) no semantics in C or C++, but there are few programmers who would feel comfortable reading such code without the suggestive hinting that indentation provides.
- pepa65 1y agoVery few where you can delete or insert whitespace at will, (even if only in the middle of 'identifiers'). I am fine with a (single) space being an important part of syntax, just don't use more than 1 please.
- fmbb 1y agoOnly a goblin would align code. But if you must you can start with a new line and the right indent.
- jihadjihad 1y agoRob Pike on why Go is indented with tabs [0]: > How wide should the indentation be? 2 spaces? 4? 8? Something else? > By making the indent be a tab, you get to decide the answer to that question and everyone will see code indented as wide (or not) as they prefer. > In short, this is what the tab character is for. 0: https://groups.google.com/g/golang-nuts/c/iHGLTFalb54/m/zqMoq9JRBAAJ https://groups.google.com/g/golang-nuts/c/iHGLTFalb54/m/zqMo...
- throwawayqqq11 1y agoExactly. Indentation != spacing. And thats all the argument i need. I dont understand why people argue with consistent text layout for all-spaces. You can use tabs to indent and spaces to align after that, in most cases.
- lesuorac 1y agoYou use tabs to delimitate tabular data. Unless you're trying to argue that your code is a tsv file then tabs is the wrong thing to use.
- rafram 1y agoYou use line feeds (\n) to instruct your teletype machine to feed in one more line of paper. Unless you're trying to argue that your text editor is a teletype machine, then line feeds are the wrong thing to use.
- lesuorac 1y agoI think most people are pretty amenable to the argument that text editors are teletype machines. Nobody cares that phone calls happen over fiber now instead of telephone lines. So, same should apply to teletype. Nobody is going to care you're reading this over fiber instead of a telephone line. Now, people do care if they're trying to read a csv document and somebody didn't quote their commas within strings and now the values are in the wrong columns which could've been avoided by using tabs to store tabular data.
- personjerry 1y agoWait until you guys hear about fibonacci tab spacing: https://marketplace.visualstudio.com/items?itemName=ewic.fibonacci-tabbing https://marketplace.visualstudio.com/items?itemName=ewic.fib...
- jedberg 1y agoThis is the first I've heard of this, but honestly, I think this would be really good for beginners! Generally, you shouldn't have all that many indents in your function. Using this would be a good visual clue to a beginner that maybe they need to break out their function into multiple functions.
- hotsauceror 1y agoNot that one more opinion in this endless war of opinion will matter, nor will it convince anyone, but I genuinely don't see the issue with "tabs for indentation, spaces for alignment."
- o11c 1y agoEvery repo that tries that ends up broken. I've looked at a lot of them. Also, any use of hard tabs breaks diffs, which should make tabs a non-starter.
- IncreasePosts 1y agoIndentation is alignment
- microflash 1y agoIndentation is columnization.
- IncreasePosts 1y agoColumnization is alignment
- sergiotapia 1y agoJust gimme a `go fmt` or `mix format`. These discussions are so 2007! :)
- cesaref 1y agoI remember these discussions in the 80s...
- taeric 1y agoWithout tab stops, tabs always fall a bit short. I'm now vaguely interested in hate making a programming language that relies on tabs and field/record separators. Just to really embrace the crazy.
- the_mitsuhiko 1y agoThe war is mostly over because regardless of it you use tabs or spaces, the many modern languages use a code formatter and reformat to whatever is common. Languages that go with tabs are also now routinely mixing it with spaces for visual alignment and assume a certain tab width for total visual width enforcement. On the other hand editors often now handle spaces as if they are tabs, even for cursor movement. So well. Both won? I remember a time when people religiously claimed that both tabs need to be the way to indent but also that they have to be 8 spaces visually. I guess at least that war was lost since now even CSS allows you to change the number of visual spaces a hard tab has.
- tinco 1y agoNo one who uses tabs would ever assume a certain tab width for visual alignment. What do you base that slanderous statement on? I've also never heard anyone argue that someone else should configure some different tab width, is there a specific language ecosystem you were in that had these insane takes?
- ben-schaaf 1y agoTo quote the linux kernel style guide: > Tabs are 8 characters, and thus indentations are also 8 characters. Yes, tabs are used for alignment as well. To quote the OpenBSD style guide: > Indentation is an 8 character tab. The GTK source code uses tabs when the number of spaces for indentation >=8. This goes against their coding-style document, but if you don't have tabs set to 8 you'll find the indentation broken. git is the same: although it prescribes tabs if you don't set the width to 8 you'll find broken alignment everywhere.
- throwawayqqq11 1y agoNow let the battle of how much spaces to use begin! Are you a superior 4-spacer or is that too much for your weak IDE on that 4:3 screen?
- chrisweekly 1y agoThe choice isn't (tabs) vs (spaces). It's (tabs && spaces) vs (spaces). In the real world, there will always be spaces, whether used for indentation or not. Using tabs for indentation inevitably leads to a mix of both - which is, objectively, worse for maintenance and consistency.
- PaulDavisThe1st 1y agothe correct rule is: tabs to indent, spaces to align [TAB][TAB][TAB]ShortTypename[SPACE][SPACE]variable_name [TAB][TAB][TAB]LongLongLongTypename[SPACE]variable_name2 ps. the [SPACE] counts above are illustrative, not accurate.
- g-b-r 1y agoExactly, just have your linter error out if there's a tab following a space
- throw-the-towel 1y agoThe correct rule is: you shouldn't align.
- hollerith 1y agoThe code I maintain (Emacs Lisp) follows that rule.
- TZubiri 1y ago
- deleted 1y ago[deleted]
- hackthemack 1y agoIn the 90s, when I used various text editors like Ultraedit, Nedit, Pico, Nano, Vi, and my co-workers used Dreamweaver, Visual C++, Visual Basic, NetBeans I was in the "TABs are superior" camp but only for the initial indention of code blocks. But somewhere along the way, editors added features that let you see invisibles, and let you set up smart tabs so that you could hit tab, but it would interpolate 4 spaces (or whatever you set) into the document, and let you shift+tab back the indention or TAB the indention, but put in spaces. More importantly, the mass of people who all coalesced on using the same editor in the web development sphere, Sublime then Atom then MS Visual Studio Code, has made it easier to just say "set your editor to do this". I have changed my mind to using SPACES now because the editor lets me fake using TABS.
- frizlab 1y agoNavigation is still more painful with spaces than with tabs.
- DrSiemer 1y agoNot if you learn to use the right shortcuts for it (ctrl+arrows, mostly).
- frizlab 1y agoI know the shortcuts. (It’s not ctrl-arrows; ctrl-arrows is to switch Space.) There are still situations where it’s annoying, mostly when navigating the code using the arrow, moving from one location to another using the arrows, I won’t add a key modifier right in the middle of moving the cursor, it just doesn't make sense.
- DrSiemer 1y agoSwitch space? On any Windows OS ctrl-arrows (left and right) move the cursor by word. I don't exactly understand how people work with code or even do text editing without it.
- bbkane 1y agoThe most important thing is consistency. I've become a huge fan of deferring tabs vs. spaces debates to an autoformatter. Set it; forget it; argue about something else. This is most useful when applied ecosystem wide - no one in the Go ecosystem argues about tabs vs spaces, they just run `go fmt` (or more likely their editor is set to do that automatically) and move the #$@% on with life :) Fortunately for me, newer languages tend to include a formatter in the core install/editor tooling - Go, Rust, Gleam, Dart, probably more I'm forgetting... I think Go pioneered this approach and I'm glad others have taken it as well.
- kevin_thibedeau 1y agoAn autoformatter wont touch a tabbed ASCII diagram in the comments,
- arccy 1y agobut the autoformatter will have dictated the choice of space vs tabs for the file in question, an likely also the width of tabs (if any) for alignment. so you just need to follow the convention.
- kevin_thibedeau 1y agoThe whole point of preferring tabs is so you can customize the display. That can't work if tabs are used in fixed format text.
- justinclift 1y agoGo's autoformatter will absolutely screw up existing ascii comments when they randomly decide to change how the formatting works. As found the hard way when one day we updated the version of the Go formatter, and much of our nice comments needed to be redone. Thanks Go formatter team (yes, that's being sarcastic).
- GeorgeTirebiter 1y agoCompletely agree: tabs FTW. I wish I could find the reference, but when dealing with mono-spaced fonts, readability is apparently enhanced with THREE spaces per indent. Now, good computer people hate non powers-of-two, so it's either 1, 2, 4, or 8 spaces!!!! I guess I'm not a good computer person, because my eyes find tab stops at '3 spaces per tab' just right.
- frizlab 1y agoI have used tabs with a three-space width since forever, and it is indeed the better spacing.
- Izkata 1y agoI remember suggesting it as a jokey promise over a decade ago, but got curious and tried it myself. It also seems just right to me, and is what I've used in all my personal projects ever since.
- RGBCube 1y agoI also use 3 spaces myself, because 4 spaces is too damn wide and 2 spaces is a little bit too small. I would use tabs instead, but rustfmt doesn't handle it well at all in some of the nightly options, I've had it use spaces where it should use tabs a lot.
- rossant 1y agoTIL some people use 3 instead of a power of two. I would never had thought of it nor would I have considered it as a reasonable choice. And now I wonder why I would have thought that.
- no-program 1y ago[dead]
- notarobot123 1y agoThe original "tabulator" key was intended to save time and effort aligning text with spaces. With the ubiquity of decent IDEs that objective is unnecessary. I think there is a reasonable argument about the distinct semantic value of tabs but they introduce a concept that the general public think is superfluous when two spaces do the trick. Words can become obsolete if there are other more commonly understood ways of expressing the same thing. This seems similar.
- jl6 1y agoTabs are the modern choice, because you can then configure your editor so that for every tab character, it calls an LLM with the buffer contents up to that point, with instructions to generate an appropriate number of spaces that can then be substituted in. You might be thinking 2, 4, or 8, but the LLM will give you the contextually-correct answer.
- PaulDavisThe1st 1y agoLLM? Emacs has been doing this for decades without any such technology.
- g-b-r 1y agoEmacs can let a butterfly flap her wing, causing momentary pockets of higher-pressure air to form, which act as lenses that deflect incoming cosmic rays, focusing them to strike the LLM's memory; the LLM will then report the appropriate amount of spaces.
- kelseyfrog 1y agoConfigure your ^\s+ width if it's that important?
- purpleidea 1y agoTabs are the preferred, more efficient and more accessible format, and most people know this. Every golang dev loves just having one tap to indent code, and nobody loves the constant repeat rattle of space indented code. Seriously though, tabs let you pick what's visually easier for you to read and I've worked with coworkers that struggle when indentation isn't clear.
- devnullbrain 1y ago>nobody loves the constant repeat rattle of space indented code. It's hard to view your opinion as unbiased when you think this is how people indent with spaces.
- deafpolygon 1y agoI've always been team Tab. I prefer tabs, even in my CSV (actually, TSV) files. But everyone else has decided this for me and I have begrudgingly adopted spaces. Even though Tabs can be set to whatever anyone wants at no switching cost to anyone else. Imagine if Python used actual Tabs.
- konart 1y agoThankfully all the go code I'm working with has tabs.
- TheAceOfHearts 1y agoThis tabs vs spaces nonsense debate has gone on way too long, mostly because people cling on to terrible legacy text editors. Any modern text editor should allow you to write a simple plugin to display tabs or any combination of leading spaces as whatever indentation amount you prefer. Projects should just pick whatever standard is most popular for their given language, and then people can tweak their editors for personal preferences. If you encounter a lot of code on the web then you might consider writing a browser plugin.
- Avshalom 1y agoThe real war is between people constantly aligning and formatting things in their code and people who just want to know which bits are inside the loop.
- _hao 1y agoBullshit. Tabs are the only sane choice and I don't care what anyone else says.
- indycliff 1y agoWhat would an LLM choose... guarantee it's a tab
- jahewson 1y agoTabs are for tables. Change my mind.
- kmbfjr 1y agoNot only that, just wait until they find out there is a vertical tab.
- jfengel 1y agoHow about "neither tabs nor spaces, and set your editor to indent according to the syntax rules of your language"? It doesn't work for indent-sensitive languages like Python, but it works for most of the other major languages.
- owlstuffing 1y agoThis is yet another reason why source code sb stored in parsed AST form.
- exiguus 1y agoThis makes me smile. All the hard work to look up the defaults. Personally I prefer that the CI Workflow enforce whatever is chosen.
- dimava 1y agoEdit: it got fixed, thanks to the author I think with majority of TypeScript projects using Prettier, 2 is more likely to be the default[0] The linked page literally says to ignore it [1] > STOP READING IMMEDIATELY THIS PAGE PROBABLY DOES NOT PERTAIN TO YOU > These are Coding Guidelines for Contributors to TypeScript. This is NOT a prescriptive guideline for the TypeScript community. 4 is a historical thing used as a default for all languages in VSCode [2] [0] https://prettier.io/docs/options#tab-width https://prettier.io/docs/options#tab-width [1] https://github.com/microsoft/TypeScript/wiki/Coding-guidelines#style https://github.com/microsoft/TypeScript/wiki/Coding-guidelin... [2] https://github.com/Microsoft/vscode/issues/41200 https://github.com/Microsoft/vscode/issues/41200 Edit: found the TS style guide at https://github.com/basarat/typescript-book/blob/master/docs/styleguide/styleguide.md#spaces https://github.com/basarat/typescript-book/blob/master/docs/... , it should be the correct link P.S. did send a mail to author hopefully they fix it
- jeffrallen 1y agoThe fact that Go = tabs is just one more good reason to use it, in my book.
- tfandango 1y agoMy favorite things about the Tabs vs. Space war is that you can't even reference it without igniting it.
- ChrisArchitect 1y agoObligatory Silicon Valley HBO clip on Tabs vs Spaces: https://www.youtube.com/watch?v=oRva7UxGQDw https://www.youtube.com/watch?v=oRva7UxGQDw
- Quitschquat 1y agoHow about flexi spaces? Best of both worlds. Set you space size.
- DrSiemer 1y agoMeanwhile, the war on tab width marches on. Back when I got tired of inconsistent tab widths, I simply based my preference on the silly fact that some research showed how developers using two spaced tabs make slightly more money. Among our team we do not enforce a specific width, but respecting the choice of the original author of a project is required. Kind of annoying how LLMs will sometimes randomly decide to change tab width.
- helf 1y ago[dead]
- binary132 1y agoI would humbly suggest that something like “lines of application code ever written”, or better yet, “source code files evaluated since Unix epoch [or “per second” if you prefer]” is probably a better metric. I think in that analysis, you would find that tabs are more than holding their own.
- dusted 1y agoIt's slightly insane that computer programs are still mostly derived from plaintext files.. but what's absolutely insane is that we, the people creating those programs, do so by modifying individual characters in those very same plaintext files.. Yes, text is a good interface medium for exchanging program descriptions between humans and machines.. but it's not a very good medium for storing and exchanging program descriptions from machine to machine, or even human to human.. Humans have opinions, sense of aesthetics, habits, and so on.. some more than others, but still, most people care about at least some part of the.. non-important-to-the-actual-program-compiling stuff, such as casing, indentation, placement of brackes, variable naming and so on.. all stuff that's there for the humans, the compiler don't care what you name your variables.. It's insane that there's no abstraction here.. Just think about how much code we've written to wrangle characters in text files.. formatters, beautifiers, linters, preprocessors, templating systems, lexers, compilers.. It's natural, the amount of development invested in this, and the, honestly, pretty good tooling we have to manipulate those individual characters in files, makes it seem like the only way.. But it shouldn't be.. We should be able to describe programs by typing text, but the text shouldn't be there both for us and for the machine, it should be there only for us, the machine should present text to us, that describes the program, but we should be in control of how that is presented to us, far, far beyond choosing a color scheme in our glorified typewriter emulators. I should be able to tell my programming editor how _I_ want things presented, and that presentation should be a setting in _MY_ editor, not something that has any effect on the program descriptions I'm working with.. Like, the browsers default stylesheet in an alternative world where HTML only described what, and didn't allow the webmaster to overwrite the style. Power to the user. If I wanted variables to be blue and blinking, and I want the function keyword to be a fire emoji, that's on me, that's just presentation.. We shouldn't have directories with plaintext files as our program storage, we should have dedicated program description files, and we should have dedicated tooling to work with them.. We will never have that.
- g-b-r 1y ago> variable naming and so on.. all stuff that's there for the humans, the compiler don't care what you name your variables.. It's insane that there's no abstraction here.. You would have variable names not saved? They don't matter for the future maintenance of the program? You can have most of what you ask right now, the further step most relevant here would be to not indent anything in the saved code; with most languages you're free to do it, and it's feasible to have an editor display it with the indentation you prefer; however it could only make sense if there's no way to have your team agree on an indentation style, there's too many fldownsides with hardly any advantage otherwise. You're always free to have your editor ignore the spaces and display the code the way you prefer, anyhow. But it's probably not always possible to deduce how things should be aligned.
- deleted 1y ago[deleted]
- Brajeshwar 1y agoI’ve also been tinkering around with AI-Coding assistants, having fun and learning many of the missing steps from my career. As someone who loved to write codes that are well formatted, well named, and well organized, the one thing I hate about AI-Coding is the fomattinig mess. So, the first thing I do now is to set `.editorconfig`[1] and add an instruction as part of the process to respect it. btw, it still ignores it at times. Of course, long back, these are also the first things I did so the team can reduce fights and let them choose their own tab-to-space preferences. The other thing was to set up `.gitattributes`[2] early on, specially for those on Windows, to commit the correct attribution when pushing to git. 1. https://editorconfig.org https://editorconfig.org 2. https://git-scm.com/docs/gitattributes https://git-scm.com/docs/gitattributes
- wormius 1y agocommas.
- em-bee 1y agoem-dashes
- wodenokoto 1y agoWhen I started programming in Python I was all like “why do they even allow tabs?” But now I’m like “why did they ever allow spaces?” Space indentation is only nice if your editor has all sorts of weird logic to handle spaces at the beginning of a line as though they where half or a quarter as many tabs. Just use tabs!
- donatj 1y agoHear me out - tabs are better because there is no possibility of invalid indentation state. "Make invalid states unrepresentable" and all that, If your style rule is 4 spaces, you have 3 invalid indentation levels for every valid one. Even if you only use two spaces half your possible indentation levels are invalid. The number of times in my life I've been editing a space-indented file in vim on some sshed server and had to count spaces is way too high.
- burnt-resistor 1y agoDespite the triumphal declaration, bikeshedding flamewars over superficial minutia will continue because that's human nature.
- TZubiri 1y agoI didn't hear no bell
- cowboylowrez 1y agoI would like to congratulate my fellow space using elite on our complete and total victory. I'm also now considering how to use the now empty spot in the ascii chart, I'm thinking we can use tab as an alternative pipe character as I'm tired of hunting for the existing pipe key with every friggin new keyboard I buy.
- hiAndrewQuinn 1y agoOne of the best side effects of a space victory is that Tab Separated Values are a much nicer format than Comma Separated Values if you aren't bothering to use a proper library since \t appears materially much less often than , in most datasets of interest. (Which you should but, you know, just in case.) Just my two cents.
- TrnsltLife 1y agoTabs are better