>I note that this thread is about the amount by which one indents, not
>about whether one indents with space characters or tab characters.
The amount is far more interesting. But I use real spaces because the amount is small enough that there's really no difference between tabbing once and spacing twice. If I used an indent of four or more spaces, I would be more inclined to switch to tabs.

I used to do that. . . then I started writing real code and it got sooooo ugly and unreadable that I just couldn't do it anymore. But, I use vim as my editor so (in the old days) I was stuck to two spaces = two spaces and not an indent.

Someone coding with two spaces should be taken out an horse whipped. ;) just kidding.

09-22-2009

brewbuck

Quote:

Originally Posted by Memloop

I like tabs and always keep my code 80 characters wide at most. Only one problem though: Let's say your company has a rule that code should not be more than 80 characters wide, and you start using tabs that are only 4 characters wide. What happens when someone who likes their tabs to be 8 characters wide opens your file and find that every other line soft wraps or disappears into the marginal?

Then the company policy is incomplete. If you specify that tabs must be used, AND that lines are to be viewed at 80 columns, then you MUST specify the tab width or your specification is incomplete (obviously).

Here, since we do not specify specific tab width, we therefore leave line length unspecified as well.

09-22-2009

Prelude

>then I started writing real code and it got sooooo ugly
>and unreadable that I just couldn't do it anymore
Real code gets out of hand quickly, not because of stylistic choices (assuming those choices are reasonable), but because real code is complicated and always evolving. It takes more work to keep it clean and readable, regardless of how much you indent. ;)

09-22-2009

Kennedy

Quote:

Originally Posted by Prelude

>then I started writing real code and it got sooooo ugly
>and unreadable that I just couldn't do it anymore
Real code gets out of hand quickly, not because of stylistic choices (assuming those choices are reasonable), but because real code is complicated and always evolving. It takes more work to keep it clean and readable, regardless of how much you indent. ;)

True that. One of the other paragraphs in Linus's coding style document (in the Linux code) says that one must keep functions short and to one point. If a function is longer than a screen shot (25 lines), then the function is probably too complicated (except for the case in which the function does IO or has a nasty switch statement handling many cases).

I've tried my very best to adhere to what Linus wrote -- his was a morph of the K&R style -- which they didn't teach at JSU -- we were just kinda left to our own devices about the style of our code.

09-22-2009

whiteflags

I'm pretty sure my editor uses tabs, so I use tabs, still, and always. In fact I expect my code indented whenever I type a brace and press enter. The length usually looks like 4 spaces but it's actually 8 spaces.

09-22-2009

MK27

Quote:

Originally Posted by Kennedy

I follow Linus's lead:

Quote:

Originally Posted by L.T.

Rationale: The whole idea behind indentation is to clearly define where
a block of control starts and ends. Especially when you've been looking
at your screen for 20 straight hours, you'll find it a lot easier to see
how the indentation works if you have large indentations.

Is the fact that you can no longer see straight supposed to be some sort of justification here? I mean I sometimes like marathon sessions but I would not use them as an excuse ("after 5 hits of acid and a case of beer, you'll find it a lot easier to see how the indentation works if you have large indentations"). If you are becoming confused by 4 char tabs, please call it a night.

I use tabs set to 4 characters but I don't care much, 2, 4, or 8 is fine. I switched from 8 to 4 because a block nested 6 or 7 levels deep is so far inset that you must start scrolling horizontally for long lines. I didn't vote because the poll seems flawed to me, insofar as it contrasts "a tab" with any number of spaces.

I'll draw the line at one, tho. 1 character is not indentation.

09-22-2009

brewbuck

Quote:

Originally Posted by MK27

Is the fact that you can no longer see straight supposed to be some sort of justification here? I mean I sometimes like marathon sessions but I would not use them as an excuse ("after 5 hits of acid and a case of beer, you'll find it a lot easier to see how the indentation works if you have large indentations"). If you are becoming confused by 4 char tabs, please call it a night.

I don't understand what the problem is. Kennedy seems to mostly do Linux kernel programming. It is completely appropriate that he would adhere to the Linux kernel coding standards when doing kernel coding, don't you think?

09-22-2009

Yarin

Does no one use 3 spaces?
2 is too few because everything looks more flush than it should. My code tends to have deep nests, and I abhor the horizontal scroll bar, so anything more is overboard. Like, 8. Seriously?
I'll often use the tab key, but only if I've set the IDE to print 3 spaces instead.

Quote:

...but what I do hate are source files that have been mangled up with a mixture of tabs and spaces.

I've found that this is usually due to someone ripping someone else's code, or, because the same file was edited in different editors.

09-22-2009

brewbuck

Quote:

Originally Posted by Yarin

Does no one use 3 spaces?

I used 3 spaces for ten years then switched to 4 spaces for murky reasons.

09-22-2009

MK27

Quote:

Originally Posted by brewbuck

I don't understand what the problem is. Kennedy seems to mostly do Linux kernel programming. It is completely appropriate that he would adhere to the Linux kernel coding standards when doing kernel coding, don't you think?

Yes. I wasn't criticizing Kennedy, I was criticizing Mr. Torvalds. However, the part of the kernel source that I have looked at does seem to be mostly short functions and the nesting never gets past 3 or 4 levels, so maybe he is trying light the way down a certain path, I dunno.

09-22-2009

Yarin

Quote:

Originally Posted by brewbuck

I used 3 spaces for ten years then switched to 4 spaces for murky reasons.

Please, elaborate.

09-23-2009

CornedBee

Seriously, what do I use? I use everything. The whole point of styles is that you stay consistent with existing code.

Single tab for work. Four spaces for Boost. Two spaces for Clang. I've even used the evil GNU indentation style when working on GCC (I still have nightmares about that). What am I supposed to do with this little single-choice poll?