Tab vs. spaces for code indentation

Asked

Viewed 1,260 times

0

Is there any recommendation on what is more appropriate? Tab character (\t) or spaces?

From what I can see, there are usually conventions for language:

  • Ruby: two spaces
  • Delphi: two spaces
  • Python: four spaces
  • Java: tabulation
  • etc.

In the case of Python we have a particularity, indentation is taken into account by the compiler, but it is smart to recognize both spaces and tab.

1 answer

1


I do not know a standard recommendation for identation. Each language uses its own.

What I usually practice is to follow the convention of each language. In general it is more common to use spaces than tabs.

What has always been a good practice for me is at the beginning of a project, involving more than one developer, always write a document of "code standards" that not only defines identation, but also names used in variables, methods, where to use camelCase, where to use Pascalcase, etc.

The first rule of this document is: for any situation that you don’t have something combined, combine.

For me it always worked well to work this way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.