Sunday 12 April 2015

Refactoring science

Computer programmers have a proverb that goes:

Replace repetitive expressions by calls to a common function

This is a type of operation known as "refactoring". Refactoring - for any non-programmers in the audience - involves reorganising code without changing its function. I think what's currently happening with memetics is a similar type of operation involving refactoring science.

A very common type of refactoring operation involves identifying two pieces of code that perform similar functions and replacing them with calls to a common subroutine. Separate pieces of code that perform similar tasks can arise in many ways. Similar code could be developed independently by different developers. Or it could be duplicated from a shared source and modified for a new purpose.

In science we see essentially the same thing: models are developed independently, turn out to have essentially the same dynamics and then need combining.

A classic recent example of this involves kin selection and group selection. While originally conceived as very different processes, many modern formulations have turned out to be different ways of expressing the same types of dynamics. Group selection and kin selection have turned out to be close synonyms.

Organic evolution and cultural evolution are currently getting the same treatment - in that "universal" models are being developed that cover both cases.

Part of the motivation for this type of refactoring is normally that it prevents duplicated maintenance work. When maintenance effort needs duplicating, it costs more to perform. The branches involved can gradually get further out of step with each other as time passes. This introduces incompatibilities and merging the branches can become increasingly expensive as time passes.

As with this type of refactoring in computer science, the original duplicated routines do not need to be performing exactly the same function as one another. Even if they are doing a similar job it often pays to combine them. Sometimes the differences are represented as different parameters. Sometimes they are "lambda functions". Sometimes the differing functionality is encapsulated in pluggable modules.

That's the role that genetics and memetics play in evolutionary theory. They are pluggable modules that are accepted as parameters to a more general evolutionary theory.

That it clearly proposes this refactoring operation is one of the unique features of memetics. It neatly partitions the required changes when adapting evolutionary theory to cover culture into:

  • Changes to evolutionary theory it make it more general;
  • The creation of encapsulated theories of genetics and memetics;

I think that some of the debates over memetics are illuminated by this comparison with refactoring - at least for those with a background in computer science. When refactoring, there are often team members that say features should be being worked on instead. Sometimes the objection that refactoring will introduce bugs is made. Others point to the cost of the refactoring operation. Some say that the code isn't that similar after all, and shouldn't be combined. Some say it's too late to make the change at this stage, and we should learn to live with the old design.

I think we see many of the same objections being made by those involved in evolving modern evolutionary theory. However, this does seem like a pretty attractive refactoring to me. It is worth bearing in mind that science is forever. We should strive to make our models clean and beautiful - for the sake of those that come after us.

Why does this commonality between computer programming and science exist? I think that's a fairly easy one: both science and computer programs involve building and maintaining models of the world - and that's enough to explain the commonality.

1 comment:

  1. This is an important blog post. Code refactoring (the bane of my life) is practical for software application code in reuse and redundancy elimination. But I think you are are touching on something far more important about both a more generalised Darwinism and its (re)cognition (particularly by academia).

    Firstly, cultural evolution may not just be some poetic metaphor of biological evolution, as some would have it. Rather, these are two parallel "species" that inherit evolutionary mechanisms form from a less-derieved "genus". Object-orientation overlaps Linneanism (and genre theory), and we might consider a structure preserving morphism (cf category theory), via a mechanism Dawkins called the "meme".

    Secondly, I envisage that the lambda calculus might actually have some explanatory value. Beyond delegate functions in computer programming languages, alpha conversion and beta reduction (and other goodies) seem to give insight into how the minds abstract symbolic data types behave and interact. Possibly this is what dreaming is concerned with.

    As such may offer some algebraic way of notating the objects of memetics (the underlying code of mind and culture), then I sense this area is a conversation worth pursuing.

    ReplyDelete