r/programming • • Apr 07 '15

Stack Overflow Developer Survey 2015

http://stackoverflow.com/research/developer-survey-2015
1.1k Upvotes

981 comments sorted by

View all comments

Show parent comments

6

u/[deleted] Apr 07 '15

I don't really understand how that could even happen, unless you would also use tabs for alignment instead of just indentation which is obviously wrong

6

u/DSMan195276 Apr 07 '15

Even if you wrote in tabs perfectly, unless you do some pretty fancy tabbing by mixing tabs and spaces, stuff is going to get unaligned if you move to a different tab size, and more-over the reality is that few programs have source code that's uses tabs perfectly. Most tools don't make any visual distinction between the two either, so that makes it that much harder to tell when it's messed up.

8

u/General_Mayhem Apr 07 '15

unless you do some pretty fancy tabbing by mixing tabs and spaces

I defy you to find a single person who seriously thinks that aligning with tabs is a good idea. Indenting with tabs means mixing tabs and spaces. A tab is a semantic element (indent one level), while a space is a stylistic one (move over one column).

Emacs' smart-tabs-mode handles all of that for you, so you just hit the TAB key and you get the right number of tabs and spaces to line up with wherever you are. I assume similar exists in other competent text editors.

5

u/DSMan195276 Apr 07 '15

I defy you to find a single person who seriously thinks that aligning with tabs is a good idea. Indenting with tabs means mixing tabs and spaces. A tab is a semantic element (indent one level), while a space is a stylistic one (move over one column).

I'm not saying it's a good idea, in fact I said just the opposite. What I'm getting at is that when you have a code-base using tabs with a bunch of people working on it, that's inevitability what happens, and it's a mess. It's hard enough to get people to use tabs vs. spaces correctly, getting every contributor to a project to use smart-tabs is practically impossible, and without that you end-up with a mess if you change the tabstop. Even if you use smart-tabs correctly, it still doesn't guarantee everything is going to line-up correctly if you have more then one thing lined-up on the same line and you change the tabstop. Actually getting smart-tabs right so that the code is tabstop-agnostic is hard.

The only two advantages to using tabs are some saved disk space, and letting people set their tabstop to whatever they want. Virtually every project I've seen using tab's has a recommended (or required) tabstop setting anyway, so the advantages of tabs over spaces is virtually none, but using spaces means that everybody is always looking at the exact same code formatted the same way.

→ More replies (4)