What is a variable?–the name of a value. What is an attribute?–the name of a property. These are the working definitions that most of us find adequate in daily life and daily computer science. To consider whether there is more to it is to consider an ontology, the ontology of the variable. Is there a good comprehensive definition of "variable" for students and laypersons?
First, however, let's address the subject that arises prominently where variables meet worldly ontology—the professional design of an ontology for some real thing, in some domain, driven by a commercial need to capture some enterprise in a database. The question is, "What do we need to keep track of?"
To answer that question—there's money in it—requires extensive knowledge of some real-world arena of activity, such as sewing, or collateralized debt obligations, or military deployments, or Bordeaux wines [Noy and McGuiness], along with the skills to represent that knowledge in some data language. Working under the entity-relationship model, an expert would elicit and record the entities, attributes, and relationships that need to be exposed in the domain.
The principles of working ontology is a subject taken up by several philosophers of computing. The goal is often knowledge representation and sharing, and the objective is often organizational. Barry Smith and fellow researchers combine the abstract or formal with the domain-specific [Smith2004, Smith2008]. Basic Formal Ontology provides templates and tools as in engineering, and addresses philosophical questions arising from those practices [Buffalo Ontology].
That's not what we're talking about. The question of interest here—there's no money in it—requires probing into the nature of that workhorse abstraction, the variable. We look not to the fine-grained level of a "distinction that makes a difference" (attributed to Donald McKay [McKay]), but to the level of identifiers with associated values. Quine says that "to be is to be the value of a bounded variable," an intriguing notion, but not the informal explication we seek. We want to articulate—toward a comprehensive definition—the ontology of a variable as it is used in computer programming. We mutter, "What's the variable for the tax rate?" or "That variable has a misleading name" or "We don't need a variable for month, because that's a function of the date." The ontology of something that is used so relentlessly in computing must have something to tell us about computing.
Let's consider several questions that may provide direction. (In fact, questions are as far as we go here.)
- If a variable is the name of a value, what about a constant? The distinction is easy to explain in programming, but not so easy outside of it. Is const a special case of var, where some extra property, "mutability," attaches to the var object? And what about the attribute of database design; what is that? Does attr break down into var and const? William Kent raised this question of the ontology of the attribute in 1978, noted its peskiness, and concluded that there is really no difference between an attribute and a relationship.[Kent]
- What is the difference between a variable and a value? Is the variable a thing or some property of a thing? To say that we don't need a variable for the month is to say that the value (but not the variable) can be derived elsewhere. Because variables "go away" when values are substituted, a common view of a variable is as a "placeholder." What is it holding a place for? For a predicate? For a proposition? For an entity? In other words, what is the shape or category of a variable? Is it an attribute of something, a whole statement about something, or the something itself? Again, in a program (or in its formalization in denotational semantics), this is clear; the difference between variable and value is embedded firmly in the process.
- What about the multiple instantiations, the fact that all occurrences of a variable are bound to the same value? To say "that variable has a misleading name" is to condemn several substrings of code. How would we include that aspect (also straightforward in a formal semantics) in a comprehensive definition?
- Is a variable something we know or something we don't know? An algebraic definition of a variable is as an "unknown." Yet we know a lot about a variable x that appears in an equation such as f(x) = ax^2 + bx +c. We know that it is an object suitable for such a setting, that is, a number, and that it belongs right there, and that its value is constrained by the given relations to other values. What's unknown is which number. We always "know" the variable in the rather weak sense that we grasp its need and purpose. In a program, a variable's value is something that we don't know in the source code, the human product. In the execution, as soon as it's bound, the value is "known" in some sense, but to what or whom?
The art of definition has a philosophy of its own [SEP-Definition]. Experts in that realm would not be surprised to encounter difficulties, but computer scientists might be surprised at the subtle and complex issues that come from a mundane and familiar idea.
[Buffalo Ontology] Buffalo Ontology Site. University at Buffalo. Accessed 29 January 2019.
[Kent] Kent, William. 1978. Data and Reality. North-Holland Publishing Company. Chapter 5.0. Attributes.
[McKay] McKay, Donald. 1969. Information, Mechanism and Meaning. MIT Press.
[Noy and McGuiness] Natalya F. Noy and Deborah L. McGuinness. Undated. Ontology Development 101: A Guide to Creating Your First Ontology.
[SEP-Definition] Gupta, Anil. 2015. Definitions. The Stanford Encyclopedia of Philosophy. Edward N. Zalta, editor. Accessed 31 January 2019.
[Smith 2004] Smith, Barry. "Beyond concepts: ontology as reality representation." In Proceedings of the Third International Conference on Formal Ontology in Information Systems (FOIS 2004). Pgs. 73-84. IOS Press.
[Smith 2008] Smith, Barry. "Ontology (science)." Formal Ontology in Information Systems. C. Eschenbach and M. Grüninger, editors. Proceedings of the Fifth International Conference on Formal Ontology in Information Systems (FOIS 2008). Pgs. 21-35. IOS Press. DOI:10.3233/978-1-58603-923-3-21
Robin K. Hill is a lecturer in the Department of Computer Science and an affiliate of both the Department of Philosophy and Religious Studies and the Wyoming Institute for Humanities Research at the University of Wyoming. She has been a member of ACM since 1978.
I wonder what the author would think of the answer given by Christopher Strachey, when he was laying the conceptual foundations for the semantics of programming languages in the 1960s?
Strachey wittily remarked "One important characteristic of mathematics is our habit of using names for things. Curiously enough mathematicians tend to call these things 'variables' although their most important property is precisely that they do not vary".
But Strachey then went on to talk about L-values and R-values and the state of the store, in a way that if I don't misunderstand provides at least one precise account which answers the questions in the article ... and which has influenced future generations of programmers (e.g., these ideas are used in the description of C by Kerhnihan and Ritchie in their book 'The C programming Language').
I'd be curious to know: is there something missing from Strachey's analysis? (I don't know about laypersons, but I personally would teach and have taught Strachey's distinction to CS students.)
Fundamental Concepts in Programming Languages. Higher-Order and Symbolic Computation 13(1/2): 11-49 (2000)
which is a reprint of lecture notes from the 60s.
Note: I certainly agree that things can get confusing and appreciate the author raising this recurring issue.