Indentation: Spaces or Tabs?
Moderator: PPS-Leaders
Indentation: Spaces or Tabs?
I want to ask you guys about indentation. As suggested in this paragraph we should use spaces instead of tabs. This is tradition in the development of Orxonox as this was suggested early by Patrick.
However I don't see the problem with tabs. In contrary actually I see some advantages when using tabs.
When indentation is done using tabs, everybody can configure his IDE such that the indentation looks like he likes it the most, since you can configure how much space a tab uses. When you use spaces instead, the image of the code is utterly constant.
Of course this is a advantage if you want the code to look like the same in every editor. On the other side each developer should be able to work with his own preferred indentation in my opinion, which he can configure if we would use tabs.
What do you think? Should we change our policy or are there disadvantages I did not happen to see?
However I don't see the problem with tabs. In contrary actually I see some advantages when using tabs.
When indentation is done using tabs, everybody can configure his IDE such that the indentation looks like he likes it the most, since you can configure how much space a tab uses. When you use spaces instead, the image of the code is utterly constant.
Of course this is a advantage if you want the code to look like the same in every editor. On the other side each developer should be able to work with his own preferred indentation in my opinion, which he can configure if we would use tabs.
What do you think? Should we change our policy or are there disadvantages I did not happen to see?
"I'm Commander Shepard and this is my favorite forum on the internet."
I have a pretty strong opinion about that: Spaces.
The reason really is quite simple: Layout. For my part, when I'm coding, I sometimes make extensive use of spaces to format my codes, even on multiple lines. I especially like to align similar lines of code vertically.
That would get screwed by using tabs.
a few examples:
and from a header file:
It was written with 4 spaces/tab. Using tabs with a size of 4 on the creator machine, this would look like this on another machine with a tab size of 2:
The reason really is quite simple: Layout. For my part, when I'm coding, I sometimes make extensive use of spaces to format my codes, even on multiple lines. I especially like to align similar lines of code vertically.
That would get screwed by using tabs.
a few examples:
Code: Select all
std::string timeString = "===============\n"
"time: " + std::string("x")
+ "===============\n";
Code: Select all
float timeFactor_; //!< doc
bool bPaused_; //!< doc
float timeFactorPauseBackup_; //!< doc
TclBind* tclBind_; //!< doc
TclThreadManager* tclThreadManager_; //!< doc
Shell* shell_; //!< doc
LuaBind* luaBind_; //!< doc
Code: Select all
float timeFactor_; //!< docstring
bool bPaused_; //!< docstring
float timeFactorPauseBackup_; //!< docstring
TclBind* tclBind_; //!< docstring
TclThreadManager* tclThreadManager_; //!< docstring
Shell* shell_; //!< docstring
LuaBind* luaBind_; //!< docstring
Last edited by 1337 on Fri Mar 06, 2009 5:42 pm, edited 3 times in total.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
hm...
for me there are two points:
- if we would use tabs instead of spaces each coder could set his own tabsize (which is extremely practical if you have a 12" display) and there would be no discussion about 2/4 spaces of intendation. additionally it would be more consistent than now (now we have a mix of 2 and 4 spaces intendation)
- the con of using spaces is formatting as reto mentioned before
for me point 1 is more important than point 2
what about the others? x3n, felix, and everyone else ?
for me there are two points:
- if we would use tabs instead of spaces each coder could set his own tabsize (which is extremely practical if you have a 12" display) and there would be no discussion about 2/4 spaces of intendation. additionally it would be more consistent than now (now we have a mix of 2 and 4 spaces intendation)
- the con of using spaces is formatting as reto mentioned before
for me point 1 is more important than point 2
what about the others? x3n, felix, and everyone else ?
There are only 10 types of people in the world: Those who understand binary, and those who don't.
I agree that you could use tabs for the indentation only. But how do you tell your IDE to use spaces for the formatting instead?
And it would still screw my first example from the SignalHandler.
There is another argument I would like to post: If we were to switch now from spaces to tabs, it will result in major trouble:
- Editing existent code gives either ugly results or you'd have to switch to spaces every time.
- Converting ALL code to tabs is not an option because this is a major screw up in the SVN history. I still feel the aftermath of my svn:eol-style "native" intervention. It did resolve lots of issues, I'm sure, but it also screwed the SVN history.
And it would still screw my first example from the SignalHandler.
There is another argument I would like to post: If we were to switch now from spaces to tabs, it will result in major trouble:
- Editing existent code gives either ugly results or you'd have to switch to spaces every time.
- Converting ALL code to tabs is not an option because this is a major screw up in the SVN history. I still feel the aftermath of my svn:eol-style "native" intervention. It did resolve lots of issues, I'm sure, but it also screwed the SVN history.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
I like spaces better, because I like nano, ms notepad, ascii-art, drawing with characters and formatting with whitespaces (that are not tabs).
But imo, we could also dictate to use tabs and to set 1 tab = 4 spaces. Then the code would look the same on every computer and we would only have to hit tab once instead of space 4 times.
But imo, we could also dictate to use tabs and to set 1 tab = 4 spaces. Then the code would look the same on every computer and we would only have to hit tab once instead of space 4 times.
Hmm, I can actually hit tab once and get four spaces...
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
There should be really no tabs in our code except for the external libraries.
Why is that?Mozork wrote: which could be a little problematic since all (or almost all?) code is formatted with spaces...
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
If we were to revert to tabs we would have to convert all spaces (resp. 4 at a time) to tabs, which probably won't work as well as we'd hope to, so either we then go through all the files and verify, reps. correct or we risk that there are quite some inconsistencies/screwed up formatting. (Or so I'd expect...)
Well, of course someone had to verify each file. Only the indentation should be changed, not the formatting.
But I guess the "tab group" wouldn't like to do just that
So my hopes are with a safe conclusion that nothing is going to change...
But I guess the "tab group" wouldn't like to do just that
So my hopes are with a safe conclusion that nothing is going to change...
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
No, its really stupid. The only reason to change to tabs, is that everybody can individually modify the size of the tabs. However in most cases it would totally mess up the layout of the code, if people use different sizes for the tabs.
The example is already given by reto in his first post. This totally defies the benefit of having his own tabs, since the code just sucks.
Making a rule of telling everybody to use tabs = 4 spaces is stupid as well, because this again defies the benefit of being able to choose his own size for the tabs.
Easy example where using tabs would make sense:
I mean.. that would be cool...
So I'm totally for spaces in the end. But I'm glad we discussed it and wasted time on this issue.
The example is already given by reto in his first post. This totally defies the benefit of having his own tabs, since the code just sucks.
Making a rule of telling everybody to use tabs = 4 spaces is stupid as well, because this again defies the benefit of being able to choose his own size for the tabs.
Easy example where using tabs would make sense:
Code: Select all
int x = 0;
int y = 0;
int z = 0;
and with 2 spaces per tab:
int x = 0;
int y = 0;
int z = 0;
So I'm totally for spaces in the end. But I'm glad we discussed it and wasted time on this issue.
"I'm Commander Shepard and this is my favorite forum on the internet."
we could make a compromise, but I gess the effort would not be worth the result.
line beginings: use tabs (then each coder can choose his tabsize)
variable definitions: use spaces
then everybody would be glad and we wouldn't have ugly code
but it would be quite extensive to change all our existing code ^^
line beginings: use tabs (then each coder can choose his tabsize)
variable definitions: use spaces
then everybody would be glad and we wouldn't have ugly code
but it would be quite extensive to change all our existing code ^^
There are only 10 types of people in the world: Those who understand binary, and those who don't.
@Beni: Yeah, I see the benefits of your example. Unfortunately you can always give an almost identical example that doesn't use the same amounts of tabs for each of the lines because for instance the variable names are of different length. Then having different tab size would mess it up eventually.
But enough of this discussion...
But enough of this discussion...
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.
A webcomic of romance, sarcasm, math, and language.
Who is online
Users browsing this forum: No registered users and 1 guest