Eclipse is very nice, but :(...

Jacob Fugal lukfugl at gmail.com
Mon Jun 19 17:23:13 MDT 2006


My main reason for prefering whitespace over tabs is for cases when
tabs are used for justification that is dependent on the tabwidth.
Examples:

* A list of #defines in C, where values are justified into a column

    #define CAL_JANUARY   1
    #define CAL_FEBRUARY  2
    #define CAL_MARCH     3
    #define CAL_APRIL     4
    #define CAL_MAY       5
    ...

if tabs are used to do the justification, the column breaks up when
the tab width is changed.

* Some shops/clients/projects want function arguments, if wrapped, to
be in a column with the first parameter coming right after the opening
parenthesis of the call[1], e.g.:

    result = someLongFunction(param1,
                              param2,
                              param3,
                              ...
                              paramN)

If tabs are used for that justification, changing the tab width breaks
the column.

* Wrapping conditions in an if statement:

    if (condition1 &&
        condition2 &&
        (condition3 || condition4)) {
       ...
    }

This one is usually fine, since spaces are generally used anyways due
to the justification being less than a tab stop, but if the tab stop
is set to two, and the justification performed using tabs... well, you
know the drill.

These sorts of cases require using spaces instead of tabs if you want
consistent justification. We can still use tabs for logical
indentation (scope and/or control structures), but that's about it.

Regarding the argument about source file size: does it matter[2]? I
suspect that each line has at least 14 bytes (on average) of
non-whitespace characters per line of code. So even if we want to keep
our shift width at 8 columns, converting from tabs to spaces will at
worst double our filesize, and then only if we have an average
indentation level of 2 tabs *per line*. Since anyone using spaces
instead of tabs is probably using a shiftwidth of 4 or less, and most
programs will have an average indentation below 2 tabs per line, I'd
guess that using tabs instead of spaces only saves a maximum of 20% in
your file size. And if you *really* care about file size, what about
all those blank lines and comments and descriptive_variable_names that
are eating up bytes?

Jacob Fugal

[1] I don't advocate this style, but I've seen it, and seen the
breakage caused by using tabs for justification while using it.

[2] When you're talking about CSS/HTML/JavaScript, et al, this is
indeed another story, since 20% increase in bandwidth is much more
significant than a 20% increase in the source code that takes up about
1% of your multi-gigabyte hard drive. That and HTML does tend to have
a lot more levels of indentation...
[2]



More information about the PLUG mailing list