Tabs vs Spaces





Our thread on Silicon Valley (TV show)

Programming related films/TV shows

I wonder what he thinks about spacemacs…


One benefit of tabs: If you’re reading highly nested code, you can adjust tab width in your editor to make it easier to read (so it doesn’t wrap as much).


Best of both worlds - just set your editor to use soft tabs :smiley:

Why tabs are evil:


funny thing, watching that episode with my (non-developer) wife, my response to his whole i-like-precision thing was “Wouldn’t you just use spaces then?” which was this actresses next line.

I feel like this show makes my wife understand me a little more :slight_smile:


For those who may have never used a manual typewriter, the semantic meaning of tab is harder to understand. When you physically set a tab stop on the typewriter, then press the tab key the insertion point jumps to the nearest tab stop to the right. Tabs were originally intended for vertical alignment, which really is our goal in code.

That said, I use the tab key, but have vim set to do soft tabs. That’s the best compromise IMHO.


I don’t believe there is a programmer who indent using space key instead of tab key, regardless of which character he uses in code (space or tab).


This programmer does! :slight_smile: Also I think the debate for tabs vs spaces was settled long ago in Elixir; spaces.


@AstonJ Check this out: Elastic tabstops - a better way to indent and align code.

Haven’t used it myself though.


I just put all my code on one line :slight_smile: white space is for wimps.


This is spoiler I answer after I watch this episode :slight_smile:


You really made me think about it very, verrry hard. And I think i understand now, i don’t type like professional typist, and although i use most of my fingers my left hand is on far left side of keyboard, instead being closer to the middle. If I had my hands on keyboard like I should I would not be using tab key so much probably, because space is much more accessible.

Now I understand why people would use space key for indenting.


The thing you should NOT do is to change the tab size, this is what is really really evil. All the issues in the “Tabs are evil” come from this. If tab size is always the same then mixing tabs and spaces is not problematic. Also a lot of things assume that tab size is 8, printers for example.

Setting tab size and using that to indent will guarantee 2 things:

  • While it might look good in your editor, with your settings, the rest of the world will curse as they have to reindent your code to be able to read it.
  • Alignment becomes practically impossible, which is bad as alignment is good

So don’t change tab size. If you don’t like using tabs, with tab size 8, then set so you only use spaces. Please.



LOL. This is so good! #spacesftw


Hmm, I am probably gonna make to switch to spaces then. Just gonna use TAB a shortcut for 8 spaces in my editor. :slight_smile:

Thank you for the insights everyone.


@chrismccord You really hit the spacebar 4 times when defining a function? Seems like the tab key might be a productivity boost for you :laughing:


Not often when your editor correctly maintains indentation levels


Let’s all go back to punching programs in punchcards. Then we didn’t have this problem… :smile:


There was once an article that showed the % of projects on GitHub that used tabs or spaces for different languages. The one for Ruby was like 98% spaces—I’d love for Elixir to have the same % so we can stop bikeshedding!


I think the best solution is to use two spaces. It’s like in Ruby, but it’s a rule from a community guide.