Sunday, June 30, 2013

The Biology of Computer Programming


Computer Programming (CP) is a human activity. 

Humans are organisms. So CP can be investigated biologically.

Scientific investigation makes use of any method that engenders results: the further understanding of the natural world. So, let's take two complementary, established approaches to investigating human activity within the biological sciences. 

Approach 1: CP is a human experience that is partly accessible to consciousness. That is, there is some conscious experience, likely a very small part of the overall activity, which people who do CP are aware of. This is a repeatable awareness, found in common to all people who do CP, and although there isn't much outward indication, the moments of the experiences are mostly identifiable by informants. At the very least, I know when I perceive that I'm doing the various tasks that constitute CP. 

Approach 2: where, in the moment of the awareness of these experiences, we find externalized indicators (perhaps with instrumentation).

Principles of investigation

In a nod to Franz Boas, I need to say: I couldn't investigate this question if I wasn't a computer programmer. 

In a nod to 17th & 18th century philosophers of the mind, for example David Hume or Dugald Stewart, I assume that these internal experiences are small indicators of large, complex, inherited mechanisms that shape our mental activity and our actions in the world. 

In a nod to ethologists such as Niko Tinbergen and Konrad Lorenz, I can assume that these are significantly instinctive abilities, and so can be investigated for any member of our species. 

In a nod to geneticists, I can assume that these abilities are highly enabled and shaped by our genetic endowment, with phenotypic modifications that take place during development and life.

In a nod to Noam Chomsky, I can use myself as an experimental subject, an informant in linguistic terms, and begin to ask increasingly sharp questions, and perform experiments, regarding aspects of these human experiences that we all take for granted. 

In a nod to Christopher Alexander, I can use the informant method to examine in detail extremely obscure, complex, hard to find, yet universal, human experiences. 

In a nod to recent use of fMRI techniques by cognitive neurologists, I can turn these experiments into external readings, which help us to begin to sketch out the neurological structures that are part of the activity, and the relation of these activities to other complex human experiences.

In another nod to Chomsky, we assume that any human experience, or any biological feature, is composed of some combination of these three factors (A, B, C): 

A) natural law: for example, there is no gene that says a single cell must be spheroid rather than some other shape -- this is natural law. Genetics operates within these biophysical constraints, which are still poorly understood.

B) biological inheritance: genetics, epigenetics, and various known biological mechanisms -- and poorly understood ones, for example, structure-preservation during morphogenesis, and whatever makes multicellular organisms cohere so robustly.

C) external stimulus: from the environment, during the development and life of the organism.

Approach 1

Let's begin with a general interview of our informant. How does CP feel?

CP feels like any craft, in some way, with some planning, some building of a strategy, some carrying it out, some storytelling (to oneself and others, parts of which become part of the product), a great deal of trial and error, and the use of a great many unknown mental capacities. There is also a sense that one must endeavor to keep the structure of the program coherent, and the user interface must be effective. There are little things that we do, which are quite important, like trying to keep the code well-organized.

That's a very complex human activity. So let's tease one tiny possible CP piece for testing by our informants.

A tiny theory

Here's a small, testable theory: a programmer considers one aspect of "good coding" to be the representation of the same code by the same name. I posit, in this theory, that the human "moment of recognition" of "the same code doesn't use the name" and the "resolution" of this, by "replacing the code" with the "previously defined name for that code" is carried out by people in the same way, activating the same pattern within the brain, that one would activate when putting identical objects into the same pile or while putting books into sets on a shuffled bookshelf.

I may be wrong here. It's just a theory. It also may be far too complex a comparison, requiring simplification. 

Also, there are many questions one could ask about CP mentations that only require comparisons between very similar coding activities (see the conclusion for an example). But, for broader interest, I thought I'd include a test of a broader comparison between mental activities.

The programming side of the experiment is pretty straightforward: in front of the subject, we place a few lines of code. There are a few variable definitions at the top. One complicated value sits on the righthand side of one variable definition. The same complicated value has been placed elsewhere, within the few lines of code. We ask the informant to "clean up this code":


  • var x = a.b.c.f(15);
  • var y = 0;
  • print x, y;
  • y = z( a.b.c.f(15) );
  • print x, y; 


We then create an equally simple version of the comparison activity, and have our informant perform the two, and ask if it feels like the same kind of mental activity. For this methodological discussion, let's assume that we had it right, and most of them said "yes".

