On porting code


Of late, my main side project has been rug, a stripped-down Git implementation which I’m building in Rust. I’m following along James Coglan’s excellent book [Building Git][building-git] where he lays out how he went about building the same project, in Ruby. In essence, my project boils down to porting [James’s code][jit]1 into Rust. But why bother with this at all? After all, porting code from one language to another is probably not on your top ten list of cool project ideas.…
Read more ⟶

Piping output to a pager


When you run git diff on a project where you’ve made more than a screenful of changes, the output is automatically redirected to a pager and you can browse through your changes using the familiar less interface. This post shows a minimal example piping output to less. To achieve this, git creates a pipe and spawns a new process, whose purpose is to exec the pager. int fds[2]; if (pipe(fds) == -1) { perror_die("pipe"); } int child_pid = fork(); Let’s start by looking at the parent process, even though in the code this case is handled last.…
Read more ⟶

Myers' diff algorithm in Clojure


If you’re a programmer, you’re probably fairly comfortable with understanding and interpreting diff patches of the kind that git and other version control systems use. In this post we’ll walk through a Clojure implementation of the Myers' diff algorithm, which is the algorithm used by Git. I have been implementing Git following along James Coglan’s book “Building Git”– you can check out the project here. The project itself is in Rust but I thought it might be an interesting exercise to implement the algorithm in Clojure.…
Read more ⟶

Summary of recent reading(July-September 2019)


The Little Elixir & OTP Guidebook by Benjamin Tan Wei Hao: an introduction to the Elixir programming language and the OTP framework that comes with it. It focusses on Elixir’s concurrency features and shows you what OTP can do(the book mostly focusses on GenServers and Supervisors) without spending too much time on the language itself– the idea being to get someone already familiar with functional programming excited about the features that set Elixir apart.…
Read more ⟶

Summary of recent reading(April-June 2019)


Peak by Anders Ericsson and Robert Pool: a book on deliberate practice by one of the researchers who originally coined the term. This book lays out a framework for how to achieve expertise. Briefly, this goes as follows: identify what skills and mental representations an expert possesses, design a step-by-step program where you build up that skill, get feedback on what you’re doing wrong, focus on your weaknesses as you practice.…
Read more ⟶