Tabs vs Spaces
The answer, obviously, is tabs.
- Fewer keystrokes
- Save bytes
- Easier consistency
- Can be adjusted in IDEs
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.
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.
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.
There are no comments on this entry.
There are no trackbacks on this entry.