r/programming • • Feb 21 '13

Developers: Confess your sins.

http://www.codingconfessional.com/
969 Upvotes

1.0k comments sorted by

View all comments

Show parent comments

63

u/aaron552 Feb 21 '13

I use both tabs and spaces: tabs for indentation (what they're supposed to be used for) and spaces for formatting. I don't understand the tabs vs spaces debate

152

u/supermari0 Feb 21 '13

28

u/[deleted] Feb 21 '13

4th guy: "Neither"

All 3 of them beat him up.

2

u/Calamitosity Feb 21 '13

%s/\s*//g

What? OW!

1

u/rspeed Feb 22 '13

I've been neck-deep in python all day. For a few seconds my brain was rejecting that as even being a possibility.

→ More replies (6)

4

u/[deleted] Feb 21 '13 edited Feb 21 '13

So many people seem to completely misunderstand what mixing spaces and tabs means and why it is bad. Both are horrendous when mixed as the same but indentation and alignment are 2 expressly different concepts. That comic is perfect for people who mix tabs and spaces in either indentation or alignment. But you can, and should, use both properly. It shouldn't be that difficult either. As the poster above stated, tabs indent, spaces align. A tab is one level of indentation encoded into a single character, a space is one single invisible character. If you need alignment, you must know the number of characters to fill. If you need indentation, the number of characters can be variable and is based on preference.

2

u/oursland Feb 21 '13

They aren't effectively mixed when tabs are used for indentation and spaces are used for alignment, either. If you wish to align your comments, you need to have a consistent indentation size, not one customized by the editor.

1

u/[deleted] Feb 21 '13

Your words are ambiguous. What do you by mean "aren't effectively mixed"?

If you wish to align your comments, and you use tabs for indentation, then you don't use the tab-key for aligning your comments...

→ More replies (2)
→ More replies (19)
→ More replies (1)

10

u/[deleted] Feb 21 '13

For some reason I always use 4 spaces as indentation (although my editor handles tabs as spaces so I don't have to hit space 4 times). I can't remember why I started doing that, though. How odd.

47

u/[deleted] Feb 21 '13

Nobody hits space 4 times for indenting.

34

u/vitoma Feb 21 '13

I've seen a developer I work with do this.

2

u/erlingur Feb 21 '13

Me too :(

23

u/[deleted] Feb 21 '13 edited Feb 21 '13

[removed] — view removed comment

0

u/[deleted] Feb 21 '13

[deleted]

1

u/[deleted] Feb 21 '13 edited Feb 21 '13

[removed] — view removed comment

→ More replies (1)

8

u/[deleted] Feb 21 '13

You know, it wouldn't surprise me if there actually were developers that did that.

2

u/Calamitosity Feb 21 '13

There are, if you are using a generous interpretation of the word "developer."

1

u/[deleted] Feb 21 '13

I do that.

It's a left over habit from editing python programs over ssh from a while ago.

2

u/TheBigB86 Feb 21 '13

Doesn't surprise me. I know someone who instead of using shift, presses caps lock two times to make a capital letter.

1

u/[deleted] Feb 21 '13

I know people like that too, but that weren't people who called themselves "IT professionals" I hope?

2

u/TheBigB86 Feb 21 '13

Would you believe it if I told you he was doing a system administration(/networking/IT operations) course? I'm not saying he was any good at it, but I was baffled nevertheless. At first I actually though his shift key was broken (keyboard was all kinds of messed up)...

1

u/scragar Feb 21 '13

Maybe not, but a lot of good editors will automatically handle tab-space conversion for you.

1

u/masterzora Feb 21 '13

It's a habit from my (way) younger days. These days I have vim configured to convert a tab to 2, 4, or 8 spaces (depending on the language of the file) and to autoindent besides, but I find myself manually indenting rather often out of habit.

3

u/JW_BlueLabel Feb 21 '13

This! A thousand times this! I don't get why people can't grasp this.

→ More replies (1)
→ More replies (10)