Paul Kernfeld

Exploring Computation Graphs in Rust

17 Jun 2018

Recently, I've been trying to figure out a good way to model computation graphs in Rust. In this post, I explore using a graph with vector indices. I'm not sure if this is the best approach, but writing it out has helped me to understand the advantages and disadvantages better.

When I say "computation graph," I mean a representation of a mathematical expression like 2 * a + a * b. This example contains a constant (2), two variables (a and b), and two functions (addition and multiplication). This expression can be modeled as a directed acyclic graph:

2   a   b
 \ / \ /
  *   *
   \ /

In my ASCII diagram above, all edges go downwards. In general, edges don't really have any interesting information associated with them so I'm going to pretty much ignore them.


Confusing Names

03 Feb 2018

Martin Lee Allen: a whole law firm or just one person's name? I bring you a data-driven answer to this question.


Rust's Future by Example

20 Jan 2018

This document is intended to let readers start working with Rust's Future quickly. Some other useful reading includes:


How do people really order adjectives?

06 Nov 2016

Adjective ordering is a big ugly problem in English, but at least it's not an ugly big problem. Recently I saw a claim by Mark Forsyth that adjectives are ordered, "opinion-size-age-shape-colour-origin-material-purpose." I was interested to see how well adjectives really can be ordered.


Bitcoin is not a payment system, it's a database.

31 May 2016

Ask n nerds to explain what Bitcoin is, and you'll get n + 1 answers. It could be a commodity, a currency, a pyramid scheme, or a payment system. To further complicate matters, here's my opinion: Bitcoin is a database.


Exandria: A decentralized public file library

13 Apr 2016

There are many great file repositories online: WikiLeaks and The Internet Archive are two prominent examples. Even these two notable sites are centralized, however. This means that censorship-happy governments can and do find ways to attack these sites by going after their founders, servers, or DNS records.

This article describes Exandria, a design for a file library with decentralized ownership. Any owner can vote to add or remove content, making Exandria extremely difficult to censor.


Many systems have some of these properties, but not all of them. If you know of another system that does or tries to do this, I would love to hear about it!



The world's first decentralized cat name database

20 Feb 2016

In this post, I'll show you how to build a client for the world's first decentralized cat name database. This will be a censorship- and spam-resistant set of cat names which anyone can write to, without an account.

First, I'll break down the requirements. For some more theory on this, see World-writable data structures by burning bitcoins.

The code for this blog post is available at paulkernfeld/decentralized-cat-names on GitHub. This post is a literate program written with litpro.


World-writable data structures by burning bitcoins

19 Feb 2016

Once a user knows the hash of a file in BitTorrent, downloading that torrent is easy, fast, and secure. But finding a hash is a completely different story; the hash must be downloaded from a website, which then becomes a single point of failure in the torrenting experience. The Pirate Bay, probably the most famous torrent index, is one of the most popular sites in the world; at the end of the day, many torrent users are putting their security in the hands of a few Swedish guys. If this is something that so many people care about, why aren't there decentralized torrent indices?

World-writable data structures like lists, sets, or maps could solve this problem, as well as many others. It would be possible to create censorship-resistant username registries, content directories, and domain name systems.

Currently, though, there aren't many good tools for building these shared decentralized data structures. My proposal is to build world-writable data structures using the Bitcoin blockchain. These data structures must be easy to use, spam-resistant, and censorship-resistant.

This sounds so simple... so why doesn't it already exist?


How Bitcoin Loses to the CAP Theorem

15 Jan 2016

The CAP Theorem

If you can figure out P vs. NP, you'll get a million dollars from the Clay Institute. If you can prove or disprove the Beal Conjecture, you'll get a million-dollar prize held in trust by the American Mathematics Society. If you can beat the CAP theorem... I'll give you a million dollars!


Fake Words

Generating fake words with machine learning
15 Nov 2015

"Inatissentis sentere querum" is a Latin expression meaning, of course, nothing, because those aren't real Latin words. In fact, they are fake Latin words generated by training an algorithm on a Latin text. These words look to me, a non-Latin-knower, like realistic Latin words, and hopefully they do to you, too. Of course, if you know Latin, they probably look terrible, and you're probably already mad at me. Instead, take a look at some of the other languages that I've modeled!

This project explores using Markov chains to model word structure in an alphabet-based language, after being trained on a text in that language. This model is then used to generate realistic-looking fake words and to detect "foreign-looking" words.



