Live data from Hacker News

Formatting a 25M-line codebase overnight

stripe.dev

31–40 of 115 posts

Re: Formatting a 25M-line codebase overnight

#31
post #25

Earlier quoted context omitted.

Things can always be worse. It could be PHP, for example.

Facebook runs in it, so I think the language itself is probably a fine choice.

It's almost like other factors than language choice are more important :)

Re: Formatting a 25M-line codebase overnight

#32

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…

Outside of the naming - this is a perfectly sane thing to do for developer comfort and can usually be accomplished with simple transformations.

There are often limitations (like manually added indentation/spacing for alignment) but as long as you're very intentional about what changes you'll allow and have a good understanding of the language it can be an extremely safe operation.

Re: Formatting a 25M-line codebase overnight

#33
An insight about code is that compared to the scale we operate on data, code as text is tiny. Instantaneous git operations and “run this tool over all the code” are the norm even while we wait for LLMs to stream their tokens to stream back so tool calls can operate on it.

That insight might seem obvious - but if you stay cognizant of it as you work, you can invent some pretty amazing tooling for yourself & your team.

Re: Formatting a 25M-line codebase overnight

#34
post #15
post #10

Earlier quoted context omitted.

They're up to 42 million now, as per the article

That sounds even more insane to me, but I guess most of that code does not really touch financial transactions, otherwise it would be a nightmare being responsible to verify that.

Ruby code touches financial transactions. Card payments were migrated to Java when I left in 2022. Non-card payments (e.g., ACH, checks, various wallets) were still processed by Ruby.

PCI-related/vaulting code lived in its own locked-down repo. I think that was a mix of Go and Ruby.

Once you have the foundations in place for account balances and the ledger, processing a payment isn’t that daunting. Those foundations, however, took a lot to build and evolve.

Re: Formatting a 25M-line codebase overnight

#35
post #5

Earlier quoted context omitted.

The systems have to be written in some kind of programming language, and I think Ruby is a perfectly fine choice.

Not denying that Ruby is a perfectly fine choice but within the article itself it says that Stripe runs the world's largest Ruby codebase so certainly it might be testing the constraints of the language. The thing I am interested is that I don't suppose that Stripe always had these many LOC's and so I would be curious to know if at any point as the codebase was increasing, were they looking at other new languages whi…

LOC doesn’t have much to do with the “constraints of the language”.

Stripe has dabbled in Golang. There is also a growing Java monorepo.

Re: Formatting a 25M-line codebase overnight

#36

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…

If he didn't bother formatting code, it would seem impossible to create a tool that formatted code the way he preferred.

Re: Formatting a 25M-line codebase overnight

#37

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…

If he didn't bother formatting code, it would seem impossible to create a tool that formatted code the way he preferred.

Sounds like he did format code, and even had opinions on how it should be formatted, but OP disagreed.

Re: Formatting a 25M-line codebase overnight

#38
> Given that complexity, the hypothesis was simple: tackle the hardest syntax first and the rest will follow.

Always nice to see. I've seen people fall into the trap of designing for the common case, not realizing most of the code will be to deal with the less common cases.

Re: Formatting a 25M-line codebase overnight

#40
post #26

I'm surprised they went with a all-at-once reformat. Even when doing it over a weekend this is bound to mess with a lot of open PRs at their scale. I had to introduce a formatter in a few sizeable codebases in the past (few 100k to few million LOC), and I always did it incrementally via a script that reformatted all files that are not touched in any open PR. The initial run reformatted 95% of all files. Then I ran th…

both options have their pros and cons. if you utilize some form of ratcheting[1], you can sneak it in without your team knowing.. but all of your PRs for the foreseeable future will have a ton of reformatting screwing with your git blame. if you do it all at once, someone will have to sort out conflicts, but you can utilize `blame.ignoreRevsFile`[2] so that your history remains useful

[1] https://github.com/diffplug/spotless/tree/main/plugin-gradle...

[2] https://git-scm.com/docs/git-blame#Documentation/git-blame.t...

Post reply on HN