Skip to content

Tabs vs Spaces

Posted by Nathan Giesbrecht on March 6, 2019 in Uncategorized

The answer, obviously, is tabs.

Reasons:

  • Fewer keystrokes
  • Save bytes
  • Easier consistency
  • Can be adjusted in IDEs

Fewer Keystrokes

Obviously, hitting Tab once requires fewer keystrokes than hitting the Space Bar 2, 3, 4 or 5 times. Not only is this easier on your hands, it’s also easier on your keyboard and could theoretically lengthen the life of your keyboard.

Save bytes

Again, this should be pretty obvious, but a single Tab takes up 1 byte, while spaces require as many bytes as spaces as you’re using for indentation. This is obviously not a huge deal, but it does make Tabs more efficient than Spaces.

Easier Consistency

It’s far easier to accidentally hit the Space Bar 3 times when the rest of the code is using 4 Spaces without noticing it. If you hit an extra Tab or miss one, it’ll be visually very easy to see.

Can be Adjusted in IDEs

Most modern IDE’s allow you to convert Tabs to Spaces, and will save multiple spaces as Tabs. This makes it easier to play well with others while using your preferred indentation, while keeping a shared code-base clean and consistent.

Spread The Love, Share Our Article

  • Delicious
  • Digg
  • Newsvine
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter

Related Posts

There are no related posts on this entry.

Comments

There are no comments on this entry.

Trackbacks

There are no trackbacks on this entry.

Add a Comment

Required

Required

Optional


framework-break