Writing a virtual machine in Rust
Overview # To help me learn Rust, I decided to implement an interpreter for Lox, the toy scripting language in Robert Nystrom’s book Crafting Interpreters. I’ve been interested in scripting languages that are designed to be embedded in applications, and this seemed like a good way to learn more about how such languages are made. Nystrom’s book walks you through two different implementations of the interpreter: a tree-walk interpreter in Java, and a bytecode virtual machine in C. I was more interested in the bytecode VM. Over the years, I’d written a couple of tree-walk interpreters, starting with Apache FreeMarker, as well as an optimising source-to-source compiler with type inference. But I hadn’t implemented a bytecode VM yet. The idea of it brought back good memories of doing assembly-language programming on the Apple II when I was fifteen years old. The instruction set for Nystrom’s virtual machine is simpler than the instruction set of the Apple II’s Motorola 6502 CPU, but the basic idea is the same. So I skipped the part of his book about the tree-walk interpreter and went directly to the part about the bytecode VM.
Calculating centrality indices with the Paris public transport network
I thought it would be interesting to try some basic network analysis of the Paris métro (rapid transit) and RER (commuter rail) systems, starting with some centrality indices. These are metrics that rank the nodes in a graph according to their importance, for some definition of importance. For example, in a transport network, the centrality of a station could give an indication of the likelihood that passengers will pass through that station as part of their itinerary. A public transport authority could use this information to gauge how inconvenient it would be if particular stations were closed, e.g. because of flooding or maintenance, and to help it identify the most effective ways of improving the resilience of the network. Here I’ll use Python, networkx, and SQLite.
The words ‘Turk’, ‘Arab’, and ‘Greek’ in the Ottoman Empire in 1899
While reading Khaled Khalifa’s beautiful, elegiac novel No One Prayed Over Their Graves, I noticed something that may not matter in the context of the novel, but is worth thinking about if you’re interested in the history of social categories that are taken for granted today. The narrator talks about a party thrown by a Christian woman in Istanbul to welcome the new century on the night of 31 December 1899:
The Sound of Crying
In 2024 I did the English subtitles for the short film Mal partum (English title: The Sound of Crying), a beautiful documentary about postnatal depression. Émilie D. used her personal experience to make a film that provides practical knowledge that we can all use.
Shady Lewis, On the Greenwich Line
The novel On the Greenwich Line, by the Egyptian writer Shady Lewis, came out in 2019. Since reading it in Arabic in 2023, I have given the original Arabic version or the French translation to several of my friends (there’s also a German translation), and now I will be giving other friends the English translation that is due out next month. With great sensitivity, Lewis has written a very funny comic novel about immigration, racism, and bureaucracy in London, where he is a social worker. In a lecture at the Institut du Monde Arabe in Paris in April 2023, he said that when the news is so full of horrors every day that we become inured to them, humour can revive our feelings. The treatment did me a lot of good.