Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The reason the tabs vs spaces debate is silly

Name: Anonymous 2017-02-27 14:16

is because spaces are vastly superior. And I'm not sure how so many people were convinced otherwise. The biggest issue with using tabs is that people tend to want different tab widths for code versus other scenarios, like tab delimited data files for example. I would want 4 for the former and 8 for the latter. Changing it based on file type still leaves you with some bad scenarios.

And the reasons idiots use tabs are horrible.
-Tabs create smaller file sizes. Do you also use smaller variable names? This one is nonsense.
-Tabs allow you to control the indentation on your end. You don't get to decide what the code looks like that someone else wrote. I cringe when I see an opening brace on a separate line, but there's nothing you can do about it.

Also, if you're using an editor that shows whitespace, spaces look way better than tabs. Please stop using tabs.

Name: Anonymous 2017-02-27 15:23

No, that's wrong. If we're talking about generic curly brace syntax, then there should only be tabs between the end of the newline character until the first non-whitespace character. If you you follow these guidelines, then your spacing will be correct no matter the tabwidth of the editor. Additionally, one logical source line should map to one physical line in the source file. There is no need to break a long line of code at the 80-character mark so that it wraps. Editors and IDEs have widely variable widths, so it is up to the reader of the code to make a long line wrap as he pleases.

If we follow these guidelines, we have reduced the most popular indentation styles down to a pair: the style in which a brace is placed on the newline (Allman-type) and the style in which it is not (K&R-type). Because a block is its own statement, it should be placed on a newline; indeed, it doesn't make sense to place the opening brace before a newline. By a similar argument, the closing brace should be placed at the end of a line. We can also place multiple opening or closing braces on the same line, which we should have been doing anyway.

Here is a contrived example of a snippet of a C source file:

int someArray[3][4] =
{{ 1, 2, 3, 4 },
{5, 6, 7, 8},
{9, 10, 11, 12}};
// ...
int quux;
// ...
int foo(int bar, int baz, char *baz)
{int q = bar * baz / quux;
while (1)
{int r = 0;
for (int i = 0; i < q; j++)
{r += *(baz + i);}
return r * someArray[bar % 3][baz % 4];}}
// ...


With a saner syntax like that of Python, we could just use tabs and newlines to define the block structure. But since our other popular languages are still littered with curly braces, the best we can do is to tidy them up so that the source flows neatly over linebreaks.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List