Immutability is the idea that data or objects should not be modified after they are created. This concept has permeated throughout computing, and it is a core tenant of functional programming languages such as Haskell, Erlang, and Clojure. Popular object oriented programming languages, like Java and Python, treat strings as immutable objects.

Immutability has been put forth as a way to simplify parallel programming. Coordinating actors reading from and writing to mutable state is the primary challenge of parallelism. The version control system Git is another example of immutability in practice. Each version in a Git repo is effectively a tree of pointers to immutable blobs and diffs. New versions introduce new blobs and diffs, but those necessary to produce the previous version remain intact and unchanged.

In the past few years, immutability has entered the conversation in databases and data storage. Pat Helland of Salesforce gives a great talk on how “Immutability Changes Everything“. In a Hadoop Distributed File System (HDFS), once a file is closed, it cannot be modified. For Datomic, a database designed by Rich Hickey, the creator of Clojure, immutability is a core concept. Datomic is a time-oriented database, wherein the entire database is treated as a time-ordered series of immutable objects. This simplifies reasoning about the state of data as all queries are performed at a particular point-in-time, and at any point-in-time, the database is consistent and unchanging.

When we first conceived of Orchestrate, Rich’s ideas around immutability were very much in our minds. We designed Orchestrate with immutability as a central tenant of the system. Every collection-key pair in Orchestrate identifies a time-ordered collection of immutable objects. This time-series represents the version history of that key. When you PUT a value to a key in Orchestrate, you will be provided with an identifier for that particular value. We call that identifier a ref. When you GET by key, you will be returned the latest value assigned to that key. If you were then to update that value and PUT it back to that key, that updated value becomes the head.

Even as you change the head value of a collection-key pair, all previous versions remain available. You can retrieve old values by querying the ref provided when storing or retrieving those values. Even DELETEs are non-destructive. A DELETE sets the head version to null. All previous versions remain available. (Side note: we recently rolled out purge deletes which run counter to immutability, but allow users to ensure that data has been permanently removed from Orchestrate.)

From the perspective of a user, Orchestrate is non-destructive. All your old data is available. If a mistake is made during an update, an older version can be retrieved and restored as the current value. Immutability offers a sort of conceptual simplicity in the face of our search subsystem being eventually consistent relative to key/value data. When search results are returned, each value is accompanied by its full qualified path, its collection, key, and ref. This fully qualified path is guaranteed to identify the same value that was returned by the search query. This comes in handy when performing updates. Should you update a value using a search result and you do a conditional PUT, a PUT where you tell Orchestrate which ref your update was applied to, it will reject the update if that ref being updated is no longer the latest value.

Treating objects as immutable confers other benefits vis-à-vis other databases. Coordinating multiple actors updating the same value is as simple as using a conditional PUT. Comforted by the knowledge that old data remains available, you can provide your end users ways to track and restore old versions, even in the face of destructive edits. Further, Orchestrate is auditable by data governance professionals. They can see what was changed when and how it was changed.

This concludes our initial discussion of immutability. Immutability will show up in future posts in more practical contexts such as backups, conditional updates, and search. By the way, we're live now in the CenturyLink Cloud. Sign up today for Orchestrate at