topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday March 18, 2024, 11:04 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Developers who use spaces make more money than those who use tabs  (Read 13624 times)

Edvard

  • Coding Snacks Author
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 3,017
    • View Profile
    • Donate to Member
The title says it all.  I'm not any good at analyzing data, but it's all there for those wishing to take a crack at it:

Do you use tabs or spaces for code indentation?

This is a bit of a “holy war” among software developers; one that’s been the subject of many debates and in-jokes. I use spaces, but I never thought it was particularly important. But today we’re releasing the raw data behind the Stack Overflow 2017 Developer Survey, and some analysis suggests this choice matters more than I expected.



from Stack Overflow blog

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,741
    • View Profile
    • Donate to Member
Obligatory 'Wat?"

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Spaces. Of course.

And each time a "tabbed" file is encountered, every tab is converted to 4 spaces (which would be the follow-up for the 'spacers' among us)!

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,746
    • View Profile
    • Read more about this member.
    • Donate to Member
I was taught to use spaces, and had done so for years. But then a couple of years ago I actually thought about it instead of just dogmatically accepting what I was taught and I came to the conclusion that tabs are better because they give more choice to each individual.

But that's for my code on my projects. If I were doing a group project where the lead maintainer or whatever had coding style guidelines insisting to use spaces, I'd happily use spaces on that project.

It doesn't really matter to me, but it seems ideal to let each person decide their preferences for how much to indent a line with the configurable-width tab rather than force your preference on others by using spaces.

Which is not to imply that people who prefer spaces also do so only because that's what they were taught and never applied critical thought to it. I'm just saying that, at least for now, I'm convinced that using tabs is superior to using spaces. And I'm not aware of any argument or reason why spaces are objectively better than tabs for indentation.

Unless, I suppose, if you count people using spaces making more money as an objective reason spaces are better than tabs.
« Last Edit: June 18, 2017, 04:11 PM by Deozaan »

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,741
    • View Profile
    • Donate to Member
What about people who use auto-indentation?

Or god forbid.....those who don't indent at all *shudders*

mwb1100

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,645
    • View Profile
    • Donate to Member
...those who don't indent at all *shudders*
-Stephen66515 (June 18, 2017, 03:41 PM)

They've done so well for themselves, they don't have to program anymore.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
I was taught to use spaces, and had done so for years. But then a couple of years ago I actually thought about it instead of just dogmatically accepting what I was taught and I came to the conclusion that tabs are better because they give more choice to each individual.

The reason I use spaces is for exactly this reason.  Consistency in code, as you can set the tab to be anything, and get unusual alignment when using tabs.

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Consistency with indentation, no matter in which IDE/editor you open your code in, is really helpful, especially in multi-programmer projects. A tab can be set to whatever default, depending on user preference and software to edit code with. And it is easy to add an accidental tab that won't show up in one piece of software and disrupts indentation in another.

Spaces do not cause such problems in any editor/IDE in whatever (regional) language. And using spaces hardly takes up that much extra storage on disk. My anecdotal experience is that using spaces works better/consistently within whatever versioning system I have tried over time. But that can be just me.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Consistency with indentation, no matter in which IDE/editor you open your code in, is really helpful, especially in multi-programmer projects. A tab can be set to whatever default, depending on user preference and software to edit code with. And it is easy to add an accidental tab that won't show up in one piece of software and disrupts indentation in another.

Spaces do not cause such problems in any editor/IDE in whatever (regional) language. And using spaces hardly takes up that much extra storage on disk. My anecdotal experience is that using spaces works better/consistently within whatever versioning system I have tried over time. But that can be just me.

Nope, I totally agree.  And you bring up a good point - VCS.  With spaces, they are stored consistently.  Some VCS' don't do so well with tabs in my experience. But that might be better now.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,746
    • View Profile
    • Read more about this member.
    • Donate to Member
I came to the conclusion that tabs are better because they give more choice to each individual.

The reason I use spaces is for exactly this reason.  Consistency in code, as you can set the tab to be anything, and get unusual alignment when using tabs.

