Blog Posts – Naming Things
Packrat parsing is a relatively new approach to parsing code introduced by Bryan Ford in his 2002 Master’s thesis. Packrat parsers are capable of very efficiently parsing a class of grammars called Parsing Expression Grammars (PEGs). I covered PEGs in more depth in my previous post, PEGs and the Structure of Languages, so if you’re new to the topic, I recommend you begin there. The packrat parser is based on earlier work on recursive descent parsers, dating back to the 70s, but focused specifically on Parsing Expression Grammars. In this post, I’ll attempt to demystify packrat parsers by walking through a complete packrat parser implementation that fits in a few dozen lines of Javascript code.
In programming, there are a lot of benefits to using immutable values, but the benefits are unrelated to whether variables can be reassigned. Immutable values are a type of data that are guaranteed to never change (as opposed to mutable data, which can change). Using immutable values helps you: Safely store values in a cache so the same value can be reused later. Use trees or lists with shared subcomponents. Preserve invariants in datastructures like hash tables. Store unchanging historical records like undo logs. Share data between threads safely without synchronization primitives. In essence
Explore this link on the map →related reading
- Variables and Mutability - The Rust Programming Languagedoc.rust-lang.org
- A half-hour to learn Rustfasterthanli.me
- how I think when I think about programming - alice mazalicemaz.com
- Immutable object - Wikipediaen.wikipedia.org
- Destroy All Values: Designing Deinitialization in Programming Languages - Faultloregankra.github.io
- Learnable Programmingworrydream.com
- Reading 8: Mutability & Immutabilityweb.mit.edu
- Rust Language Cheat Sheetcheats.rs
- Reading 12: Regular Expressions & Grammarsweb.mit.edu
- Laurence Tratt: Which Parsing Approach?tratt.net
- Omar Rizwan on X: "it feels like we keep orbiting this: a programming system where when you have a value, say `4`, it always comes with a provenance? (did it come from evaluating `2+2`, did you prompt the user and they typed in `4`, etc: thtwitter.com
- Facts and myths about Python names and values | Ned Batcheldernedbatchelder.com