Starforth v1: How to Write a Compiler without a Compiler!

This article is part of an ongoing series on writing a self-hosting compiler. You can find the first installment here. This post goes over how I shaped up the first version of the compiler. The main criteria for version 1 were, the compiler should be able to compile its own source code, and also be bootstrappable by the compiler written in assembly. Each version of the compiler is kept in its own branch, so you can find the latest update for version 1 in the v1 branch, though I am going to mainly reference how the source code looked like at tag v1.

Starforth: A Minimal Self-Hosting Compiler

This is going to be the beginning of a series of articles on writing a self-hosting compiler. This is an introductory post. No source code or actual development is going to be discussed in this installment, or possibly not even in the next one. But we’ll get there…hopefully! EDIT: Second installment is now available. I’ve always been vaguely aware of Forth. It’s the language that works with only a stack.

I'm on Gemini now!

I’ve created a gemini capsule at this same domain. If you have a gemini browser, you can visit my capsule at gemini:// Not sure if that means I will not be writing here anymore. Probably not. But I’m definitely more active there at the moment. What’s Gemini? If you’re not familiar with it, Gemini is a new Internet protocol that is heavier than Gopher and (a lot) lighter than the web.

LRFS Part 4: Early Userspace: initrd and initramfs

This is part of a series of articles. You can find the first part here. Although init is considered the beginning of the Linux userspace, this is not technically the case. There are other facilities that are part of the userspace and run even before init. Using these is not mandatory, and as it happens we are not going to use them in our distro (not now, at least), but I thought it might be educational to examine them here.

LRFS Part 3: Init

This is part of a series of articles. You can find the first part here. In this first part of this series we built a kernel and ran it with a very minimal (and useless) init program. We then built bash and used that as init. Let’s go back to our init program and see how we can make a more proper init system. What is init? The first process to be started by the kernel is called init.

LRFS Part 2: Adding a shell and packages

This is part of a series of articles. You can find the first part here. In this first part of this series we built a kernel and ran it with a very minimal (and useless) init program. That’s not very useful. Let’s add a shell. But before that, let’s backtrack a bit. Remember we briefly talked about repeatability in the last post. Let’s get back to that and later see what it has to do with us wanting to add a shell to our distro.

Linux Really from Scratch: Part 1

Linux from Scratch has been one of the projects that I’ve always been interested in…and never gotten around to actually going through with it! I think I downloaded the book a few years ago and actually read a couple of chapters, but never went past that. So for one reason or another, during the last few days I’ve been looking at how Linux is actually booted and how the user space is launched, and I thought maybe I can do it all by myself.


I’ve recently moved to the small but beautiful town of Enschede in The Netherlands. I’ll just leave you with a view from my desk at work for now. Pretty colorful, isn’t it?!

So you want to know you're talking to a robot?

Just imagine for a second, that people were calling for a law that the nationality of who calls them needs to be clear. “I need to know if a Mexican is calling me,” they would say. What would you call those people? Racists, right? Now those people are doing something similar, but now they call what they do “ethics”. They are outraged that we can’t be sure if it’s a human or a robot on the other end of the line.

Benchmarking Python XML Parsers

I’ve written a small benchmarking tool for some of the different XML parsers available to Python programmers. It calculates each option’s throughput by sending a large amount of XML data to each parser. You need to provide it with some XML input. $ ./ 1.xml 2.xml 3.xml 4.xml You can find the source code here on Github. These are the results on my computer: Results: xml.dom.minidom: 7.49 MBps lxml.etree: 89.63 MBps xml.

Launch Virtual Machines Quickly with spinup

For a long time now, I’ve been using Vagrant to quickly launch a VM or two when I need to. Recently, I’ve been less and less satisfied with Vagrant. It’s usually slow and needs editing the Vagrantfile if I want to change the machine specs. The slowness might be partially due to using VirtualBox by default. There is a vagrant-libvirt plugin that lets you use libvirt/KVM but the plugin seems to be a hit-and-miss affair and I’ve not been able to make it work all the time.

Building a static flanneld binary on Ubuntu

I just spent some time trying to build flannel and since there were some nuances, I decided to list the instructions here. Install build dependencies: sudo apt-get install linux-libc-dev golang gcc Make Go directories: mkdir -p ~/go/src cd ~/go/src export GOPATH=~/go Clone flannel: git clone Install Go dependencies: cd flannel go install Since I wanted a statically linked binary, I edited the Makefile and updated the build instruction like this:

DPDK, tamed!

DPDK is a fantastic piece of software. I’ve used it both for work and in my hobby projects (yes, I crunch packets as a hobby, say what you will about me!) and it works great. My only grievance with it has always been the complicated build system it forces on you. It’s ugly and inflexible and it sometimes drives you crazy. Yesterday, I saw that DPDK is in Ubuntu’s repositories. It took me some time to realize wha that means.

Controlling rtorrent with XML-RPC

I’m a huge fan of rtorrent. It’s simple, lean and elegant. I have so far only used it as an interactive BitTorrent client inside screen/tmux or as a batch downloader with a watch directory. There is more to rtorrent however. It supports XML-RPC which means you can control it programmatically. As I was in dire need of a client I can manipulate from a script, I spent some time today to setup rtorrent correctly and call it remotely.

Python/asyncio based BitTorrent tracker

I just uploaded a Python/asyncio-based UDP BitTorrent tracker to my github account. It’s called pybtracker and you can find it here. You can install pybtracker using pip by running pip3 install pybtracker. You’ll need Python 3.5. After installing pybtracker you can simply run it like pybtracker -b -O. An interactive client is also included which can be used by running pybtracker-client udp:// (update server address as you wish).

Letting AsyncIO choose a port for you

Say you are writing a test case for an AsyncIO-based network function. You want to write a test server and have the code being tested connect to it. You can choose a port number and hope it’s not taken when the test is run, or you can have a free port chosen for you each time the test is run. Simply pass 0 as the local port number: {% highlight python %} transport, protocol = await loop.

Python 3.5 in Emacs

April 2016 Update: Native support for Python 3.5 has finally landed in Emacs development branch. You don’t need this patch anymore. Native co-routine support in Python 3.5 is really cool. So cool in fact that it finally made me switch from Python 2. I never was a big fan of Python 3, but that’s another story. The point is I’m finally ready to write some Python 3 code and I find out that my favorite editor (Emacs) does not support the new functionality.

First Post

This is the obligatory content-free first post in my blog. I’m sure numerous posts are coming soon to this blog. Or not! We shall see.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.