5 ms·
Why would you want to convert from tabs to spaces?
by Alifatisk 2y ago
Why would you want to convert from tabs to spaces?
- diggan 2y ago> their mostly-Python codebase had always been indented with tabs Tabs VS spaces isn't usually very important, but what's more important is that all the stuff is the same way. So if all the other codebases (in the same language) are using tabs, then make everything (in that language) use tabs. Consistency basically :)
- Alifatisk 2y agoI agree.
- gwbas1c 1y agoI used to agree with that, until I read this article. I would always use the IDE's default and "not care" as long as the code was consistent. The problem with tabs is that they render as different widths in different contexts. For example, Visual Studio shows them as 5 spaces, but Github shows them as 8. Puts me firmly in the spaces camp now.
- diggan 1y ago> I would always use the IDE's default and "not care" as long as the code was consistent. I mean, "just use the IDE's default" isn't really agreeing, unless that's what your entire organization does too, and you all use the same IDE :)
- gwbas1c 1y agoPretty much everywhere I've worked everyone uses the same IDE. When someone doesn't, we make sure they know we aren't going to make too many accommodations for them.
- diggan 1y ago> Pretty much everywhere I've worked everyone uses the same IDE. FWIW, none of the places where I've worked has everyone used the same IDE (or an IDE at all, personally I use nvim so :shrug: ). Fun how the world is different for everyone :)
- InsideOutSanta 1y ago> The problem with tabs is that they render as different widths in different contexts The funny thing is that this is why I prefer them. It means I control how indents render rather than the person who wrote the code.
- mabster 1y agoI would agree, except that only deals with the left hand side of the code. We are also making decisions on the right hand side of the code to deal with lime width as well which only really works if all developers have the same tab size. Nowadays I just chuck format on save on all the code I deal with so I don't have to deal with any of this stuff anymore. If we take this to its longer conclusion though, it would be pretty good if our tooling supporting a difference between the view (using your own preferences) and storage (consistent code for committing to git or whatever).
- DidYaWipe 1y agoWhat? If you have lines that are too wide, you can 1. Change the tab width in your IDE 2. Turn on line-wrapping
- mabster 1y ago1. This problem is introduced by increasing the tab width, so this solution is basically "don't do that". 2. Line wrapping on something like C where you have braces is okay, but not with something like Python where the code now looks wrong. I'm in the spaces camp, but I was musing about this for the tabs camp because wanting to adjust the indentation seems reasonable. (My "favourite" convention was Luajit where the convention was: 2 spaces, until we got to 8 spaces, in which case tab.)
- DidYaWipe 1y agoYep, that's why line-wrapping is #2. I can see why it'd be less acceptable for some languages.
- DidYaWipe 1y agoThis is an oft-repeated and utterly bogus argument. You can simply change how many spaces a tab is in your own IDE. And in decades of programming in IDEs from Borland to Visual C++ (since there were separate 16- and 32-bit versions) to Xcode... I've never seen one default to five spaces. Four spaces is, by far, the most common. People who don't understand tabs are akin to those who don't understand styles: Doomed to laboriously dick around with formatting, and make work for everyone else.
- motorest 1y ago> I used to agree with that, until I read this article. I would always use the IDE's default and "not care" as long as the code was consistent. The problem is that everyone touching the project can and often does have different defaults. If you work on a professional setting, specially in legacy projects, you are bound to touch files where your changes comprise mainly of whitespace changes.
- gwbas1c 1y agoThat's why "clean up tabbing" projects happen.
- ujkiolp 1y ago[flagged]
- deleted 1y ago[deleted]
- mmastrac 2y agoBecause it's the one true way, and tabs are WRONG. Also Vim > Emacs, the new BSG was better than the old BSG, TNG is the best Trek, and all the other hashed-out flamewars of the 90's and 2000's. :)
- evbogue 2y agoThere's a debate about new BSG being better than old BSG?
- mmastrac 2y agoI posit: For every topic of A vs B where A and B are related in some way, no matter how small, there exists an argument C where two people take increasingly opposed positions about which is better.
- HideousKojima 1y agoI actually love the original BSG. And the new one started out strong but the writers clearly didn't have a plan for where they wanted things to go despite the opening credits insisting the Cylons have a plan.
- mixmastamyk 1y agoAgreed. Not to mention the original BSG was strangled in its crib for costing too much. Something a production in the aughts didn't have to worry much about.
- daneel_w 2y agoBecause the latter is universal, and it can always align perfectly. # using tabs with tabsize 4 some_func( eyesore, blah ); some_func( eyesore, blah ); some_func( eyesore, blah );
- SoftTalker 2y agoWell, obviously tabs should always be 8 spaces.
- daneel_w 2y agoNot sure if you're joking since 8 makes the whole problem even worse :)
- Asooka 2y agoWe use 4-wide tabs and in our code style it would be some_func( verylongarg0, verylongarg1 ); Which I feel is the most readable option. If you have to break the args into a vertical list, you want to use the least amount of whitespace before each arg. It's also a bit easier to read with every term starting at a tab break.
- daneel_w 2y agoWith a large set of arguments broken down to multiple lines I prefer to keep them clear of the function name. with_long_func_names( this_scheme, looks_muddled ); long_func_name( tidier, scheme ); But my main gripe with tabs is that no one agrees on the width.
- ooterness 2y agoTo make more money: https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/ https://stackoverflow.blog/2017/06/15/developers-use-spaces-...
- zahlman 1y agoMy best guess: using spaces selects for developers who understand how their editor works (which correlates with higher overall cluefulness), because they'd go insane otherwise.
- y-curious 2y agohttps://youtu.be/oRva7UxGQDw?si=XUvMWQqIF-Uy1gNp https://youtu.be/oRva7UxGQDw?si=XUvMWQqIF-Uy1gNp
- rascul 1y agoThis is the discussion I came here for.
- mcdonje 1y agoBecause they're deranged control freaks who need to convert a single character that is semantically a tab into multiple characters that are an opinionated representation of a tab. Devs: We need to separate concerns and split the view from the model. Also devs: Someone might view the code differently!!1!
- maw 1y agoA codebase that's formatted notgivingashittily is an accessibility issue. It's not just deranged control freakism. Maybe Yelp's codebase was otherwise clean, but aside from golang projects (and the Linux kernel) I've come to associate tabs with unreadable slop code. Maybe your experience is different.
- smrq 1y agoForcing a single opinionated tab width is an accessibility issue -- a real one, not a weird heuristic that boils down to "tab fans can't format". I've read multiple accounts from people who need either very small tab widths (to accommodate unusually large font sizes for eyesight reasons without cascading off the side of the screen), or very large tab widths (to accommodate difficulty in seeing indentation differences, again for eyesight reasons).
- umbra07 1y agoI'm confused. how does handing control of the reading experience over to the reader = accessibility issue? isn't it the other way around? accessibility issues come in many different forms, and you can't accommodate them all yourself.
- thfuran 1y agoWell, you see, it's too accessible, and that's a problem. Or something.
- Defletter 1y agoI've been firmly pro-spaces ever since I discovered there was an everlasting war over this, and it came about primarily over documentation. Say you're writing documentation within a /***/ block, so each line is prefixed by three characters. Now say your documentation includes a code snippet. Or lets say that particular sections of the documentation (such as JavaDoc's @see) are indented so each line always starts after the @see. You end up with documentation indented with spaces because it's the only way to ensure consistency. And if you're doing it with your documentation... why not your code too? However, my conviction has since been tested by Dart which opinionatedly forces you to use two-space indentation. There's no way to disable this and its IDE plugins enforce the style. I just find it so difficult to read, even with Rainbow Brackets. I yearn for Dart to use tabs just so I can configure the tabs to appear as four-space indentation. Or better yet, stop trying to coerce how people write their own code.
- david2ndaccount 1y agoTabs are a control character and have no business being in a text file. Do you use ascii record separator characters too?
- DidYaWipe 1y agoWhat an absurd statement.
- IvyMike 1y agoGalaxy brain: indent using U+001F Unit Separator
- imiric 1y agoNo, but I do use Line Feed and Carriage Return.
- yjftsjthsd-h 1y ago> Do you use ascii record separator characters too? The only reason I don't use them is because nothing supports/expects/shows them. The alternate history where we properly use them is a world where CSV isn't needed and we're better off for it.