notes.shixiangxi.com

Alan Kay on the meaning of "object-oriented programming" (2003)

sxx0 · 60 points · 17 comments · 2 天前
打开原文HN 讨论

评论

5 条顶层评论
socketcluster30 分钟前

IMO, the most important philosophy in all of software engineering is "Separation of responsibilities." The best way to achieve it is through the principle of "High cohesion, loose coupling." OOP is just another layer of philosophy which builds on top of that. It's more specific, imposes additional guardrails. It requires objects with state encapsulation (locality) and message-passing as the mechanism for components to interact with each other; each component is responsible for changing a subset of the state of the system. Each component is responsible for handling messages (calls to action) by performing local state changes and potentially also sending messages to other components which have more specific sub-responsibilities. OOP without "High cohesion, loose coupling" is almost worthless IMO. It must build on top. I think were most people fail with OOP is that they think coming up with good separation of concerns, good abstractions is easy. They just start implementing the first idea which comes out of their heads and then figure out the scope of responsibilities as they go. The test for good separation of concerns is that you should be able to explain your architecture to someone with the intellect of a 9 year old child who happens to understand the business domain. I'm not exaggerating. It has to be that obvious or else you will not be able to maintain clean separation... You will not be able to maintain alignment in your team. If the responsibilities of a specific object are somewhat vague, what will happen is that the scope of responsibilities between objects will soon blur and the messages between objects will start to look increasingly elaborate; your system will look like a bunch of horrible incompetent managers trying to micromanage junior employees using long, convoluted instructions and occasionally throwing chairs at them... If your system is passing around object references all over the place; that's usually a sign of poor separation of concerns; passing around complex objects by reference is tight coupling, by definition. Each object, each person should be able to fulfill their responsibilities and finish the job using communication only.

jqpabc1231 天前

I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages It was originablly conceived as a simulation of a distributed system. Distributed systems can be useful but does anyone really believe that they are simpler or easier to develop and maintain? The amazing part to me is that so many were trained and convinced to accept that adopting this simulation could make all programming easier or somehow "better". As if adding complexity would magically lead to simplification.

agumonkey20 分钟前

Just a guess, it may be that he understood distribution more as the static distribution of meaning in fine grain entities (objects) to allow a wide range of context, flexibility. Not necessarily the time aspect of distribution.

sph3 小时前

> Distributed systems can be useful but does anyone really believe that they are simpler or easier to develop and maintain? I believe that programs written in languages made for distributed systems are simpler and easier to maintain. Also I believe that one of the major problems in modern computing is that most languages we use do not understand that even trivial programs require ‘communication’ and OS/hardware facilities that have behaviours of distributed systems such as latency, transient faults, etc.

BobbyTables23 小时前

Generally speaking, toy examples can always be made to look simple. In reality it often means the “hard part” was moved into the shadows, not actually solved. Graphical programming like LabVIEW looks very appealing. The product demo practically sells itself. Sure, it fits well for a very narrow class of use cases. But even fairly simple things in a textual language quickly become an unwieldy mess. (Try factoring an integer in it…) There are formal models for distributed systems often solve the “easy” problems that didn’t need solving while making various practical concerns harder/impossible such as timeouts or node failure.

ahartmetz1 天前

That's the Smalltalk school of OOP. There is also the Simula school. It is kind of unfortunate that they use the same name.

mycall1 天前

> OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. How does Simula differ here?

ahartmetz1 天前

AFAIU, Simula focused more on types and inheritance and less on late-binding, in particular not of "all things". Alan Kay's distaste for (static) types is just his opinion and an original contribution of IMO rather dubious value. After the dust has settled, it seems like the most valuable parts of OOP are private data, convenience (no need to repeat the class name in a method call), good fit for some domains, and interfaces.

jqpabc1231 天前

private data, convenience Which can be easily achieved without OOP.

pjmlp1 小时前

In fact, to a certain point of view, OOP is a way to have modules bind to variables, and being extensible.

