Tabs vs Spaces

Thoughts?

:lol:

Our thread on Silicon Valley (TV show)

9 Likes

I wonder what he thinks about spacemacs…

4 Likes

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).

4 Likes

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

Why tabs are evil: https://www.emacswiki.org/emacs/TabsAreEvil

2 Likes

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:

4 Likes

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.

7 Likes

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).

3 Likes

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

10 Likes

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

Haven’t used it myself though.

1 Like

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

9 Likes

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

1 Like

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.

3 Likes

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.

Robert

7 Likes

LOL. This is so good! #spacesftw

2 Likes

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.

3 Likes

@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:

1 Like

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:

3 Likes

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!

2 Likes

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

2 Likes