Copy-on-write is a similar advance for concurrent programming as garbage collection was for memory management.
I became a copy-on-write believer at around the turn of the millennium when I was working for the HiBase project as a research assistant. Among other things, I implemented an in-memory SQL database server in Shines, our prototype programming language, which used a strictly copy-on-write memory model. We employed an optimistic concurrency control algorithm to resolve possible conflicts for database transactions run in parallel. The code was elegant, easy to understand, and ridiculously efficient. There wasn’t a single lock or critical section in the entire system. Just threads, message passing, and copy-on-write data structures. Beautiful.
John McCarthy invented garbage collection for Lisp in 1959. It took almost 40 years for garbage collection to finally hit the mainstream programming consciousness with Java. I’m not exactly sure when the copy-on-write data model was invented, but based on the Wikipedia page on functional programming I’m going to place it somewhere in the 1970s. It would be about time for copy-on-write to hit mainstream now, but I don’t see that happening. What’s wrong?
The Erlang guys have touted the copy-on-write model to be the True Way to do concurrent programming for years. But Erlang isn’t enjoying much success in the mainstream. I suspect this is to do with the academic stigma that goes with functional programming and the unusual syntax inherited from Prolog.
Nowadays, copy-on-write techniques are growing increasingly popular also outside the confines of RAM. In the past ten or so years, a number of file systems have popped up which use a copy-on-write data model to implement snapshotting, for example. I find ZFS to be the most promising of these. RAID-Z is just super cool. But let’s get back to programming languages.
I believe the concurrent programming language for the mainstream will have the copy-on-write data model, threads with message passing, a familiar syntax, plus a big ecosystem of libraries and tools. Most importantly, though, the language won’t called a “functional” language, even though it might in reality be awfully close to being one. I wonder when this language will appear. Or does it already exist?
- Copy-On-Write 101 – Part 3: The Sum of Its Parts
- Copy-On-Write 101 – Part 2: Putting It to Use
- Copy-On-Write 101 – Part 1: What Is It?
- Programming Problems in Disguise
- Why Write Code When You Can Remove Some?