Approach 2

At this point, we can bring in an fMRI, and more informant-subjects. We scan for normal brain activity for the action of typing, cutting and pasting, looking at a screen, etc. For our comparison activity, we scan for normal identifying and shifting of objects, books, etc. We then subtract these from the scans during our two experimental situations, look at the remainder, and see if they are the same.

Clearly, such an experiment could show the theory to be inconclusive. At that point, the theories, questions and experiments would need to sharpened up.

The limits of comparison studies

It's quite likely that every mental aspect of programming cannot be revealed through comparisons with other kinds of activities. There are many times when programming feels like nothing else, although it is possible that there is some mental activity that is simply exaggerated by programming.

In these cases we will continue to iterate between the approaches until we can more clearly identify such unique mental activities, and then probe them by constructing more subtle experiments.

The Scale

It is likely that there will be hundreds of mental theories of CP that could be identified, and confirmed or rejected, in this way. It is likely that unifying these theories, simplifying them as much as possible, will be difficult work, but hopefully revealing.

Engineering

At that point, yes, we could, perhaps, begin to use this information to model human CP activity, creating a computer simulation that, with some stimulus and direction, might do something we could metaphorically call 'programming'. 

Of course, we could create such "human simulations" without doing any biological research on the actual human mind -- this has been done in computer science and in the computer industry for at least 50 years. That's the field of Artificial Intelligence, which, in its rush to a "solution", has invented hundreds of techniques that have almost nothing to do with the actual science of biology. Artificial Intelligence, and engineering in general, is not science. Science is our attempt to discover what is actually happening in the natural world. Science is not the drive to imitate nature. It's the drive to understand it.

Conclusion

I believe that moving the study of computing into biology can be motivated by the construction of many testable theories, something that any programmer can begin to do. The reduction and teasing out of the features of CP, as a human activity, the identification of fundamental actions, is something that is commonplace in the engineering world, as a way of passing along principles of good engineering practice: patterns being a recent example. Repositioning and refining these practical insights into biological theorems is very difficult, and leads one to very different questions than engineers are used to asking. 

Just using approach 1, coding activities can be reduced to increasingly interesting questions, such as, "is grouping code into a procedure a completely different activity from dividing one procedure into two, and if not, what are the overlapping mental activities?" These can be tested just using approach 1. I think if we are going to have a true science of computing in the future, it will be essential to examine these kinds of questions.

Thursday, June 6, 2013

Phenomenology as grist for cognitive biology

So, when a philosopher says something like "science cannot tell you what it's like to be thrown into life", well ...

... if philosophy (or literature or whomever) has identified some actual feeling or idea or internal process, that is, some kind of experience, which they assert as true subjective experience, then that is something that could be investigated from a biological perspective ... as a cognitive science experiment. 

So, put some people in fMRI machines, ask them to evoke that experience, and tell the investigator when they're feeling it, and then the investigator can look to see what patterns of brain activity are common at that moment among many subjects, find the common localized structures, compare to other structures, find elements, field effects and compositional mechanisms, etc.

The same can be done with, say, a "sense of individuality" or a "moment of free will" or an enjoyment of "being in the moment". If the phenomena are common experiences, then we can start to identify them. We won't find out much, because understanding of the brain is in such a primitive state, but at least existentialism can be brought back under scientific review, and we can separate the good stuff from the bad.

Yes, it's a little ironic, since the original idea was to emphasize individuality. But irony shouldn't stop us from learning something new about the common human experience.

The endless ramifications of bad science

Descartes published a scientific theory, founded upon a then-popular mechanical view of the universe, positing that humans had within them some kind of substance more than mechanics: a mind-spirit-soul substance. Unfortunately, this idea was immediately misapplied, and over-applied, by incautious thinkers, claiming to be "very scientific", who felt they could now mistreat animals since they were only machines. These people were bad scientists, and every modern scientist should know this story, among the many, many cautionary tales of bad science suffusing modern history.

In Descartes' time, immediately after the bad scientists first marched around kicking pets, there were other scientists who said "what are you doing?" and made counter-proposals that criticized both the original theories and their irrational overreach. 

But, at the same time, the acts of bad science fed into anti-scientific sentiment, in all kinds of circles: political, theological, etc. It's as if the consequence of almost any scientific progress is a kind of two-pronged bombardment of the intellectual world, aside from a fairly common bombardment of the world people live in.

