this is what go does, and it works great. take any gofmt-formatted style, set your tab size to anything you like, and it will still look great.
it's baffling and slightly tragic that this style of indentation is not more popular!
this is what go does, and it works great. take any gofmt-formatted style, set your tab size to anything you like, and it will still look great.
it's baffling and slightly tragic that this style of indentation is not more popular!
I wonder if gofmt logic can be extended to other languages.
E.g. I would write
struct Foo {
int bob;
string alice;
};
and not worry about lining up variables, whereas gofmt would give you type Foo struct {
bob int
alice string
}
which is fine too but not worth doing by hand IMO.But if you are, it's not too hard to know where to use spaces and where to use tabs, even w/o show whitespace. But it is true that this is more deeply more than most programmers want to think about indentation. :)
Spaces work everywhere.
http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/
And here's what codinghorror had to say about the style:> This way, in theory at least, the level of indent can be adjusted dynamically without destroying alignment. But I'm more inclined to think of it as combining all the complexity and pitfalls of both approaches, myself.
Which sadly seems to be most people's reaction -- basically, it might be better, but I'll be damned if I'm going to have BOTH tabs and spaces in my files!
Oh well...
Spaces are obviously a workable solution, but there are two really big downsides: (1) it throws away information -- when should I insert or remove a indentation block of spaces? You can make your editor guess, but it won't always guess right, and you won't always be editing inside your properly configured editor. A tab simply says what it means and requires no editor trickiness. (2) The obvious inability to adjust the visual width of the indentation, though personally as long as it's not too crazy I'm happy with anything from 2-8, so this doesn't bother me. (I normally run with tabs at 4.)
Go is making a play to make tab/space mixing work nicely in practice and that's quite interesting to watch.