logoalt Hacker News

fn-moteyesterday at 5:40 AM1 replyview on HN

One of the lessons I took from the formatters (Python, Go, Rust) is that enforcing the same style ends all of the drama - indeed, all of the thinking - about how to format code. I like that.

I run my formatters manually, so I can’t comment on the jumps in code. That does seem jarring.


Replies

rafabulsingyesterday at 2:02 PM

Again, I don't entirely disagree. Some choices are entirely stylistic: single vs double quotes for strings. Tabs vs spaces. Indentation width. Trailing commas. Those (and others) encode literally 0 meaning, and any time discussing those is time wasted, so they should be auto formatted away.

But some things are not like that. Two statements being right against each other, or having an empty line between them, encodes information.

In a big function call with many arguments, where do you add line breaks between arguments? That can convey information as well. As the posted link says, those are some of the most difficult scenarios for a formatter to try to deal with, and my point is that I think it's not worth the effort.