Programmers Dispute on “Tabs vs Spaces”

information-information-board-message-business-card-39604 (1)


There has been an on going debate over the years whether source-code lines should be indented using tab characters or space characters?. Most of the people generally don’t mind reading code that is consistently indented using tabs, or code that is consistently indented using spaces. Complications arise when some of the lines are indented with tabs and others are indented with spaces. In such cases, the code will only display nicely if the reader has the same tab stop settings as the authors and if all the authors used consistent settings.

Tabs vs Spaces:

A) Using tabs


Using Tabs has certain advantages over spaces. Using Tabs gives the reader control over the visual effect. Fewer keystrokes are required to get things aligned. Files are smaller and Tabs take less space. Codes intended with Tabs is easier to copy and paste. You can customize how much indentation should appear. In case your teammate likes 8 column indentation and you prefer 4 columns, you don’t have to do anything. You can set the editor to display 4 column tabs and you don’t need to worry about how many columns your teammates see.

B) Using spaces

Ruby and Python programmers mostly use spaces-for-indentation. Programmers using Python agree that indenting with spaces is important in Python because white space is used for delimiting blocks. The best thing about using spaces is that it makes the code look consistent everywhere. Spaces are Consistently displayed across all display hardware, text viewer/editor software, and user configuration options. Space gives the author control over the visual effect.

C) Mixing Tabs and Spaces

It is easy to mix spaces and tabs. Mixing tabs and spaces can make it difficult to read the code, but you can convert the tabs in most editors and get something close to readable.

Which is More Popular?


Source: Github

According to a research, most of the programmers use spaces to indent.


You can choose Tabs, spaces or choose whatever layout conventions that make sense to you and your team. It doesn’t matter which coding style you pick but what does matter is everyone and you in your team stick with.