"Procedure" and "Data Structure" - A Distinction without a Difference
What happens in computer programs?
"The inner coming-to-be or genesis of substance is an unbroken transition into outer existence, into being-for-another, and conversely, the genesis of existence is how existence is by itself taken back into essence."
- Hegel, Phenomenology of Spirit (paragraph 42)
Classically, an algorithm is a well-defined procedure that takes input and returns output. The input is some piece of data. You know, a number; or string. The procedure turns this number into another number; or a string into a number. Or whatever.
Literarily, a crystallized objective object comes in. Upon it acts the action of a thousand rapid hands too quick to see. Finally, fresh out of the fire, the result pops out, separate from its furnace, like a piece of toast from the maw of the toaster.
Briefly, Data. Process. Data.
We didn't come out of the womb knowing this pattern though. We had to be taught. A teacher had to guide our hands, pointing, "Look! Those numbers! That's data. That sentence! It's data too." Then we saw the process of the data's transformation. It changed from this data, to that data. And this change, our teacher called, "Procedure." And we saw the names, that they were very good.
And so we learned a pattern. To call this or that, a "data structure" or a "procedure." We followed our teacher in not calling a number a "procedure." Otherwise, we would really confuse things. And we would get a slap on the wrist ... for being wrong about the pattern we have learned.
Once we recognize that we were taught these things, that we entered into a pattern, we might begin to wonder whether we should take our pattern with the upmost seriousness. Shall we step out of our pattern to see what is real in it and what is mere habit?
And so we invite ourselves to consider our concepts as they are, uncommitted to where our results may lead us (say lead us to a slap on the wrist), and our old rules have left our mind for the moment. Uncommitted inquiry.
In other words, let us enter into the world of philosophy.
Let's look at something very "obviously" a piece of data: the number five. What is it to a computer? ( Really, what is it to a programmer? Computers don't really regard things. )
Five is something such that if it is next to a plus sign and another number, it returns the sum.
We might as well have the following.
def 5 (op, summand):
if(op == '+'):
if(summand == 1):
if(summand == 2):
The same goes for multiplication and other operations that the processor is designed to do when it "sees five."
And this procedural knowledge, "what to do," is the entirety of the number five to a computer program.
The same goes for all numbers. And the same for all data. For a computer has to know what to do with the data. But it needs the data to tell us what precisely this is. And so data itself tells the computer what to do. Thus data is procedure.
On the reverse side, "what to do" must be stored someplace in a computer. That is, a procedure is also a thing within a computer program. A piece of hard data.
Thus data and procedures don't seem all that different. The shocking thing occurs when we consider a description of an algorithm with this insight, "Data is processed into data." The "data" part processes the "is processed into" part. And the result is a process. Movement upon movement! This is enough to make one's head spin. Each part seems the mover and the moved simultaneously. And we realize we can no longer look at the computer program from the world of computer programming. For computer programming has static things which are acted upon.
And we come down from this wild experience, tired; our movement and thought we ease -- we make for ourselves an arrest in our experience. But with wonder at how vast our world is; how limited the world of computer programming is. But we like our old game, and we enter into it again, but with the awareness that procedures and data are merely distinctions without a difference.