I'm not sure I follow you. How does using spaces give more choice to each individual? And how does it provide any more consistency in code than tabs do?

One tab-width indentation is always exactly as wide as you've configured it to appear to you. You can't get any more consistent than that.

But once you decide to use spaces, then you have to determine how many spaces to use per indentation block. Some people prefer 2 spaces. Some (most, I think) prefer 4. Some do weird things like 3 or 6 or even 8! And if you're working on a project with someone (or with a library written by someone else) who prefers a different amount of spaces than you, you no longer have consistency. One or both of you needs to compromise and submit to the others' spacing preference.

With tabs you can just use tabs, and configure your IDE to display it how you want it to appear to you. And others can configure how they want it to appear to them. Everybody wins. It's the most accessible and friendly way to get it to look how you want it to look and to allow others the same privilege, even if all parties disagree on what looks best to them.

In summary:
  • Spaces are dictatorial in that they enforce your preference on others, whether they like it or not.
  • Tabs allow each individual the freedom (and responsibility!) to configure it to appear in whichever way pleases them most.

That said, if VCS doesn't properly handle tabs (which hasn't been my experience) then that's not the fault of the tabs. It's the fault of the crappy version control software (or GUI client written for the VCS).

In practice, it doesn't really matter to me which I use. But I'm still of the opinion that tabs are The Better WayTM since they allow the most freedom for everyone involved to view the code how it looks best to them.
« Last Edit: June 21, 2017, 01:22 PM by Deozaan »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #10 on: June 19, 2017, 07:57 AM »
The reason I use spaces is for exactly this reason.  Consistency in code, as you can set the tab to be anything, and get unusual alignment when using tabs.

I'm not sure I follow you. How does using spaces give more choice to each individual? And how does it provide any more consistency in code than tabs do?

I'm saying that tabs can be set to anything, and interpreted differently in each editor.  Spaces give more consistency, and there is no interpretation involved.  And when I say VCS, I mean a Version Control System.

Some VCS' don't do so well with tabs in my experience.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #11 on: June 21, 2017, 10:06 AM »
Using spaces for indentation is stupid.

It's treating a semantic piece of information as visual formatting, and that by itself should be enough to disregard space-formatting.

As Deozaan says, it also means that you (you special snowflake!) is trying to dictate how wide my indents are supposed to be, instead of letting that be up to my editor settings. Editor settings that probably vary depending on whether I'm on a machine with big monitors, or editing in Vim through SSH.

I've never seen indentation be a problem for VCS (any of the modern ones, anyway - pre-subversion days don't count), unless you've got non-team-players that insist on reformatting files instead of sticking to the project standard.

The only place where you might need "consistency" is if you have tabular data represented as code - and that's easily solved by tabs-for-indent, spaces-for-alignment, which is a fine compromise until everybody is using automagical IDEs that don't care about source representation and do on-screen format based on language rules :-)
- carpe noctem

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #12 on: June 21, 2017, 03:11 PM »
Most of the dedicated Python editors I have encountered have settings to strip tabs and indent with the number of spaces the user sets.  In Python the indentation is the only indicator of the beginning and end of blocks.  You don't have curly braces or "begin" and "end" keywords to fall back on.  It can get funky fast if you load someone else's Python source code with hard tabs unless the editor can auto convert the tabs for you.

That is the best reason I have found for insisting on spaces.  As I have gotten older I have gone from tab to 4 spaces to 2 spaces for indentation.  I hate it when source wraps to the next line or kicks in the horizontal scrollbar just because there were a few nested blocks generating a bunch of white space.


f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #13 on: June 21, 2017, 04:33 PM »
I consider languages insisting on indentation for semantics (like Python) to have made a really bad choice in that regard. The intention might have been to make program structure clearer, but it's dictatorial "we know better" that doesn't belong in a language, and it ends up causing more troubles than it solves.

I hate it when source wraps to the next line or kicks in the horizontal scrollbar just because there were a few nested blocks generating a bunch of white space.
You're either using a very, very narrow monitor (for professional development I've been on 120 columns with plenty of real estate for an IDE for 5+ years), or having crazy amounts of indents.

