Code and Data
Among the pearls of wisdom and wackiness chronicled in Steven Levy’s classic history Hackers: Heroes of the Computer Revolution (Doubleday), my favorite is this one by Bill Gosper, who once said, “Data is just a dumb kind of programming.” The corollary, of course, is that code is just a smart kind of data—data designed to trigger processors into performing certain useful or amusing acts.
The potential interplay of code and data tends to be discouraged in most conventional programming instruction. Code and data are usually severely segregated; even in object-oriented programming, code and data have their own special roles to play. Any intermingling of the two—such as data being executed as if it were machine code—is considered to be a violation of natural law.
Only occasionally is this barrier between code and data breached. Compiler authors write programs that read source code and generate machine code, but compilers do not really violate the separation of code and data. Where the input and output are code to the human programmers, they are just data to the compilers. Other odd jobs, such as those performed by disassemblers or simulators, also read machine code as if it were data.
As we all accept rationally, if not emotionally, code and data are ultimately just bytes, and there are only 256 of them in the entire universe. It’s not the bytes themselves but their ordering that gives them meaning and purpose.
— Petzold, C. (2007). Chapter 8. On-the-Fly Code Generation for Image Processing. In A. Oram & G. Wilson (Eds.), Beautiful Code: Leading Programmers Explain How They Think. Sebastopol: CA: O’Reilly.
Petzold’s distinction between code and data is at least twofold. One is done on the basis of human semiotics and affects, the other on the basis of the physical and logical limitations (or possibilities) of processes engaged in the functioning of computers. No boundary is set between these two, and it should be hard to find it. When the distinction is explored historically, though, the orderings differ and the overall distribution of roles and powers is not the same. According to media theorist Friedrich Kittler, Turing and John von Neumann developed the hierarchies we find to be so natural to computing, by removing “a tiny but sacred distinction that had still enjoyed inviolable authority in the time of De Morgan or Babbage: the distinction between data and addresses, operands and operators.”
When Babbage designed the first universal calculating machine in 1830, he shuddered at the thought of entering operations or commands into his machine in the same punch-card format that he had provided for arbitrary number values. Von Neumann’s machines, on the other hand, write commands and data in the same format into the same, undifferentiated databank; that is their stupidity and their power
- Kittler F. On the Take-off of Operators. In: Lenoir T Stanford: CA: Stanford University Press; 1998. p.77.