C++20 Modules

I started digging into C++ 20 Modules. If you're not familar, here is a good introduction. Compared to other languages like Rust, I found official references and examples sparse or incomplete. Microsoft has a short intro. I found these Vector of Bool posts insightful, although the writer has seemed to receive C++ Modules with a high degree of criticism. I find the Clang docs unclear about a number of important things. Things are slightly different with GCC.

First of all, with Clang 12, you need to opt-in to modules with -fmodules. I'm not sure why -Xclang -emit-module-interface is a front-end option still. It seems obscure, you can only find it from running clang -cc1 --help. But you need it because you're expected to precompile modules (I made a gist that demonstrates the work flow). Then when you build the file that imports the module, you need to specify where the prebuilt module is located.

It's awkward that the compiler wants to know the module names. Your compiled module's file name must match the module name or you can provide a special flag that maps the module name to an arbitrary file (ie -fmodule-file=name=./file.pcm).

C++ Modules are literally an after-thought, and they have the DX of one. They get a lot more complex than this, I will spare you the rather painful details. Honestly, I'm not sure if they're going to appeal to anyone who's got a large C++ codebase. But for new projects they seem to be an improvement.


In his 1934 book entited Logik der Forschung, Karl Popper argued for falsifiability over verifiability.

Verifying the claim "All swans are white" would require assessment of all swans, which is not possible, the single observation of a black swan is sufficient to falsify it. Citation — Falsifiability

Small-world networks

The Watts-Strogatz model of the small-world network have a large clustering coefficient and paths from node a to b that are on average short.

This means the typical number of steps between two randomly chosen nodes grows proportionally to the logarithm of the number of nodes in the network. The simplicity of this approach makes it a nice starting point for decentralized search.

"It is possible to prove that in the model of a d-dimensional lattice with uniformly random shortcuts, no decentralized algorithm can find short paths [...]. Exploring further, though, we find that a subtle variant of the Watts-Strogatz network will in fact support efficient search: Rather than adding the long-range shortcuts uniformly at random, we add links between nodes of this network with a probability that decays like the dth power of their distance (in d dimensions)." Jon Kleinberg — The Small-World Phenomenon and Decentralized Search

A blockchain is just a data structure

It has no moving parts. It's just a list of items. And each item has some properties. The defining characteristics though, are that each item has 1. a property that acts like a finger print, and 2. a property that points to the item that came before it. A secure hash function creates the finger print using the item's properties as input. A correct and complete blockchain can be implemented in fewer than 50 lines of code.

A blockchain is most likely the least interesting part of any system that is built with one. Networking, consensus and replication, for example, are discrete and non-trivial problem domains that can form a foundation for maing a blockchain useful.

The lifetime of software

The more difficult the problem a project solves, the longer its lifetime will be.
Type of Project Average Lifetime ↑
OS Kernel Multiple Decades
Image Processing Library A decade
Front-End Framework A few years

On Minimalism

Constraints provide meaning.


Some papers on logical and vector clocks.

Lamport Timestamps

Interactive logical timestamps.