Author Topic: Tabs Versus Spaces  (Read 7552 times)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Tabs Versus Spaces
« on: July 14, 2017, 09:11:51 PM »
Tabs versus Spaces

The great programming holy war

So, what are the stats on tabs versus spaces? Turns out, someone has analysed this for GitHub repositories, and broke down the result by language:
Tabs or Spaces

There is quite a variation between languages. For spaces, they also broke down how many spaces are used for indentation.


To add some more data, and a bit of humour to this:
Developers Who Use Spaces Make More Money Than Those Who Use Tabs

There was some investigation into the data to try and find confounding factors. The main article comes up empty, though some of the comments are quite good. Of particular note was the graph in the comments that mentions the two salary peaks for the developers who use spaces. I could see that being really easy to miss.


Finally, there's this YouTube video:
Tabs versus Spaces
 :P

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Re: Tabs Versus Spaces
« Reply #1 on: July 15, 2017, 12:04:38 PM »
What about tabs that get converted to spaces?
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Tabs Versus Spaces
« Reply #2 on: July 15, 2017, 01:47:45 PM »
What about those crazies that use neither tabs or spaces, preferring to push out spaggetti code quickly and hope that they never have to touch the code again? Do they make the most money of all?
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Tabs Versus Spaces
« Reply #3 on: July 15, 2017, 09:17:56 PM »
Quote
What about tabs that get converted to spaces?
Mind blown :o

Quote
What about those crazies that use neither tabs or spaces, preferring to push out spaggetti code quickly and hope that they never have to touch the code again? Do they make the most money of all?
Clearly. Or not clearly. That's why they have the code obfuscation contests. ;)

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Tabs Versus Spaces
« Reply #4 on: July 18, 2017, 10:59:31 AM »
Tabs.

If you use spaces you're wrong.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Re: Tabs Versus Spaces
« Reply #5 on: July 19, 2017, 07:05:29 AM »
I just press the tab key, let the IDE figure out how to interpret based on its default settings, and never look back.

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Re: Tabs Versus Spaces
« Reply #6 on: July 19, 2017, 01:50:31 PM »
I prefer 2 spaces. Tabs are just bad, their size is hardly ever consistent between editors even with the same monospace font.

Offline White Claw

  • Hero Member
  • *****
  • Posts: 854
Re: Tabs Versus Spaces
« Reply #7 on: July 19, 2017, 08:37:33 PM »
"Back in my day" we ended up using Spaces because Tabs would come out as different sizes depending on the printer you used...which could cause your code to go over 80 columns, subsequently not printing out your entire line of code. A tab could look like "five spaces" to a printer, but maybe only looked like "three spaces" on your computer screen.

Although now (as someone else mentioned above) I just let the IDE do it's thing...which ultimately means (for me) that it auto fills the spaces to indent properly. So there goes the argument "why press space space space space, when you can just press Tab once"...I do neither.

I think my favorite quote I stumbled upon while reading about "space vs. tab" is:

Quote
In theory, practice and theory are the same. In practice, they are not.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Tabs Versus Spaces
« Reply #8 on: July 20, 2017, 12:33:02 AM »
I love that quote too. So awesome.


My main complaint about the tabs versus spaces debate, is that it's a global editor setting, but a per project decision. I don't want to change global editor settings when switching between projects.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Tabs Versus Spaces
« Reply #9 on: July 21, 2017, 06:52:49 AM »
I just got used to tabs (visual studio handles them really well) but spaces are fine too. I just hate how easy it is to miss spaces and then you end up with blocks of code that don't line up properly.

Offline lhark

  • Newbie
  • *
  • Posts: 11
Re: Tabs Versus Spaces
« Reply #10 on: July 25, 2017, 07:28:04 PM »
Also, some editors (for example, vim, not to name it :) allow you to display tabs, which sometimes reveals some dirty indentation (yes I'm looking at you xterm).

As for tabs vs space, for me it depends on the language: C, C++ and Java should be indented with tabs, but I would never put tabs in a python program.

That was my 0.02CAD :)

Offline lordpalandus

  • Banned
  • Hero Member
  • *****
  • Posts: 825
Re: Tabs Versus Spaces
« Reply #11 on: July 26, 2017, 12:12:28 AM »
Us Canadians don't have pennies anymore :P

(end thread hijack)
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Tabs Versus Spaces
« Reply #12 on: July 26, 2017, 03:55:06 AM »
I generally switch on showing whitespace in my editors. You can do it in Notepad++, and Geany. Very useful for keeping things consistent. Mismatched whitespace stands out like a sore thumb, and you just can't resist fixing it.


Lordpalandus, I think most countries these days don't use currency with denominations that small. Why is it, one of the richest countries in the world, has to count pennies?

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Tabs Versus Spaces
« Reply #13 on: July 26, 2017, 10:49:51 AM »
I wish we'd get rid of pennies. They cost more to make than they're worth. But alas, the Zinc industry lobbies in washington. Zinc lobbyists... I want to drown myself.