ebababi
Mutters about programming et cetera

How the Ship of Theseus Relates to Major Code Changes

On the news: A couple of weeks ago at Mozilla, the final commit removing “XBL” has been pushed. That means that after years of effort they’ve completed the process of migrating the Firefox UI to Web Components. That story reminded me of the Ship of Theseus thought experiment. What? How is that even related?

I first stumbled upon the Ship of Theseus thought experiment in a philosophical context. The thought experiment raises the question of whether an object that has had all of its components replaced remains fundamentally the same object. Although there are many variations of this experiment, this particular version was first introduced in the greek legend, as reported by Plutarch:

The ship wherein Theseus and the youth of Athens returned from Crete had thirty oars, and was preserved by the Athenians down even to the time of Demetrius Phalereus, for they took away the old planks as they decayed, putting in new and stronger timber in their places, insomuch that this ship became a standing example among the philosophers, for the logical question of things that grow; one side holding that the ship remained the same, and the other contending that it was not the same.

Plutarch, Theseus1

Plutarch, thus, questions whether the ship would remain the same if it was entirely replaced, piece by piece. Well, I’m not sure about philosophy, but when it comes to doing major changes to production software, this is definitely a good idea. Especially compared to the “single worst strategic mistake” alternative, the “rewrite”.

Very often, major changes are required during the software life cycle, like technology replacements or redesigns. Many will flirt with the idea of rewriting the whole thing, falling for the promise of a fresh start. But, the more conservative ones will embrace change in a progressive way, replacing the system components one by one until everything has been replaced. See the analogy to the thought experiment here?

Another direct correlation between the concept of progressive replacement of system components with the Ship of Theseus thought experiment has been written by Mark Christian and Johnny Rodgers from Slack, in an article they wrote describing the approach they took to upgrade the technologies on the Slack desktop application. As the article puts it:

If every piece of wood in a ship has been replaced, is it the same ship? If every piece of JavaScript in an app has been replaced, is it the same app? We sure hoped so, because this seemed like the best course of action.

Mark Christian and Johnny Rodgers, When a rewrite isn’t: rebuilding Slack on the desktop

A similar approach has been taken by Mozilla years ago in order to replace “XBL” with Web Components. As Brian Grinstead reports, it’s taken a couple years of remarkably steady progress until reaching the completion of that project. Take a look at the XBL code and bindings burndown graph, as published at “Are We XBL Still? No!”: XBL code and bindings burndown graph

So, congratulations to Mozilla! They made steady progress towards the long-term goal of replacing a technology without waiting for a rewrite. If only I didn’t always learn the hard way… 😉

  1. Plutarch. “Theseus.” Translated by John Dryden, The Internet Classics Archive, http://classics.mit.edu/Plutarch/theseus.html