Video generated via cellular automata
21 Jul 2012

A video generated by the program

I wrote Utopia/Dystopia at Brown in 2012. The video is generated via a program in which each pixel is a cellular automaton. Normally, cells assume the average color of their neighbors. When a cell's neighbors are all white, though, the cell explodes in a flash of color. The program is inspired by Zamyatin's We.


Reactor 1

Real-time audio soundtrack from video
20 Jul 2012

Demonstration video: a time-lapse video of the Boston skyline

I created Reactor 1 in Fall 2010 as my final project for Interrogating the Digital Archive at RISD. Reactor is a Max/MSP program that generates an ambient soundtrack for a video feed in real time. The program responds to sunrise and sunset by changing the tone of the music: as the screen gets brighter, the music increases in pitch and moves faster. The program responds to sudden movement on the screen with flourishes of high-pitched notes.



Draw-your-own-ship tower defense game
19 Jul 2012

A mid-difficulty level.

I wrote Shipwrite for Mozilla's Game On 2010 competition. The player draws ships with the mouse, then commands them around the screen to fight off waves of enemies. Depending on the shape drawn, the ship will have different properties: small ships are cheap, big ships are powerful, sleek ships are fast, and jagged ships can carry more weaponry.


Touch Tone Tanks

Use your phone keypad to control tanks online
18 Jul 2012

Only two players, but you get the idea.

Touch Tone Tanks was a 24-hour hack that I worked on with David Trejo and Justin Ardini for HackNY Fall 2010, at which we won second place.


Robots Are People Too

A two-player cooperative platformer
17 Jul 2012

The game's trailer

Robots Are People Too, or RAPT, is a two-player cooperative platformer written in C++.


Space Duel

A local multiplayer Asteroids-style game
16 Jul 2012

A reasonably large ship using the chain gun

Space Duel was an Asteroids-style multiplayer game that I made in 9th and 10th grade.


Fine Cocktails for Normal People: The Chili Dark 'n' Stormy

A two-ingredient cocktail with a kick
15 Jul 2012

Chili Dark 'n' Stormy.  Photo Credit: Max Monn.

Two-ingredient cocktails. If you had any fewer you'd be drinking gin from a bottle, or maybe just grapefruit juice. From a logistical standpoint, two-ingredient cocktails are great because you don't need to hunt down an endless list of liqueurs. From a sipping standpoint, it's easy to adjust the ratio of the ingredients to your liking, and simple to add a third ingredient without being overwhelmed.


Fine Cocktails for Normal People: The Alien Brain Hemorrhage

Tastes better than it sounds
11 Jul 2012

The Alien Brain Hemorrhage.  Photo Credit: Max Monn.

The Alien Brain Hemorrhage is an exercise in both spelling and layering. This drink relies on the differing densities of its ingredients in order to produce a stunning visual effect. As such, it's essential that it be prepared in a clear shot glass.


Fine Cocktails for Normal People: The Martini

Preferably not shaken, actually
08 Jun 2012

The Martini.  Photo Credit: Max Monn.

Many establishments use the term "martini" to refer to any drink served in a martini glass (appletini, flirtini, velociraptini, and so on). These are not martinis, in the same way that tomatoes are technically fruits. So, maybe not the best conversation starter? A martini is gin, dry vermouth and olives. Or a lemon peel, actually, but let's just stick with the olives for now.


Fine Cocktails for Normal People: The Cosmopolitan

Sex and the City glamour without the live-in nanny fees
01 Jun 2012

The Cosmopolitan.  Photo Credit: Max Monn.

The Cosmo isn't really a classic cocktail, since it was invented in the late 1980's and popularized by Sex and the City. Which, well, er, okay, just read the post, all right?


Fine Cocktails for Normal People: The Old Fashioned

Enjoy classic drinks for 57¢ a pop!
24 May 2012

The Old Fashioned.  Photo Credit: Max Monn.

The Pitch

Anyone can tell you how to make cocktails, but why? Well, you can:

Although cocktails have a reputation as a rich man's drink, you can make many classic cocktails for less than a dollar. So what's the catch? Unlike flipping the tab on a can of beer, mixing a cocktail takes preparation, knowledge, and just a little work. The world of affordable cocktails goes far beyond sorority girls pouring grape Kool-Aid into their Smirnoff, and it's worth a try if you're interested in expanding your drinking horizons without trashing your wallet.