4 ms·
Who actually uses tabs instead of spaces? I'm genuinely curious--one of the first things pretty much any project I've ever been involved in has been the setting
by angersock 12y ago
Who actually uses tabs instead of spaces? I'm genuinely curious--one of the first things pretty much any project I've ever been involved in has been the setting of tabs characters to become spaces, simply because all text editors are retarded in this regard. This is quite strange.
- josegonzalez 12y agoUnsure if trolling or not. It's quite easy to have your editor represent a tab character as "n spaces" - where n is the number of spaces you find pleasing. In fact, I can't recall a serious editor where this isn't the case. What issues have you seen with regards to using tabs?
- angersock 12y agoOften different editors on a project (hell, even between computers for the same user) may display the same file different ways, and you almost always end up with weird mixes of spaces/tabs when indenting things (especially if you're super picky like I can be and really, really care about things lining up). Simply having the editor expand tabs (to whatever people agreed on, usually 4 for C/C++ that I've seen) and save spaces, always, makes life simpler. EDIT: See Grandpa Zawinski's post on same: http://www.jwz.org/doc/tabs-vs-spaces.html http://www.jwz.org/doc/tabs-vs-spaces.html
- dTal 12y agoI hate that Zawinsky post. At the top, he says "I'm trying to avoid espousing my personal religion here, I just thought it would be good to try and explain the various sects." At the bottom, after thoroughly missing the point about semantic indentation, he says "So go forth and untabify!"
- Glyptodon 12y agoI'm not sure if there's an "issue" with tabs, but I have to agree that I pretty much never come across tabs in any of the languages I use regularly and find it jarring when I do so despite the obvious theoretical benefit of flexible tab widths enabling user preference. I can't come up with a particularly good reason for it, but I'm so used to spaces at this point that tabs feel very wrong. If anyone else has a good explanation I'd love to hear it.
- MBlume 12y agoGrabbing some Clojure code because it's nearest to hand. Look here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L226 https://github.com/clojure/clojure/blob/master/src/clj/cloju... I want the bindings being declared within that let to line up with one another. the first one immediately follows "(let [" so I need the rest to be indented six characters past where the let was originally indented. Six, not N times whatever the tab width happens to be in whichever editor someone's looking at the code in. This is the problem with tabs.
- gmjosack 12y agoThe way people solve that is tabs for indentation and spaces for alignment. In my opinion this is a terrible compromise as mixing tabs and spaces is sacrilegious.
- msutherl 12y agoThere is nothing wrong with mixing tabs and spaces. It works great.
- jsmthrowaway 12y agoUntil Python. Then it doesn't.
- markrages 12y agotabs for indent, spaces for alignment works great with Python.
- oelmekki 12y agoProvided everyone use the same tab width :)
- dTal 12y agoNope, works regardless of tabwidth; that's the point. Tabs for indent (these change size with tabwidth), spaces for alignment (these don't change so things stay aligned).
- subsection1h 12y ago> What issues have you seen with regards to using tabs? How does a team adopt a standard regarding line length if their code base uses tabs and the team members specify different tab widths in their editors? In my experience, devs that prefer tabs over spaces have a tendency to be unconcerned about line lengths, and their lines of code can become annoyingly long. For example, the most popular Go project at GitHub[1] is Docker. Docker's code base contains Go files with lines of code that are hundreds of columns wide.[2] Gross. ;-) [1] https://github.com/search?l=Go&q=stars%3A%3E0&type=Repositories https://github.com/search?l=Go&q=stars%3A%3E0&type=Repositor... [2] https://github.com/dotcloud/docker/blob/master/api/client/commands.go#L1483 https://github.com/dotcloud/docker/blob/master/api/client/co...
- nmjohn 12y agoThis is a huge speculation based only on personal observations, but I'd guess people who got started coding in editors where a space was only a space, so I could indent with one keystroke, tab or with 4+, spaces. These days I use spaces, because apparently that what is "correct" these days, but I still press tab. Sublime just turns it into spaces and displays the indent as a tab.
- eximius 12y agoI do. Tabs are universal. Three indentations? Three tabs. The same cannot be said for spaces. You have to agree upon the width and make sure everyone sticks to that width. Now, with tabs, anyone may customize how the width is VIEWED, but the representation on disk is universal.
- cmelbye 12y agoVirtually every Go programmer does, at least.
- pbreit 12y agoGo developers typically use tabs. You should really try not to use the word "retarded" like this.
- Zarel 12y agoMy project, Pokémon Showdown (https://github.com/Zarel/Pokemon-Showdown https://github.com/Zarel/Pokemon-Showdown) uses tabs, although it's not for any religious reasons, it's just what I was used to when I created the project. I suggested changing to spaces when I learned they were more popular, but my most opinionated coder preferred tabs so I kept it at tabs. Tabs and spaces both have their respective advantages and disadvantages. Advantages of tabs: - you can choose your indentation width in most editors, so coders don't have to agree on indentation width (this is really the only major advantage) - most very-basic editors that can't be configured, such as Notepad or the command-line directly, will default to having the tab key insert a tab character, which is easier to press than space N times (it's rare to edit code in such cases, though) - slightly smaller file-size, although this is pretty irrelevant in modern times Advantages of spaces: - certain editors are dumb and will mangle tabs in various ways (for instance, converting "3 tabs for indentation, 9 spaces for alignment" into 5 tabs and 1 space) - most file viewers that won't let you configure tab width (for instance, browsers, which is relevant to viewing code on GitHub) will have tab width set to 8 spaces, which is very awkward - avoids the problem of some people accidentally using tab for alignment and then having alignment be messed up when coders have different tab width settings - certain text fields, such as browser text boxes, will have the tab key focus the next input field instead of inserting a tab character, which makes inserting tab characters difficult sometimes (it's rare to edit code in such cases, though)
- robin_reala 12y agoYou can style tab width in CSS though. If you want GitHub to have smaller tabs add tab-size: 2; to an appropriate selection in your site-specific CSS. I’m sure there are extensions that will do this for you. More info: https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size
- beejiu 12y agoTabs for scope, spaces for alignment.
- imanaccount 12y ago>I'm genuinely curious I find that very hard to believe. It is a holy war that has been raging for longer than many posters here have been alive. Are you also totally unaware that some people use emacs rather than vi? Do you consider it "retarded" that most systems launch vi when you type "vi"?
- rossy 12y agoLinux kernel uses tabs. I'm a fan of kernel-style, so I use it in my personal projects as well. It seems common in C projects, anyway. https://www.kernel.org/doc/Documentation/CodingStyle https://www.kernel.org/doc/Documentation/CodingStyle
- oelmekki 12y agoWhile I use 2 spaces in all my code because that's the winning convention in languages / frameworks I use, I've always felt tabs were a superior option, most notably because everyone can set tab width to what he likes, so you have a standard file with custom look and feel. I set my tab width to 2 chars ; if an other dev prefers to use 4 chars, there is no conflict. The annoying part is that you can't set tab width in browser (afaik), which makes it painful reading code on, say, github, and being displayed an indent as the equivalent of 8 spaces. Browsers have to fix that. So, to answer your question : I do not use tabs, but I would gladly do if offered the possibility.
- WorldWideWayne 12y agoSpaces make zero sense for indentation. Why would you want to use them instead of tabs, which were invented for indentation and make perfectly logical sense (3 indents, 3 tabs and editors can dynamically adjust the width of your tabs). You get none of that logic with spaces.