Live data from Hacker News

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

notes.shixiangxi.com

91–95 of 95 posts

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

#91
post #89

Earlier quoted context omitted.

Dependency Injection frameworks are a workaround for limitations of the paradigm, much like Design Patterns also are. They're necessary (by a very stretched definition of necessary) because people want to do certain things and the paradigm is fighting them. Some part of the code wants to do logging. The paradigm-native solution is to just instantiate a logger object directly, but that's not really what you want to ha…

Ignoring the singleton for now, because I don't quite see the need. What's the alternative? Which part of this is actually caused by OOP? If you want to isolate IO, which you should, then you need to inject things that do IO and you need to specify a contract for them. And then it's nice to instantiate things or call functions without explicitly instantiating the whole tree of their dependencies.

There are various ways to solve the problem (if you consider it a problem, I personally don't, there's no need for things to be this extremely decoupled, but for the sake of argument):

1) Allow objects to send messages to an implicit "parent" object, which supports "doesNotUnderstand" ala Smalltalk and that by default also forwards to the implicit parent. That means you can implement "log(...)" at the right point in the abstraction without manually passing a logger around.

2) Use algebraic effects, no need to handle this with OOP. A function requests the "log" effect and a handler defined in a higher level scope takes care of implementing log.

3) Have a language with an implicit context parameter that allows putting arbitrary things in it (closest would be Odin but Odin has a fixed set of operations in the context). Because it is implicit in the calling convention methods can be oblivious to it.

4) You separate the concerns: logging is the act of recording some information. Where that information is ultimately sent or stored is a separate concern. This is the more functional view of the problem. If you follow a "model-view-update" approach like the so called "Elm Architecture", logging is just another task produced by the view function, it doesn't need any special handling.

It's not that this is a "problem" of OOP, it is that OOP doesn't give you any tools for tackling this problem. That is why dependency injection frameworks exist. Some other paradigms and non-OOP architectures don't have any trouble with it. You can also replicate those architectures in an OOP language, but that's still "contorting the paradigm" rather than it helping or guiding you towards a clean solution.

Personally I think a global singleton logger is perfectly reasonable, it is other people (the ones using DI frameworks) that think otherwise ;)

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

#92
post #70

For most developers OOP seems to be just a handful of memes they are vaguely aware of and a kind of generally irritating sense of things not quite working in Java. No amount of writing, discussions, examples and history will change this.

I felt this way for years until I decided (for fun) to work through the extremely excellent and recommended Pharo "MOOC" (https://mooc.pharo.org/) to learn Smalltalk.

I'm now OO pilled and feel it has really improved my Python and my golang.

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

#93
post #57

Earlier quoted context omitted.

The Alan Kay variant of OOP is superior in this regard, and I'd argue the Erlang variant even more so (Actors are just asynchronous objects). But both of them are still suboptimal because they allow objects to instantiate one another and to directly communicate with whomever they come in contact with. That creates strong coupling and you have to "fight the paradigm" to avoid it. Other engineering domains have this fi…

Linda and Syndicate figured this out - it’s just that most engineers are not programming language designers or researchers, and most researchers are not designing robust scalable language implementations.

Thank you for pointing me to Linda -- fascinating and my mind is popping with fun projects related to this model. It actually seems quite spiritually similar to "Bank Python" (https://calpaterson.com/bank-python.html), but more elegant.

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

#94
post #65

Earlier quoted context omitted.

I did not know that was something people had done! Thanks for the pointer! If I were to quibble, though: in-process implies exactly the absence of the isolation guarantees that OOP!Kay and microservices share. (The overhead on a Boolean also makes my inner Mel Kaye burst into tears, but that's neither here nor there in this discussion I suppose.)

> Thanks for the pointer! You're welcome! > in-process implies exactly the absence of the isolation guarantees that OOP!Kay and microservices share. OOP objects are in-process and are isolated using language mechanisms rather than machine/process boundaries.

I think that arguably an (active) object à la Kay is itself a process — it doesn't have shared memory with the rest of the program (regardless of how that's achieved).

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

#95
post #85
post #57

Earlier quoted context omitted.

Linda and Syndicate figured this out - it’s just that most engineers are not programming language designers or researchers, and most researchers are not designing robust scalable language implementations.

Linda: https://en.wikipedia.org/wiki/Linda_(coordination_language) By Syndicate you mean syndicated actors?

Exactly, the work of Tony Garnock-Jones: https://syndicate-lang.org/
Post reply on HN