pitched2 小时前

That upfront convenience here leads to a long tail of job security when it inevitably goes spaghetti. Win-win!

Mikhail_Edoshin2 小时前

There was a Soviet philosopher, Evald Ilyenkov, whose books taught me about a "minimal working model". I'll explain it in my own words. People do not think with words: people think with things. Words serve merely as pointers to things. Some things are easy to point at; Ilyenkov talks about a cow. Some things are much harder to point at; Ilyenkov, being a Marxist, wanted to point to private property, we need to point to an object. Usually we try to talk about them using definitions, that is some sequences of words that are supposed to describe a thing. Such discussions are notoriously unproductive. The reason is that words are not really good as pointers: we have much more things than we have words and we have to reuse the same words to point to different things in different contexts. Yet in a phrase words look same so we tend to conflate these different things. As a result we get lost and go around in circles. So instead of definitions Ilyenkov talks about a notion. Notion is something that reliably points to a thing that is hard to point at. It does not have to be an abstract thing: for example, we cannot point to radio. We can point to a household radio apparat but it has way too many parts completely unrelated to radio as a principle. So instead we build a minimal radio that has like three or four parts yet is capable of emitting or receiving radio waves. We can do the same with abstract things too using the same approach. Let's build a minimal working model of a thing. "Working" so that the model indeed has the quality we are after; and "minimal" so that if we lose a single part, the quality is gone. Since the thing is abstract the model will also be abstract, that is it will be a sequence of words too, very much like a definition, but not quite. (The same principle is widely used in parables: they describe some situation and thus try to guide your attention to certain qualities of it, hoping to trigger understanding. Sometimes it is hard to even name the thing they are pointing at, yet their pointing power is palpable. I myself often think about the parable about seven blind people and an elephant. You see I'm not naming the thing it points at: I don't have a good name for it.) So let's go back to object oriented programming. What would be a minimal working thing that we can reliably call an object? Here is what cannot be there. First, there must be no inheritance. If inheritance were required, then the first thing we build wouldn't be an object as it would have nothing to inherit from. Only the second thing would be an object and only because it inherited from the first. But this does not seem right. Second, there must be no polymorphism on the same grounds. But at the same time if we do this: class Aaaa method bbbb(): ... then it is too minimal. It is hard to say how it is different from a function. It is not an object at all. Yet; there is a missing part that would turn this into a true object, but what the part is could be somewhat surprising.

sph36 分钟前

Thank you Mikhail. I'm reading a lot of metaphysics, and thinking hard about the nature of programming and object orientation, so I appreciate your philosophical approach to the problem. I wasn't aware of Ilyenkov. To answer your question: > What would be a minimal working thing that we can reliably call an object? You might enjoy this paper a lot: https://piumarta.com/software/id-objmodel/objmodel2.pdf Also check out the primary author's work on COLA as well for mind-bending possibilities this would unlock. > First, there must be no inheritance. The paper uses inheritance, but I've been exploring the same concepts WITHOUT it, and it works as well, if not better. Composition and delegation are more flexible. My current working theory is that inheritance is overrated at best, and too dangerous in the hands of common mortals, because it makes you think on the level of idealized categories rather than concrete things. As further reading, your explanation of things vs words reminded me of prototypes vs classes, so I'll recommend this article by Henry Lieberman: https://web.media.mit.edu/~lieber/Lieberary/OOP/Delegation/D...

usrnm58 分钟前

Your example lacks data. An object is the combination of data and code manipulating the data with some syntactic sugar on top

sirwhinesalot35 分钟前

Another commenter pointed it out already but might as well stress the point: objects are bundles of data and behavior. Your example is missing data.

watt1 小时前

don't say "apparat" when you can say "device". side note, when first transistor-based portable radios showed up (as opposed to large lamp-based stationary devices), they were called "transistor". you would take not your portable radio with you, it was your transistor.

unknown2 天前

[deleted]