Which of the ideas here might be worth developing from half-baked to fully-baked?
“The philosophers have only interpreted the world, in various ways. The point, however, is to change it.” – Marx
So what might XP learn from FP? Some speculation.
Part of XP’s heritage – from both object-orientation and patterns – is an emphasis on modeling the static structure of some world. Let me be careful here: I’m not claiming that current practice is as crude as the (very) old “underline all the nouns in the requirements; those are your classes” advice. And I understand that not all classes in the system may seem to be about something in the business domain: see for example Ward Cunningham’s story of Advancers, where the programmers were quite happy to work with a class that seemed to have no external meaning because it still let them solve business problems.
Note, however, the happy ending to the Advancers story: the connection between Advancers and the business domain had been there all along! The coders had, via an indirect route, discovered something true about the (human-constructed) outside world. That appeals to all us heirs of Plato, who want categories (and classes) that “carve nature at its joints“.
But that platonic view has been challenged, notably by Lakoff’s Women, Fire, and Dangerous Things: What Categories Reveal About the Mind, which argues that categories as used by humans have fuzzy boundaries and often lack any property shared by all members. Other sources, such as Kahneman’s Thinking, Fast and Slow, suggest that what we traditionally think of as reasoning – manipulating mental representations in order to create plans for manipulation of the external world – is actually a fallback strategy that our brains use only when cheaper strategies won’t do. Others, like those who work in embodied cognition and ecological psychology, are expanding our understanding of how behaviors of living organisms that seem to require internal representations or categories can be accomplished without them. For example, people catching balls don’t need to perform expensive mental computations on data that the human perceptual system is in any case unable to provide; instead, they can just maintain simple visual invariants.
The incompatibility between what our programming languages assume and what’s actually true has been discussed in OO circles for a long time, but my sense is that people have never really come to grips with it. For example, there’s still often a sneaking dissatisfaction with terminology that has only internal meaning: wouldn’t it be better if we spoke only the ubiquitous language? (The answer is probably “yes”, but what do we do when we can’t?)
The model-the-world approach has been under even more pressure recently, it seems to me, because web apps don’t have time to model the world. A lot of our habits were formed in the days when objects persisted. Apps got launched. Then objects were created, often corresponding to some part of the world, and an awful lot of them lived as long as the app did (or as long as the corresponding part of the modeled world did). Nowadays, objects live only for the duration of an HTTP Request/Response cycle. They can’t live longer because that would screw up horizontal scalability.
FP languages are a better fit for this modern world. They tend to operate on various flavors of key/value pairs (maps, hashmaps, dictionaries) that heterogeneously lump together data useful to a particular transaction script. That is: they needn’t ever work on classes that have some external meaning.
The heterogeneous structures are passed through a series of processing stages, much like this:
The stages tack on new values as needed, without necessarily much concern for whether they’re changing the meaning of the clump-of-data (what it represents). Put another way: adding a new key/value pair to data flowing through a stage doesn’t/shouldn’t inspire any agonized reflection over whether its type has changed: who cares?
And when the processing is done, (most) everything is discarded. There’s no attempt to maintain any coherent “God’s-eye view” picture of the world. Given the increasing use of eventual consistency, it’s not even clear whether a “God’s eye view” of “the state of the/a world” even makes sense.
As a bit of summary: XP has been (to some extent) hampered by a legacy of world-modeling. That attitude is “baked in” to the process by virtue of its history. FP could allow an alternative point of view: that programs don’t model the world. Rather they (pace Marx) change it by operating on particular bundles of inputs to produce particular bundles of outputs. It’s fine for a program to have no model of the world but still send instructions to actuators that physically poke at it.