nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Question from quiz on spaces #494

Closed GeNiaaz closed 3 years ago

GeNiaaz commented 3 years ago

NOT to ignite an age old debate or anything, but for all intents and purposes, is a 4 spaced tab equivalent to 4 spaces?

image

In the style guide, it was indeed clearly stated to use spaces instead, I do acknowledge that. But should the tab of 4 spaces be used, are they equivalent?

sudogene commented 3 years ago

Do you mean when certain editors help you change tab to use spaces instead? In that case, then it's actually still space as output on the text field, so it's the same as typing spaces.

If you mean that it is still an actual tab (just that the spacing it produces is the same as 4 spaces), then no it is still a tab. Because tab is a different type of character ("\t" as a Java string) that WILL look different on another system depending on how the they read tabs. Even if your tab in your system displays 4 spacing (as one single tab character), it is NOT 4 spaces (actual four space characters).

damithc commented 3 years ago

Do you mean when certain editors help you change tab to use spaces instead? In that case, then it's actually still space as output on the text field, so it's the same as typing spaces.

If you mean that it is still an actual tab (just that the spacing it produces is the same as 4 spaces), then no it is still a tab. Because tab is a different type of character ("\t" as a Java string) that WILL look different on another system depending on how the they read tabs. Even if your tab in your system displays 4 spacing (as one single tab character), it is NOT 4 spaces (actual four space characters).

That's correct. For example, GitHub shows a tab as 8 spaces while Intellij shows the same tab as 4 space. This is one of the main reasons used by the 'spaces instead of tabs' camp (i.e., using spaces will eliminate such discrepancies in how the code will look in different tools)

GeNiaaz commented 3 years ago

Ah I see, okay thanks for clearing it up!