|
|
|
|
|
by tailrecursion
4359 days ago
|
|
Kazinator's comment struck me as a lucid definition. APIs and ADTs let the thing's behavior define the thing, and subtyping and substitutability emerge from thinking about generic operators defined on more than one kind of datum. My bet is even Smalltalk programmers don't think of eggs as knowing how to scramble themselves; but eggs do have an API, a behavior, that makes them distinct from other kinds of objects and at the same time shares characteristics with other objects, such as weight and dimensions. I can assemble a list of eggs, elephants, and cars, and write "take the sum of the weights of all the objects". Although these objects are of different kind, they share a common characteristic that would be exploited naturally by any language user. Exploiting multiple "views of a thing" is a feature of English ("natural language") and to my mind is a feature of any successful "generic programming" computer language. Processes communicating by asynchronous message passing is a better simulation of the familiar world; but that vision is not realized by Smalltalk, wherein messages are passed synchronously. What we want from language is the ability to write powerful sentences and have them mean something to the machine -- as long as the computer and human agree on the meaning. The better part of this power comes from a sophisticated treatment of type and generic operators. |
|