Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active December 21, 2025 05:22
Show Gist options
  • Select an option

  • Save sogaiu/e749b45be854c1da09b05c7038f01198 to your computer and use it in GitHub Desktop.

Select an option

Save sogaiu/e749b45be854c1da09b05c7038f01198 to your computer and use it in GitHub Desktop.

non-lisp

  • The Hardest Program I’ve Ever Written - Bob Nystrom

    At this point, you’re probably thinking, “Wait. What’s so hard about formatting?” After you’ve parsed, can’t you just walk the AST and pretty-print it with some whitespace?

    If every statement fit within the column limit of the page, yup. It’s a piece of cake. (I think that’s what gofmt does.) But our formatter also keeps your code within the line length limit. That means adding line breaks (or “splits” as the formatter calls them), and determining the best place to add those is famously hard.

  • Wrapping (text)

  • Knuth–Plass line-breaking algorithm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment