Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a programmer I prefer formatters that don't introduce those heuristic line-breaks based on line length.

I'm still hoping that Rust will eventually get such a formatter. Unfortunately the people responsible for rustfmt seem to have a strong preference for the "ignore line-breaks the user inserted" approach.



Zig's formatter has no notion of line length. If you want an argument list to be stacked vertically, you insert a trailing comma after the last argument, otherwise the formatter will put it all on a single line. I was a bit bothered by this at first but I came to really like it.


Agreed. Formatters are supposed to remove all cognitive burden related to formatting. But formatters like Black (for python) will do line-length based formatting which reintroduces the cognitive burden again ("oh crap, my variable names are too long, better shorten them so this line stops getting broken up"). I like gofmt better for this reason. It doesn't break up your lines based on some arbitrary line length.


I usually set the line length limit to somewhere around 80 so I can have several columns visible at once without wrapping or truncation.

So far my magic number is three columns: three code files, or one/two code files with a terminal and/or browser window thrown in the mix. Or any of these columns can be split into two vertically stacked boxes for a total of six things.

I’m also a (nonultrawide) single screen coder (after many forays into the multi screen world) which has undoubtedly guided my preference.


Ultimately code is a visual medium (for most users). It is a data format consumed primarily by human eyeballs, so there is no escaping the reality that things like identifier length, line length, wrapping, etc. matter.

Any other strategy is like trying to design a chair without thinking about butts. You may come up with some sort of elegant Bauhaus mathematically perfect work of art, but no one will want to sit in it.


This grinds me gears. Especially when you have multiple similar lines and one is a character longer and the formatter breaks that line.

It’s like, I could scan the code easier and understand it better without you doing that, thank you!

A similar thing is match statements — some arms using braces vs statements.

There’s also a bunch of heuristics in rustfmt that are complex to the point that I literally couldn’t format the code the way it does without building some sort of decision tree annotated with uneven column limits (e.g. “70% of the column limit”). If I can’t and therefore wouldn’t format the code the way the formatter does, there’s an issue.

Formatters are for consistency, I think, and sometimes they work against that.


It's not the maintainers - rustfmt has an official style guide it's not allowed to break without an RFC: https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide...




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: