Set Types and Avoiding Overspecification.
As we move into the new multi-core reality I believe we will be seeing an increased interest in set types. A set is different from a list in that none of the operations are order dependent. In traditional non-parallel architectures it didn’t really matter if we used sequential lists to represent set types, but now that computers are moving towards parallel architectures, it becomes increasingly important to avoid specifying a temporal dependance when it is not needed.
This is directly in line with one of my central tenets of good programming: “avoid overspecification”.
When I say to avoid overspecification, I mean avoiding implementing specifications that are not reflected in the problem. For example, if I say I want you to write in pseudo-code an algorithm to add one to every element in a set, you may be tempted to write something like:
for (int i=0; i < my_set.count; ++i) my_set[i] += 1;
This has the problem that it specifies the order in which to do such a task. What you really want is something more akin to:
foreach (element e in my_set) e += 1;
Even if in many languages, this is currently implemented in an order-dependant way it can be parallelized without any modification to the language syntax. It more accurately reflects the problem which is related to another tenet which I learned from a software engineering professor: “the code should reflect the problem”.