Live data from Hacker News

Formatting a 25M-line codebase overnight

stripe.dev

91–100 of 115 posts

Re: Formatting a 25M-line codebase overnight

#92

> We chose a Saturday to format the entire codebase to avoid merge conflicts. And while our test suite gave us high confidence we'd gotten everything right, it's always a bit daunting to have a diff so large that GitHub can't render it. The dart formatter has an internal sanity check. It walks through the unformatted and formatted strings in parallel skipping any whitespace. If any non-whitespace characters don't mat…

Lots of formatters also unify things like trailing commas, so it would be slightly more involved than this.

Re: Formatting a 25M-line codebase overnight

#93
post #74

Surely, it no longer needs to be human-readable, and the era of write-only code is finally upon us with the dawn of AI writing our mealtickets. Why bother formatting 25m lines of slop, and why is AI wasting tokens on making code look human-readable anyway?

Every LLM I have ever asked about this says they perform better when they receive pretty-printed code because it is easier to see structure and priorities. It has been an almost universal recommendation for me, and it makes sense since LLMs are just mimicking human expression.

you asked the llm? i'm confused

you do understand it can't "know" how it performs right?

Re: Formatting a 25M-line codebase overnight

#95

Earlier quoted context omitted.

This kind of passive-aggressive bullshit is exactly what's wrong with tech. People don't decide things: they just passively resist, and authority ends up being a muddle of truncated information flows.

If someone sharing an old war story with what I felt was a positive and joking tone triggered you this bad, I feel bad for anyone working with you. Nothing in tech is worth going through life miserable. Nothing.

[dead]

Re: Formatting a 25M-line codebase overnight

#98
post #56

Earlier quoted context omitted.

reminds me of rob pike mentioning gofmt's style is "no one's favorite"

Having K&R brackets be a syntactical requirement and everything else is a syntax error is okay with me though.

K&R, ride or die.

Re: Formatting a 25M-line codebase overnight

#99
post #56

One of my first jobs was a small software company writing software for a small number of clients, in MS basic PDS. The lead developer didn't like to bother with formatting code, so I wrote a tool called makenice to format his nasty spaghetti gibberish into something with good indents and layout to make it easier for us normal people to parse. He was furious, literally spun in circles about it right in the office in f…

reminds me of rob pike mentioning gofmt's style is "no one's favorite"

The full quote:

> Gofmt's style is no one's favorite, yet gofmt is everyone's favorite - Rob Pike https://go-proverbs.github.io/#:~:text=Gofmt%27s%20style%20i...

The best part about gofmt is there is no discussion about how to format Go code. The style itself is fine, skipping endless hours of pointless debate is priceless.

Re: Formatting a 25M-line codebase overnight

#100
post #89
post #47

Earlier quoted context omitted.

I imagine a fancier version would be to compare the Abstract Syntax Trees.

I've always thought it would make sense for formatters to be baked into the toolchain so that they can reuse the language's parser (presumably exposed as a library) and then be implemented via parsing to AST and then formatted back out so that they're guaranteed to be correct and normalized. This doesn't seem to be how most formatters work in practice though, although I'm not sure if it's because of performance reaso…

That is essentially what clang-format is.
Post reply on HN