A Modest Design Change

4/29/2006 2:47:04 PM

A Modest Design Change

I have recently had a lot of success programming in a certain nontraditional style at a small scale. Programming in this style has numerous advantages, such as better support for multithreading, less bookkeeping, simpler code. 

This programming style, though, is completely impractical at a global level. Or is it? Functional programming languages are actually based on this style.

The idea is that all document data structures are immutable; data is instead copied or composed. Copying data in an immutable world is very cheap, because deep copies are equivalent to shallow copies since all references are sharable. Equality tests are also cheap, due to a couple of quick comparison tests on identical references and cached hashcodes.

The simplicity of this approach carries over to advanced algorithms built on top of the immutable data. For example, a trivial example of an undo implementation is to stash away the former copy of the document.

While immutable data solves or alleviates a lot of problems, it introduces one huge problem (reminiscent of trade-offs introduced by garbage collection) by eliminating the efficient assignment from the programmer’s toolbox. I do think that this problem is solvable, and that the collective advantages of immutable data may actually outweigh the inability to directly modify data in-place.






SoftPerson develops innovative new desktop software applications by incorporating artificial intelligence and natural language technologies to bring human-like intelligence to everyday applications.

Social Media