Hacker News new | ask | show | jobs
by kstrauser 825 days ago
> Sometimes there are situational choices that autoformatters cannot comprehend.

I haven't stumbled across that. Could you give an example?

> I also failed to make formatters follow the style choices I use, they were just not configurable enough.

That's kind of the whole point. I love, love, love Python's Black formatter. In my opinion, it chose the wrong default for quoting strings (i.e. it re-writes single quotes as double quotes), which irked me until I gave up and accepted it. In return, I no longer have to put up with my coworkers' insane style choices, just as they no longer have to tolerate mine. With a single addition to our CI pipeline, the days of dumb arguments about the "right" way to format our code came to an end.

3 comments

> Could you give an example?

One thing clang-format ruined for me is when I laid code out in the same indentation as the JSON it was generating.

E.g.

   json
       .startObject("root")
       .startArray("data")
           .insert(1)
       .endArray()
       .endObject();
became

    json
       .startObject("root")
       .startArray("data")
       .insert(1)
       .endArray()
       .endObject();
Likewise with rustfmt

I apply zero customization to it.

If rustfmt thinks the code should be formatted some way, so be it.

I have other things to spend my energy on, unrelated to any particular formatting choices.

Same here. "OK, this is what Rust is supposed to look like? Fine." And now I never have to think about it again.
> I gave up and accepted it.

Some people also said "just accept it" and that's part of why I ditched it. If it can be helped I do not accept it. This is not limited to code formatters, I want to have control over the things I personally use. I want to be comfortable doing my stuff.

You've gotta choose your battles. In all the ways I might want to express myself with a computer, the exact formatting of my code is almost never one of them.