Hacker News new | ask | show | jobs
by codetrotter 2042 days ago
It forces consistent formatting within a file.

But I think it was more relevant years ago. These days I see a lot of people using code formatters.

4 comments

The flip side is, if you’re indenting you’re code anyway, as you probably should, then you might as well combine the style and meaning.

It works in practice, same difference to me tbh.

I still think one of Go’s best contributions was formatting with ‘go fmt’. It’s refreshing to see so many language communities just embrace a format on save standard and keep it moving.

Reading Python has always been a bit of a headache for me, but that probably has as much to do with the lack of type annotations as it does the lack of braces.

Auto formatters are the future, why should humans ever have to manually format or discuss how it should look ever again.

However, languages that have a line length limit are the blight of them. There isn't a python formatter that won't make everything mush. My if clause that is 81 chars wide doesn't need to be broken up. Similar, my strings don't need to be reflowed.

Go fmt ignores line length, and always produces a formatted file that is pretty as a result.

You can change the max line length in black (the Python formatter I hear mentioned most often). How would you feel about setting it to something really large, like 1000, to emulate having no line length limit?
That doesn't work still. It will reflow all your lines to reflow to 1000. Try it out, anything above 88 makes even the cleanest python a nightmare.

I don't like long lines, but reflowing logic is way to aggressive in these formatters.

Yeah that makes a bit more sense, thinking back to arguments about aligning hash key/value pairs in code reviews and how that just never seems to come up anymore (thank god)
That’s a pretty bizarre rationale given that other languages didn’t need semantic whitespace (or a formatter) to maintain consistency, and the consistency was even achievable for larger code units than individual files. Formatters are definitely the way to go, but baking it into the syntax was never necessary or even helpful IMO.