var a_variable = 1;
var another_variable = 2;
var yet_another_variable = 3;
which is just too fiddlesome and in fact makes it _harder_ for me to read.Edit: turns out `git blame -w` works as expected, ignoring whitespace. The More You Know™
// some code
// ...
var some_call_result = some_object.a_method(with, quite_long, list_of,
parameters)
In the second line you get indent (up to `var' keyword level), and then
alignment. The former would be fine with tabs, but the latter must be spaces.Unfortunately there's no editor that deals with tabs in this situation correctly, which means spaces is the only way to go.
var some_call_result = some_object.a_method(
with,
quite_long,
list_of,
parameters
)
Alignment adds inconsistent negative space to the code which I find breaks the flow and makes it hard to read because lines start at arbitrary columns. If your method name grows or shrinks, the alignment in your example needs to be fixed whereas with simple indentation there's no such need.The thing is, there are codebases that use "my" line breaking, and with no editor that handles that case correctly, tabs are just no-go.
> If your method name grows or shrinks, the alignment in your example needs to be fixed whereas with simple indentation there's no such need.
I gladly accept this drawback, for the sake of situations when a linebreak is necessary, but the argument list is just too short to be split it into separate lines like in your example. (The necessity is a matter of taste, obviously.)
I admit, these situations are rare, but they happen from time to time, so I simply don't use tabs.
Previous to that with C/C++/C# the alignment usually took care of itself through the closing brace and IDE auto-formatting. So tabs was the natural unit of currency there.
Horses for courses I guess.
IOW, Python is actually far more pragmatic than most people (including most Python programmers) think. It just has a culture that strongly advocates following the rules (i.e. PEP-8 and PEP-20).
Depending on how you choose to format, it can be arbitrarily hard to check tabs are being used correctly.
For example, many people want to do some space indenting, such as:
<tab>void my_function(int arg1, int arg2,
<tab> int arg3)
<tab><tab>{
It's (I believe) impossible for a language-agnostic tool to know this is "correctly tabbed", but (for example) <tab>void my_function(int arg1, int arg2,
<tab> int arg3)
<tab> {
Is not.This let's me know if I left any trailing tabs/spaces before committing, align code better and while writing not while "refactoring".
git commit -am 'Whitespace formatting changes only'
No.
void my_function(
int arg1, int arg2, int arg3,
...
) { void drawrect(
Surface *surf,
int x, int y,
int width, int height,
uint32_t color);
Grouping relevant arguments just makes it a bit more legible. It's even more useful when calling the said function (assuming function with a lot of parameters, say XCreateWindow).I've not seen any large public code-bases uses this style, so it's hard to know how well it works in practice. Do you know of any major projects with a 'no alignment' requirement?
I hate when the code looks perfectly aligned in my editor but is completely messed up in git because git renders tabs a different with.
I personally prefer spaces on my own projects because in the early days a tab used to be fixed at 8 spaces and I though that was a bit too much.
It's adjustable now but I don't think it was then or at least I wasn't aware it was.
In an ideal perfect world, _all_ of programmers and _all_ text editor tools would use tabs specifically for indentation and spaces specifically for alignment. But, we don't live in that perfectly coordinated world so spaces maintains the most fidelity -- at the expense of programmers not being able to instantly customize the indentation from widths of 2,4,6,8.
Therefore, the slight edge goes to spaces even though I find tabs extremely attractive. (That conclusion is in the context of a team of multiple programmers, using multiple languages, multiple text editors. If you're solo and can maintain "tabs discipline", that's a different scenario.)