Hacker News new | ask | show | jobs
by randomanybody 3833 days ago
Mere humans are incapable of doing this right as most don't run with show whitespace (so tabs and spaces look different) & many don't grok the difference between indentation and alignment.

I wonder if gofmt logic can be extended to other languages.

1 comments

Well, in my opinion doing any sort of aligning-things by hand is pretty tedious. I tend to just use indentation and not worry about alignment in languages that don't have a formatter to do it for me.

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. :)