This happens over and over again. People like Darwin accidentally inspired insensitive bullies like Herbert Spencer, whose colleagues' awful support for industrialism, racism and blind positivism inspired, in reaction, a whole culture of antiscientific philosophy (Husserl, Heidegger, etc.) Curious atomic scientists, in what seems like an inevitable series of accidents, launched the deadly nuclear power industry and the scourge of nuclear weapons. The latter are not science: they are interests of money and power, making use of engineering, making use of science, for their own ends. But, as a result, people at large have no 'trust' in science or scientists ... and they shouldn't: science isn't about 'trust'. Unfortunately their criticisms are not about science itself. They are instead about the ramifications of science. The accusations are inaccurate, sure, but they are not unfair.

So, one might ask, why can't good scientists stop hiding in the corner, and directly address the misapplications of their work? Many do, of course, all the time, even the most famous figures like Pauling, Einstein, Watson, etc. And scientists often criticize the soft sciences, especially the tendency to overreach while using tools like statistics and dense terminology to lend credence and impenetrability to irrational speculation.

But, there's nowhere near as much criticism as needed. Science tends to be supported by institutions of power. Science lives in an environment that's unlikely to breed radicals who question institutions -- especially since they tend to live quite well, and sometimes quite freely, within these institutions.

The world of computer engineering is even worse. Even though computing emerged in the context of wars and monopoly, and is a bulwark of business domination over our lives and rampant consumer waste, still, I can't find many programmers or entrepreneurs who think there's "a problem" with ramifications of computing. So, it's hard to blame the scientists, who are one step further removed from the global abuses.

We need to do something. At the very least, both scientists and engineers need to develop a canon of cautionary tales, to inspire the development of a better world, and develop a culture with better sensitivity to issues outside of computing.

Monday, June 3, 2013

Engineering is not science

Unfortunately, many people do not make a distinction between science and engineering -- including many scientists and engineers. The terms have become loosely synonymous with some notion of rationality. As a result, people look at giant industrial engineering projects and say "science!", when they should know better.

Science is a particular kind of pursuit of a particular kind of knowledge. Not many people stop to think what this might mean -- I encourage the reader to do so now.

"The pursuit of knowledge" in science's case comes with some burdens. The pursued knowledge is about nature, in a simple, revealing, principled and fundamental sense. This is the goal of "theory". It is in contrast to, or complement with, "the details". Of course, details inspire the pursuit of scientific questions, but "knowing details" is not the kind of knowledge science pursues. Certain details are pursued, surely, as part of the process of asking questions which can lead to both significant experiments and better theories. Scientific knowledge, or a theory (always tentatively held) usually comes in the form of some typically non-intuitive, interesting principle, or model, one that has held up pretty well (or at least better than others) during prediction, observation and experiment, and which offers insight into how the world works: the world outside our senses and intuitions. Examples of scientific insights that have no attached equations (i.e. models): 
  • "the air" is not empty, but is instead full of all kinds of stuff
  • gravity is a property of all 'matter'
  • there is no "matter & energy"... just energy
  • we have no contact-mechanical explanation for gravity
  • etc.
Engineering, by contrast, is "building something" for "some purpose". Now, a lot of engineering is done to help in the pursuit of science. And a lot of engineering is only possible because of scientific results. But they are not the same thing.

A nice example came up, in conversation the other day with a chemical engineer ... when he needs to achieve some result, and one potential chemical reaction doesn't do the trick, he can't stop and ask "what's going on here"? Because that would be science. He has a job to do, so he just tries another process, and another, until the results are achieved. That's engineering.

Some confusion may arise because both are highly technical human activities, and so, from almost any perspective, they have more in common than in distinction. For example, there are two processes that are common to both science (uncovering nature) and engineering (getting stuff done):
  • trial-and-error
  • incremental-improvement
But, again, these are common to all human activity, probably all animal activity, and perhaps all of natural law ... a drop of water finding the optimal path down a slope is doing both of these things. These processes are part of nature, not just part of science and engineering. Humans have some faculties that seem to help us 'perform' these processes ... and some faculties that seem to hinder such performance (tendencies towards dogma, for example). But no matter how smooth our workflow (something we often try to improve, through trial-and-error) we cannot stop ourselves from using trial-and-error and incremental-improvement, whether we are trying to build something, or trying to understand nature.