3 ms·
i am going to object to this; i've programmed in, among other things, prolog, ocaml, basic-80, c, the unadorned λ-calculus, bicicleta, and qfitzah, the last two
by kragen 3y ago
i am going to object to this; i've programmed in, among other things, prolog, ocaml, basic-80, c, the unadorned λ-calculus, bicicleta, and qfitzah, the last two of which are languages i designed and implemented myself and which have no mutability. moreover i don't think anyone would claim that basic-80 or c is object-oriented
so i feel secure in claiming that i am more a walrus than a fish and therefore qualified to opine about water
i do agree that identity and hidden mutability are important aspects of the oo view of the world, and that the author of these slides is off-base about what oo is. but i think that the essence of oo is that computation is done by sending messages to objects, but sending the same message to different objects invokes different code. this feature is present without mutability in bicicleta, and in abadi and cardelli's untyped ς-calculus, which it's based on; the ς-calculus was invented to formalize the essence of object-oriented typing
the original intuition behind oo was to decompose a computer system into smaller computer systems, like a computer network; each object in the system was in effect a tiny computer, with its own private code and state. this was inspired by alan kay's undergraduate degree in biology, which mostly studies organisms made out of cells, which are basically tiny organisms. and in that formulation, obviously hidden mutability is the default, because you can't prevent a computer from changing its internal state as a result of a packet you send it; and mutability generally means identity is important
but even more central to this formulation is the idea that different objects can behave differently in the same circumstances
obviously none of this has anything to do with memory layout! except very indirectly
- bruce343434 3y agoThis is it. OOP is about building sub programs with their own state and behaviours, yet implementing a common interface so they can still effectively communicate to each other. If you boil it down to the essence, this means branching logic is encoded via a function pointer. Instead of manually switching to the correct behavior using other branching mechanisms like if or switch. This is what polymorphism is about. It's pattern matching. An interface is like an Enum to which you can add entries after it has been defined, and the behaviour for that specific variant naturally then has to be encoded inside the variant itself.
- Gehinnn 3y agoWould it be far fetched to say object oriented programming is inspired by nature/physics? And thus, "more natural" than, let's say, procedural programming. Animals can be modeled nicely with objects/classes. Physical objects do have internal private state and public interfaces. Also in nature, usually, you have multiple similar objects that work the same but have different internal state.
- bruce343434 3y agoThat might have been what Alan Kay was going for with his "cells of an organism" thing, yes. But even if you're not inspired by biology, it might just come up "naturally". Separating your data into structs, then operations on those structs, and not wanting to deal with all kinds of bookkeeping all the time, letting things manage their own - separation of concerns, aka single responsibility principle. I think automatic memory management might be a big example of this. Who wants to bother with this malloc/free stuff all the time? Who wants to keep track of ownership everywhere? Instead, have a dedicated subsystem handle it. That allows a higher signal to noise ratio in all the rest of the code that would otherwise be polluted with malloc/free. It also removes the entire class of bugs that can happen when you inevitably forget either of those. But having memory management in and of itself isn't "OOP". It's just an example of one of the principles that people tout when they talk of "OOP". Those principles can and do apply broadly. Was Alan Kay thinking of all this? I really don't know. All I know is that the dude digs biology.
- meheleventyone 3y agoI think more that messaging was the fundamental part. Modularization and composition is pretty common in most paradigms. I actually looked this up the other day for a different comment but this is Alan Kay's own words on the subject: https://lists.squeakfoundation.org/pipermail/squeak-dev/1998-October/017019.html https://lists.squeakfoundation.org/pipermail/squeak-dev/1998... It's a concept I really like and use quite a bit in game development at the inter/intra-entity communication level even if below that I'd pick a more performant substrate.
- trashburger 3y agoYou nailed it. Object programming was never about the low-level details like inheritance; it was always about managing state and sharing behavior (just like function programming!). Object programming looks at things from the perspective of the object; each object has some state and some behavior it can respond to when sent messages. Objects with compatible behavior can be substituted for each other (this is the essence of behaviorism[0]). This is symmetrical to function programming's pattern matching where values with compatible structure can be substituted as arguments to a function (this is also why I firmly hold the belief that Lisp and Smalltalk are symmetrical languages). Languages like Haskell even use things like "Integer a =>" which are basically object programming interfaces! [0]: https://handbook.selflanguage.org/2017.1/progguid.html#behaviorism-versus-reflection https://handbook.selflanguage.org/2017.1/progguid.html#behav...
- hurril 3y agoWe don't disagree at all by the looks of it. I was objecting (lol!) to the description of OO as code and data together. _Together_ doesn't carry the necessary weight here because a struct and a module of functions in the same file is also code and data together. It's that the receiver of those messages have an identity that defines it. Inheritance and polymorphim is of course central to OO, but it's not defining characteristics imho because inheritance is "module arithmetic" and polymorphism has plenty of flavours. (I am in no way trying to have a go at OO either.)
- kragen 3y agoit is astounding to me that my comment has three separate replies saying variants of 'i agree completely' and then disagreeing completely; was my writing really that unclear