His site and video only cover the somewhat easy cases, and arguably not perfectly. (For instance, note in the video how at 1:28 how the comment on line 11 doesn't move.)

But it's a step in the right direction. Whenever there's a "holy war" over some thing like this, where everyone claims advantages for their "side" and that the other side is categorically wrong, there's actually probably a modern, technical solution that would appease both, but people are too busy criticizing the other alternatives to think of it.

EvanED wrote:Unfortunately, not everyone does. There's some people in the one-true-style thread I think who think it should be a heretical 2 spaces.

I am one of them. The people I really don't understand are the ones who want to make it three spaces. Apparently, the author of the forum software is one of them, considering how tabs are converted in code boxes here.

Rysto wrote:Can we all agree that anybody who mixes tabs and spaces for indentation will spend an eternity burning in hell, though?

I'd like to. Unfortunately, that consigns far too many innocent people who are horribly abused by their IDEs. The people who *really* need to be, shall we say, doing their part to avoid an infernal ice age, are the ones who thought it would be a good idea to implement this when doing the auto-indentation in the IDE (the most common style I've seen is: 4 spaces; 1 tab; 1 tab and 4 spaces; 2 tabs; etc.), presumably to save a few bytes in the source files or something.

Seriously. We're all relative nobodies, and a bunch of people in this thread understand perfectly well how tabs and spaces are supposed to be combined. Why can't we get an editor which behaves this way by default? (Vim has the nasty habit of using mixed tabs and spaces for alignment, even once you've convinced it to use tabs exclusively for indentation.)

I've actually ended up modifying my style to use "indentation instead of alignment where reasonable", like so:

Somewhat pedantic: "TRUE" and "FALSE" are not C++ keywords. "true" and "false" are.

EvanED wrote:If someone using an 8-character stop has to deal with lines longer than 80 characters, then too bad; he can just set it to 4-character stops, and you're almost no worse off than if you had used spaces in the first place. (In fact, if this person is editing the code, he'd probably need to change settings anyway if you used spaces, lest he start inserting 8 of them where there should only be 4.) At least with tabs you've given him a choice of (1) not worrying about the 80-col limit, (2) saying that his preference for 8-space tabs overrides his preferences for 80-col limits and leaving the settings the same, and (3) saying his preference for 80-col limits overrides his preferences for 8-space tabs and changing to shorter tabs.

OTOH, if this kind of thing is a problem in practice, it might indicate that the code is simply more complex than it ought to be.

That must sound weird coming from the 2-space-indent guy. But I'm not using that as an excuse for more deeply nested code; it just looks right to me. I don't try to claim it's "right". It's just really really hard for me to imagine staring at really wide indents all the time and processing it OK.

masher wrote:The editor I use converts tabs to spaces. I use 3 spaces per tab, and I don't have to work on anybody else's code, so it's alright....

Aaaugh! It's one of THEM!

Arancaytar wrote:Seriously, if the editor takes care of auto-indentation anyway, there is no reason to use a character that doesn't even have a defined width.

You're missing the point. There is a perfectly good reason to use a character that doesn't have a defined width. That reason is: it doesn't have a defined width.

If two people are using this editor, and they want the indentation to be a different amount (and a quick survey of the thread indicates that this is very common), then if the editor has saved tabs to the underlying text file, it only has to adjust the tab stop used for the text control. If it has saved spaces, it has to apply heuristics and convert back and forth (if it doesn't convert both ways from a "reference", then the VCS will get polluted with whitespace changes, and it will also have to know who saved which version of the file in order to know how to convert the spaces). Then we notice that we simplify that code by letting the "reference" use 1 space indent, and actually letting that space be a different character from the spaces used for alignment (so that we don't need the fancy heuristics) - and gee, I wonder what character we'll pick?

Belial wrote:I once had a series of undocumented and nonstandardized subjective experiences that indicated that anecdotal data is biased and unreliable.

Anpheus wrote:I don't understand why people are looking to technology to solve that question, when we've pretty well argued this, and the simplest solution is to change your bad habit and make a good one.

zahlman wrote:I am one of them. The people I really don't understand are the ones who want to make it three spaces. Apparently, the author of the forum software is one of them, considering how tabs are converted in code boxes here.

Three is silly, but the correct answer is 4. This is self-evident.

(I don't have a "good" reason for this, I just think it's hard to blur your eyes and get an overview of the code structure, or scroll quickly for a file looking for a particular pattern, with two. Eight I think quickly forces things too the right much. (Even with two levels of indent, you're using 8 more characters than 4; I tend to use longer function, class, and variable names, so I can eat through those 80 characters quickly. I also like lining up corresponding things on subsequent lines, which often "wastes" more space and also prevents line breaks.) So basically, 2 is too few, 8 is too wide. And 3 is an odd number. Four does have the problem that stuff lines up that I don't like: like the line following either an 'if' or a 'for', depending on whether you leave a space after the keyword, will line up with the contents of the parentheses.)

In both cases, the "something else" is no longer aligned with the x==1. It's this sort of thing that cause a lot of people to say that you shouldn't use tabs because changing the indent size can mess up the code.

This is probably exactly the wrong way to mix tabs and spaces... if someone changes the tab stop to 8, your code now looks like...

Except when I press tab, 4 spaces are inserted. So it's going to be 7 spaces, 0 tabs in any editor. But I still press tab, which is why I'm saying tab... Using only spaces (which is what I do) is no doubt the safest route to go.

headprogrammingczar wrote:I use Eclipse and the first thing I do with an opened file is press ctrl+shift+f. HAHA!

Ditto. The only problem is with read-only files, which eclipse won't even write to in the text buffer. This causes a problem with the java stl, as it contains mixed tabs and spaces everywhere. Sometimes it's a tab, sometimes four spaces, sometimes eight spaces... It's horrible, and the indentation makes no sense for any tab width.

It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Do you realize the amount of bytes you are wasting using spaces in place of tabs!? By a conservative estimate, a mean average of 6 extra useless bytes per line! You could even be doing multi-line conditions and function calls and putting spaces between expressions. What's next, comments?What do you think you are coding in, Visual Basic? It's C, people, it's supposed to be unreadable, we only use tabs because code looks cooler that way, but that's as far as artistic licenses go.

I still have the "my precious cycles! my precious bits!" reflex.I guess its because the counter-argument is terrible: "Oh, because we have big mighty computers, go ahead and waste resources instead of searching for the elegant solution." Have they considered, perhaps, that a lot of little waste stacked up == big waste?

(on-topic "So my vote is in with tabs. But really, who would use an editor that can't auto format according to good indenting practice?")

I'm kind of in the middle about this one. I like the idea of tabs better conceptually, but I often end up wanting to align things a little more precisely, so I usually end up using spaces to avoid mixing the two.