Friday, September 18, 2009

A balance between flux and immutability

A fun blog post by John Rose about the delicate balance between the world of flux (e.g. volatile memory) and our attempts to enforce immutability through functional languages like Erlang.  Immutability is great, is helps rationalize and simplify your logic, but it just doesn't play well with the notion that "you don't step into the same river twice."  His overall conclusion - work with a language that encourages immutability but allows for in-place mutation where it is needed.  You know a craftsman at work when he sees the issues of software from the perspective of ancient philosophy :)
But we know from common sense (that trusty yet abused helper) that we live somewhere between the fluxy world of Heraclitus and the timeless world of Parmenides. In the days of Plato, it was his student Aristotle who balanced the claims of the two accounts, picking a middle way between the two. In short, the formal ideas we perceive and know inhere (in a way real though bound) in the mutable, moving reality around us. Object identities (what he called "substances") are real, though temporal. If Aristotle had marketers like we do, he might have called his account a hybrid paradigm (more Greek, actually, though to him "hybrid" would mean "having hubris") of flux and form. I think it's likely the story will end similarly for us, in our professional difficulties with software, with some sort of middle way.

Just to speculate wildly, maybe those hybrid functional-and-object-oriented languages (like Scala and F#) can provide a sort of dictionary and grammar of useful terms and constructs. These would somehow describe computations as immutable in most places, and manageably mutable in those few aspects needed to model real-world transitions. (Or to implement localized compute engines, like a quick-sorter.

No comments: