Need help?
<- Back

Comments (76)

  • CrzyLngPwd
    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 front of everyone, so I wrote makenasty to format code into the way he appeared to like.I only shared makenasty/nice with a couple of the team, who loved it, as it allowed easy conversion between something readable and something the team lead like.He never knew about makenasty.
  • munificent
    > 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 match, it immediately aborts. This ensures that the only thing the formatter changes is whitespace, and makes it much less spooky to run it blind on a huge codebase.That sanity check has saved my ass a couple of times when weird bugs crept in, usually around unusual combinations of language features around new syntax.(Unfortunately, the formatter in the past year has gotten a little more flexible about the kinds of changes it makes, including sometimes moving comments relatively to commas and brackets, so this sanity check skips some punctuation characters too, making it a little less reliable.)
  • hobofan
    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 the script every day for ~two weeks and got up to 99.5% of all files and then manually each time one of the remaining ~dozen PRs that were WIP for longer were merged.
  • varun_ch
    I’m shocked at the 25M line part! That is a completely unfathomable amount of code for one codebase. I really want to know more about that.
  • dgrin91
    I don't understand why the felt the need to do a big-bang merge like this. Its a formatter, so the files should be functionally equivalent before and after. Why not just enable it for new files/edit files for a while, then once comfortable apply it to old files in batches? What advantage does the big bang merge give? Seems higher risk for the same reward
  • eigenblake
    Really reminds me that there's nothing in principle stopping us from storing parse trees and exposing them via something git like so we can avoid even needing to format, let alone also needing to resolve a whole category of merge conflicts based on that formatting. I mean a format is just a theme over your data -- I mean code.
  • nitwit005
    > 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.
  • burnte
    The floating spiral thing is so distracting I spent more time deleting it in Inspector than reading the article. I feel like they hate their readers. Awful.
  • tmaly
    How did I know this was going to be a rewrite in Rust?
  • comrade1234
    Man must me nice to have the time to put so much work into tabs.
  • ryanisnan
    Cool story. The treat at the end was fun as well, thank you!
  • hokkos
    Now it makes me wonder, are those 45M LoC are untyped ?
  • failure_arch
    [dead]
  • exsol
    [dead]
  • andrewstuart
    [flagged]
  • CrzyLngPwd
    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?
  • throwatdem12311
    What is even the point of formatting code anymore.
  • cadamsdotcom
    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.