This evening whilst setting up ESLint I was asked the question of which I preferred, tabs or spaces and instantly I thought of this:
Tabs versus Spaces from HBO’s Silicon Valley Season 3 Episode 6.
What is it all about?
When writing code there are times when the code needs to be indented (e.g. for visual purposes to make it easier to read). This leads to either the space key being pressed or the tab key being pressed. As you can see in the below image (from my BlackJack JavaScript) indentation makes reading the code easier:
Personally I don’t think I have a preference yet but it did raise the question, “Are tabs better than spaces or are spaces better than tabs?” and the second question of “Is tabs versus spaces a thing?“. I’ll start with the second question first as it is easier to answer.
Is tabs versus spaces a thing?
Yes, it is. Silicon Valley S3 E6 didn’t make it up, their are some lengthy debates over which method (tab or spacing) is the best for coding. The debate is not new, with some sources claiming it goes back to the mid 90s (if not earlier).
Is one better than the other?
Tougher to answer. StackOverFlow ‘s 2017 survey indicated that developers using the space key potentially earned more money and StackExchange had a lengthy discussion on the subject. However, most of my reading leads me to the conclusion that:
- A space is always a space
- A tab can be defined in an IDE and may not look the same in every IDE
- It is mainly down to personal preference however if you are working in a team, or editing existing code then which ever preference is already in use should be used (i.e. be consistent throughout the code/program).
I’m now going to concentrate more on my typing to see which (tabs or spaces) I naturally side with.
2 thoughts on “Tabs versus Spaces”
Comments are closed.