I've been using tab-is-4-spaces indenting for some 15+ years, but I'm considering changing that to oldschool 8, since it forces you to reduce indentation - preferably by splitting your code into shorter, coherent functions.
- carpe noctem

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,466
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #14 on: June 21, 2017, 05:15 PM »
I consider languages insisting on indentation for semantics (like Python) to have made a really bad choice in that regard.

^ Pretty much this.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #15 on: June 21, 2017, 07:55 PM »
As Deozaan says, it also means that you (you special snowflake!) is trying to dictate how wide my indents are supposed to be, instead of letting that be up to my editor settings. Editor settings that probably vary depending on whether I'm on a machine with big monitors, or editing in Vim through SSH.

Not really.  If that's what the team decides on, then that's what the team does as a rule.  And when others come into the team, they adhere to the standard.  Right?

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #16 on: June 22, 2017, 02:27 AM »
As Deozaan says, it also means that you (you special snowflake!) is trying to dictate how wide my indents are supposed to be, instead of letting that be up to my editor settings. Editor settings that probably vary depending on whether I'm on a machine with big monitors, or editing in Vim through SSH.
Not really.  If that's what the team decides on, then that's what the team does as a rule.  And when others come into the team, they adhere to the standard.  Right?
It sucks if the team has made the misguided decision to use spaces, but yes.
- carpe noctem

anandcoral

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 777
    • View Profile
    • Free Portable Apps
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #17 on: June 22, 2017, 06:28 AM »
It is personal choice.

I use tab with 4 character setting. The code looks wider on other text file viewer because of default 8 characters. One of our developer uses 2 character for tab and also some time space-bar. His/her code looks awful on my editor and I have run re-indent. Still he/she is happy with his/her style. So it is a personal choice.

Regards,

Anand

Tuxman

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,466
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #18 on: June 22, 2017, 06:33 AM »
OpenBSD uses 8 spaces which might or might not improve the code legibility (thus: security).

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #19 on: June 22, 2017, 09:18 AM »
I consider languages insisting on indentation for semantics (like Python) to have made a really bad choice in that regard. The intention might have been to make program structure clearer, but it's dictatorial "we know better" that doesn't belong in a language, and it ends up causing more troubles than it solves.

I don't do much with Python.  However it does seem much more natural to type a block by hitting Enter, then Tab rather than holding down the shift key and hitting a curly brace.  At the end of the block you hit backspace to back off the indentation rather than again holding down the shift key and hitting another curly brace.  I didn't find it all that problematic when using an editor that knows Python.


You're either using a very, very narrow monitor (for professional development I've been on 120 columns with plenty of real estate for an IDE for 5+ years), or having crazy amounts of indents.

I guess you don't use end of line comments much.

I've been using tab-is-4-spaces indenting for some 15+ years, but I'm considering changing that to oldschool 8, since it forces you to reduce indentation - preferably by splitting your code into shorter, coherent functions.

So use an editor that has a hard tab/spaces option.  I don't get the controversy.  But for people who may type in the < 30 wps range hitting shift brace combinations is distracting and causes a lot of lint since it is easy to get a bracket when you want a brace.  Also I notice many IDEs, at least in free tools, lack a reformatting indentation parser(such as Tidy.)  When I used Delphi 5 I found it liberating to just type in the code all messy and hit the function key for Delforex to indent and capitalize according to rules etc..  If everything lined up chances were good I did not have any typos.




KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,741
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #20 on: June 22, 2017, 03:38 PM »
You can't just assume somebodies indentation preferences...jeez.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #21 on: June 22, 2017, 03:55 PM »
I don't do much with Python.  However it does seem much more natural to type a block by hitting Enter, then Tab rather than holding down the shift key and hitting a curly brace.  At the end of the block you hit backspace to back off the indentation rather than again holding down the shift key and hitting another curly brace.  I didn't find it all that problematic when using an editor that knows Python.
I don't find adding braces is much bother, and it removes ambiguity - if a language uses indentation for semantic purposes, you run a higher risk of stupid bugs. Especially if you copy/paste snippets of code from the intarwebs, and who doesn't these days? :-)

