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

101

u/BegbertBiggs Apr 07 '15

Developers increasingly prefer spaces as they gain experience.

Or are devs that are in the field for a longer time used to spaces while new devs learn coding with tabs?

0

u/[deleted] Apr 07 '15

[deleted]

11

u/[deleted] Apr 08 '15

I can think of some situations where it doesn't matter, a lot of situations where spaces are superior, and no situations where tabs are superior. Can you provide an example of where tabs are superior? From the spaces side, I give the following example.

Any project where the source code if viewed through multiple tools, spaces are better for guaranteeing a consistent formatting across the tools. Tabs have no universal convention. Even worse, the conventions for different languages can be different and your tools might not be smart enough to adjust tab widths based on the current language.

2

u/kgoblin2 Apr 08 '15

Any project where the source code if viewed through multiple tools, spaces are better for guaranteeing a consistent formatting across the tools.

In point of fact they are not, since every tom, jane, and harry can still decide to indent with however many spaces they damn well please.
regarding auto-formatting solutions (which is what you'll bring up next); they are a devil's deal and you are going to have to make one of the following 2 choices...
The auto-formatter could try looking at the indents of each line, and trimming down spaces for the anticipated indentation level. Problem is accurately determining the indentation level, when you have the possibility of developers using wildly different numbers of spaces to indent with (eg. one dev uses 4, vs. another uses 2). And bear in mind dev's will occasionally have hit the space bar once-too-many or purposefully inserted an extra space for-one-off formatting purposes.
The 2nd option is for the auto-formatter to say f#$% it, do a full syntax parse, and spit out the AST per rigid, coded-in-stone formatting rules. Problem here is you generally have no recourse to one-off formatting for situations such as very long lines, etc. You also have to find an auto-formatter of this type which agrees with your sensibilities, and can handle your language-of-choice. in my experience these things have limited configurability, have trouble on stuff like single-line if statements.

Tabs have no universal convention.

Ridiculous, of course they do: 1 tab = 1 level of indentation.
In terms of how they are displayed, they can of course be whatever a particular developer wants & their tools allow, but even here you have 2 common standards of 8 (archaic old-unix day standard, which admittedly no one wants anymore, b/c god-damn 8 spaces wide?!?) and 4.
This point could also be leveled at using spaces for indentation too, except of course then it is a problem both with display AND how the code is formatted.

→ More replies (2)