Typst as a Language| justinpombrio.net
Let’s start where I started. Just thinking about if statements. An if with an else can produce a value: // Cintx=-5;intabs_x=x>0?x:-x; # Pythonx=-5abs_x=xifx>0else-x // Rustletx=-5;letabs_x=ifx>0{x}else{-x}; What about an ifwithout an else? // Cintx=-5;intabs_x=x>0?x;// Syntax error! # Pythonx=-5abs_x=xifx>0# Syntax error! // Rustletx=-5;letabs_x=ifx>0{x};// Type error -- evaluates to ()! No dice. Optional if I realized that there is a meaningful value for if (x > 0) x, though. It’s Optio...| justinpombrio.net
Imagining a Language without Booleans| justinpombrio.net
Have a cheat sheet for Jujutsu. --- I’ve been learning Jujutsu a.k.a. jj, a version control system that’s compatible with git repos. It’s clicked for me in a way that git hasn’t even after many years of use. The best way to learn something is to teach it, so I wrote a reference and cheat sheet for jj with the help of a friend: The reference describes the state space of a jj repository and how it changes when you fetch and push. The cheat sheet visually shows what all of the common edi...| justinpombrio.net
JJ Cheat Sheet| justinpombrio.net
Investigating the Typst programming language. Typst is a modern typesetting system, and a competitor to LaTeX. You can roughly divide it into two parts: it’s a programming language glued to a layout engine. The layout engine deals withThe programming language deals with - Margins- Data representation - Padding- Cyclic data - Subscripts- Aliasing - Floating Figures- Mutability - Numbered references- Garbage collection - Justified text- Control flow - Right-to-left languages- Functions - Hype...| justinpombrio.net
I present a more expressive variant of Wadler’s “Prettier Printer”. --- What’s a pretty printer? You’ve probably used a code formatter like gofmt or rustfmt or JS prettier. These tools work in two steps: (i) parse the source code in a file, and (ii) print it out nicely. Step (ii) is pretty printing. Pretty printing is the reverse of parsing. Parsing turns linear text into a tree (a parse tree, which after a bit of post-processing becomes an abstract syntax tree (AST)). Pretty printi...| justinpombrio.net
You know how you start a Factorio game with some friends, and play with the Space Exploration and Krastorio2 mods, and soon you’re 123 hours into the game and your factory spans several planetary bodies and you’re trying to figure out how to efficiently route arbitrary sets of resources between planets? No? Maybe that’s just a me problem. But please, consider staying for the algorithms. By trying to do logistics in space we’ll end up with something like min-flow but on a tree. The Pro...| justinpombrio.net
A Twist on Wadler's Printer| justinpombrio.net
Pixel to Hex| justinpombrio.net