You're either using a very, very narrow monitor (for professional development I've been on 120 columns with plenty of real estate for an IDE for 5+ years), or having crazy amounts of indents.
I guess you don't use end of line comments much.
Indeed, I don't.

I find that when I use proper variable and function names - which requires extracting well-defined, single-purpose functions - I don't need end-of-line quotes for anything. The code reads pretty naturally, and when I need comments, it's usually a larger block describing why somethign is done in a special way, performance considerations, external API/service quirks, whatever.

So use an editor that has a hard tab/spaces option.  I don't get the controversy.  But for people who may type in the < 30 wps range hitting shift brace combinations is distracting and causes a lot of lint since it is easy to get a bracket when you want a brace.  Also I notice many IDEs, at least in free tools, lack a reformatting indentation parser(such as Tidy.)  When I used Delphi 5 I found it liberating to just type in the code all messy and hit the function key for Delforex to indent and capitalize according to rules etc..  If everything lined up chances were good I did not have any typos.
The controversy is a people thing, and it's already mentioned above. Tabs means flexibilty, spaces means people shoving their preferred indentation size down your throat.
- carpe noctem

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #22 on: June 22, 2017, 04:27 PM »
I find myself in general agreement with f0dder.

  • I prefer tabs over spaces.
  • If the codebase has already adopted spaces, consistency is more important so you have to use spaces.
  • I feel like us tab folks have lost the battle.
  • The idea of using pure indents instead of braces was a terrible decision by python designer.  Better would have been redundant use of brace and indent.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #23 on: June 23, 2017, 07:13 AM »
I don't do much with Python.  However it does seem much more natural to type a block by hitting Enter, then Tab rather than holding down the shift key and hitting a curly brace.  At the end of the block you hit backspace to back off the indentation rather than again holding down the shift key and hitting another curly brace.  I didn't find it all that problematic when using an editor that knows Python.
I don't find adding braces is much bother, and it removes ambiguity - if a language uses indentation for semantic purposes, you run a higher risk of stupid bugs.
I tried Python back in the early 90s.  I had the same feeling about the idea of using indentation to denote blocks.  That's why I abandoned my investigation of the language.  Then in the 2000s I took another look at it.  It didn't seem so hairy when using the right tools.  It is not all that different and likely much less restrictive that using a SmallTalk sandbox.  I can remember not liking AutoIt also because it used that old function style with the commas instead of parens.  Now when I do AHK it's not such a big deal.  Although I use the newer style function syntax unless the old function makes something easier or provides more information.

I guess you don't use end of line comments much.

Indeed, I don't.

I find that when I use proper variable and function names - which requires extracting well-defined, single-purpose functions - I don't need end-of-line quotes for anything. The code reads pretty naturally, and when I need comments, it's usually a larger block describing why somethign is done in a special way, performance considerations, external API/service quirks, whatever.

As the man said, it's a personal preference.  I started off with hard tabs then 4 spaces to indent.  It depends on the programming language.  In AHK I like to use 2 spaces for indenting.  I don't see the advantage of a lot of empty space on the page.


So use an editor that has a hard tab/spaces option.  I don't get the controversy.  But for people who may type in the < 30 wps range hitting shift brace combinations is distracting and causes a lot of lint since it is easy to get a bracket when you want a brace.  Also I notice many IDEs, at least in free tools, lack a reformatting indentation parser(such as Tidy.)  When I used Delphi 5 I found it liberating to just type in the code all messy and hit the function key for Delforex to indent and capitalize according to rules etc..  If everything lined up chances were good I did not have any typos.

The controversy is a people thing, and it's already mentioned above. Tabs means flexibilty, spaces means people shoving their preferred indentation size down your throat.
The Python editors I've used automatically filter the input and detect the indentation levels, adjusting the number of spaces to what you are using.  Hardly a gagging operation to edit the source.




MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Developers who use spaces make more money than those who use tabs
« Reply #24 on: June 23, 2017, 07:15 AM »
btw was it mentioned anywhere how much $/space they are paying?  I can crank up the autorepeat rate and hold down the space bar with the best of 'em!   :)