> >Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.
I've been thinking about it a lot. I want to still believe it, but then my experience tells me that the "right data structure" is usually "the data structure most convenient for the operations/algorithms you want to run". Which makes this principle either backward, or circular.
The right data structure is the one that's produced and consumed in a way that matches the domain you're trying to model. That domain can be inputs to a particular algorithm, but it can also be things like "states of this system" (constructors correspond to state transitions), "witnesses to this property" (constructors correspond to valid inferences), etc.
Leaving aside the unusual, to me, meaning of "domain" in this context, your description matches what I wrote above: the right data structure is determined by what you're planning to do with the data.
It only convinces me further that Pike's take is wrong. Specifically:
- "Data dominates" and "Data structures, not algorithms, are central to programming" are just plain wrong;
- "If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident" is correct only in the descriptive sense, not in the prescriptive sense. That is, it only works when you read it as restatement of Brooks's "tables vs. flowcharts" line (quoted elsewhere in this thread): it's easier to guess what your code is doing from how you organized your data, than it is to guess how you organized your data by looking at the code. I.e. it's an advice on where to start understanding someone's existing solution; it has nothing to say about solving new problemms / writing new code.
I've been thinking about it a lot. I want to still believe it, but then my experience tells me that the "right data structure" is usually "the data structure most convenient for the operations/algorithms you want to run". Which makes this principle either backward, or circular.