Top all-time · #13317
JP's blog latest posts
Personal blog · jyp.github.io/postsprogramming
JP's blog latest posts is a personal blog at jyp.github.io about programming. Since 2020, 6 different Hacker News readers have linked it 7 times, most often “Efficient parallel and incremental parsing of practical context-free languages [pdf]”. The last post was in 2023, but the archive is still widely read.
Too few sampled comments (5) to say how often HN recommends it.?
Why HN links it
HN readers link this blog for its writing on pretty printers and parsing: a write-up of how a code formatter works, plus papers on pretty printing and parallel parsing. Commenters cite these as sources.
Summarised by Claude from a sample of 5 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- Efficient parallel and incremental parsing of practical context-free languages [pdf]2 people · 3 mentions · first linked 2020-09-16
- Towards the Prettiest Printer (2015)2 people · 2 mentions · first linked 2022-05-04
- /pdf/Prettiest.pdf2 people · 2 mentions · first linked 2020-03-27
What Hacker News says?
Philip Wadler has a seminal paper [0] on implementing pretty printers by modeling them using an algebra. There's implementations of the algorithm in most programming languages nowadays, and some state of the art advances that help with performance [1] It's a very elegant algorithm, and is very pleasant to work. Elixir's formatter uses a variant of it [2], and it appears in the standard library [3]. I've personally m…
Comment linking /pdf/Prettiest.pdf
on “The Hardest Program I've Ever Written – How a code formatter works (2015)”Submitted Efficient parallel and incremental parsing of practical context-free languages [pdf] as a story · 2 points
HN discussionMy point was that "parsing with derivatives" not necessarily a slow thing and I provided example supporting that point. I specifically has been searching for performant regular expression library recently. The "parsing with derivatives" approach can share more of the state, I believe, when doing several matches in parallel (think about trie-encoded dictionary) than DFA-based libraries do and should have smaller star…
Comment linking /pdf/PP.pdf
on “Parsing Algorithms”Submitted Towards the Prettiest Printer (2015) as a story · 1 points
HN discussionIncidentally I spent yesterday implementing a Lisp formatter with the algorithm described by Jean-Philippe Bernardy in the simple and elegant paper "A Pretty But Not Greedy Printer." https://jyp.github.io/pdf/Prettiest.pdf It's based on introducing choice between vertical and horizontal stacking. It avoids combinatorial explosion by pruning away strictly suboptimal choices. With just a few extra rules for Lisp forms…
Comment linking /pdf/Prettiest.pdf
on “The hardest program I've ever written (2015)”OK very interesting! I skimmed over the issue and some of the examples. It does seem like there are at least two schools of thought on the pretty printers -- those influenced by the Wadler pretty printing language (functional style), and those more influenced by go fmt (which does no line wrapping) and clang-format (which does). There's a very recent paper linked here which has a good survey of the functional style.…
Comment linking /posts/towards-the-prettiest-printer.html
on “Why is Prettier rock solid?”The chart parsing (CYK and friends) will produce exactly what is needed - as little contiguous completely parsed parts of program as it is possible. The syntax tree from example above will be different, but not much - parts "fn f(" and "struct { ... }" will be adjacent, not included in partial tree. There's a paper [1] about efficient parallel implementation possible. [1] https://jyp.github.io/pdf/PP.pdf Enjoy. ;)
Comment linking /pdf/PP.pdf
on “Challenging LR Parsing”