9 ms·
Kay was at least as inspired by biological processes -- bacteria transmitting chemical signals to one another, for instance -- as he was by computer networks.
by bitwize 7y ago
Kay was at least as inspired by biological processes -- bacteria transmitting chemical signals to one another, for instance -- as he was by computer networks.
I think the big thing that Kay missed was asynchronicity. What Kay was thinking of when he coined the term "object oriented" -- rather than C++ -- was a sort of synchronous actor model in which the actor would always wait for a response after sending a message. This maps nicely onto function calls, but considerably more power can be had by letting the actor optionally continue doing stuff while awaiting a response. Bacteria continue to metabolize after sending chemical signals to their brethren after all!
As I've seen it said, Erlang is Smalltalk done right.
- macintux 7y agoI love Erlang; it would be fascinating (and an astronomical level of effort) to create an Erlang environment with the same powerful UX as Smalltalk.
- ProfHewitt 7y agoYes, Erlang dearly needs an IDE comparable to the one for Java Studio.
- dnautics 7y agoProgramming in elixir with vscode and elixir-ls is a fantastic experience.
- ProfHewitt 7y agoVisual Studio Code and and Elixir with Language Server Protocol are are good start but still have a long way to go reach the level of Android Studio with plugins.
- mercer 7y agocould you elaborate? I've never worked with Android Studio...
- mpweiher 7y agoAs far as I can tell, synchronous operation was not a necessary component of his model, but a pragmatic implementation mechanism in order to make at least some of the vision usable. If you look at the various histories, it seem like Smalltalk 76 was the point at which the system was made practical, and Smalltalk 80 was a refinement of that. Alan himself has repeatedly said that he was not very happy with that version.
- ProfHewitt 7y agoMessage passing of Smalltalk-72 was quite complex [Kay 1975]. Code in the language was viewed by the interpreter as simply a stream of tokens. According to [Ingalls 1983]: "The first (token) encountered (in a program) was looked up in the dynamic context, to determine the receiver of the subsequent message. The name lookup began with the class dictionary of the current activation. Failing there, it moved to the sender of that activation and so on up the sender chain. When a binding was finally found for the token, its value became the receiver of a new message, and the interpreter activated the code for that object's class." Thus the message passing model in Smalltalk-72 was closely tied to a particular machine model and programming language syntax that did not lend themselves to concurrency. SENDER was retained as part of the message-passing protocol, which is problematical for distributed systems. Also, although the system was bootstrapped on itself, the behavior of language constructs was defined (like Lisp) by an interpreter instead by their response to eval messages.
- mpweiher 7y agoWell, and classes were "really" just sort of switch-statements matching that instruction stream, with the "methods" specific cases of that switch. All seems a bit distant from the conceptual model.
- ProfHewitt 7y agoThe Actor conceptional model had not yet been developed when SmallTalk-72 was designed following on SmallTalk-71. Later versions of SmallTalk after SmallTalk-72 adopted the Simula object model. Actors were developed for concurrency, which was entirely lacking from Simula. Also, Simula had procedures attached to the class hierarchy instead of Actor message handlers, which initially seemed like a subtle distinction that grew in importance.
- orthoxerox 7y agoThe earliest Smalltalk versions used actor-like communication, but then Alan Kay learned about Simula and was seduced by the promise of straightforward low-overhead implementation.
- ProfHewitt 7y agoThere is a unique up to isomorphism axiomatization of Actors here: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3418003 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3418003 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3459566 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3459566
- edejong 7y agoSeduced sounds like it had a viable alternative. At the time, machines were mostly single-threaded, especially in the learning environment he was trying to conceive. In that case, there is no need for actor-like communication, except for mindset of it.
- esfandia 7y agoActalk [1] provided actor-like asynchronous communication on top of Smalltalk. [1] Briot, Jean-Pierre. “Actalk: A Testbed for Classifying and Designing Actor Languages in the Smalltalk-80 Environment.” ECOOP (1989).
- ProfHewitt 7y agoActalk was a useful early simulation. However, it did not provide a region of mutual exclusion for an Actor with facets. See the following: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3418003 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3418003
- alankay 7y agoThis is a quite inaccurate comment. The catalysts (in 1966) for the ideas I had included Sketchpad (especially), Simula I (a few days later), the ARPAnet (under discussion), operating systems inter-process communications (especially Project Genie), the Burroughs B5000, my old biology and mathematics majors. All these are mentioned in "The Early History of Smalltalk" that I wrote for the ACM History of Programming Languages" Actors appeared after I gave a talk at MIT about the very first Smalltalk. There were several later ideas that were discussed at Parc but not taken up because of the whirl that was already going on. One of these was derived from McCarthy's "fluents" and "situations" (essentially a labeled states/layers idea for allowing concurrencies without race conditions -- this was done very well in David Reed's 1978 MIT thesis. Another was not waiting for replies. This was in the original set of ideas -- via biology and OS techniques -- but never got implemented in a deep way. The hardware we had at Parc was tiny and Smalltalk was expressive enough to fit a lot into a little. Another set of ideas that were completely missed appeared in LINDA by Gelernter. This (and the larger ideas around it) are very good ways to deal with larger scalings, etc.
- imode 7y agoWhat's interesting is that there's no "destination" for these chemical signals, they're just emitted into the void. There's no sense of sender/receiver, which has some correspondence to the blackboard model[1,2]. 1. https://en.wikipedia.org/wiki/Blackboard_system https://en.wikipedia.org/wiki/Blackboard_system 2. https://en.wikipedia.org/wiki/Blackboard_(design_pattern) https://en.wikipedia.org/wiki/Blackboard_(design_pattern)
- agumonkey 7y agoMaybe not directly but I'm sure these organisms has knowledge of context which influence hormone release. I'd be surprised if it was totally or near totally blind.
- chongli 7y agoYeah, exactly. The synchronous, one-to-one method calls of C++ or Java bare basically no resemblance at all to bacteria chemical signals. The former are essentially functions which dispatch on the first parameter. The blackboard model isn't quite accurate though. Chemical signals have spatial locality, propagation delay, and half-lives. An asynchronous, peer-to-peer mesh network of actors would be a closer approximation to the bacterial signal model.
- imode 7y agoSomething like a "place-based" tuple space would be more accurate, yeah.
- GuiA 7y agoSee also: membrane computing/P systems https://en.wikipedia.org/wiki/P_system https://en.wikipedia.org/wiki/P_system
- edejong 7y agoThe original ideas behind Smalltalk did allow a void, as in modern day Kafka would be a void or a multi-cast IP address would be a void. There is no clear receiver, there can be multiple receivers or there can be none. Communication is ephemeral. Also, even with the single dispatch system of Smalltalk, we can easily model something similar to the Blackboard system.
- dnautics 7y agoIf by "done right" you mean "the working programmer's smalltalk". Erlang and, probably even more by philosophy, Elixir, pushes you towards Kay's model, but the underlying BEAM gives you enough "cheats" to let you be incredibly productive. Especially in elixir those cheats are sufficiently ugly (as in code esthetics, nothing more) that you don't really want to use them unless you must, and when you do use them it's reasonably good practice wrap it in a macro so that the implementation details can be hidden away. In some cases where your using a non-kayish cheat (like it only helps to make your test parallelize over stateful services) you can make your macro no-op in prod.
- ProfHewitt 7y agoThe Actor Model has been used in many important large applications [Bonér and Reisz 2017, Cesarini 2019]. In order to implement next generation Reusable Scalable Intelligent Systems [Hewitt 2019], the following extensions to Erlang are needed: * Automatically reclamation of storage of an unreachable future [Baker and Hewitt 1977] (e.g. process in Erlang). For example, an Erlang process can be orphaned if its Process Identifier becomes inaccessible. * Language support for holes in the region of mutual exclusion of an Actor implementation. For example, in Erlang it is necessary for application programmers to explicitly code a message handler for each re-entry into the region of mutual exclusion potentially enabling cyberattacks from outside the process. * Automatic cancellation of requests that have taken too long. For example, in Erlang it is necessary for application programmers to explicitly code a time-out for each message send that might take too long.
- tines 7y ago> For example, an Erlang process can be orphaned if its Process Identifier becomes inaccessible. Determining this property of a program seems to me to be about as hard as the halting problem, since (1) an Erlang process can send its Pid to another process in a message, and (2) the VM/compiler can't tell a priori whether an erlang process will access its own Pid, or even send a message, in the future. I haven't read the paper you linked though, so I'm sure they found a way around this.
- dragonwriter 7y ago> As I've seen it said, Erlang is Smalltalk done right. As I see it, It's not, but it’d be a decent platform to build an asynchronous smalltalk on top of. One key thing it is missing is a convenient syntax for defining processes (either via instantiable templates equivalent to “class” in many OOPLs or as singletons equivalent to “object” in Scala) in terms of the message handlers and local state (volatile state of the kind that would be held in the process dictionary and the kind of “transactionally updated” state that, in Erlang, would be carried in function args.)
- yesco 7y agoIsn't that exactly what Erlang's gen_server does or am I missing something?
- regulation_d 7y agoseems like OTP to me
- cuddlecake 7y agoA process is simply a function that runs independent of other functions in the system + a mailbox + a handle + own memory. So the convenient Syntax to define a process is a function declaration. Plus, calling "spawn" to start the process. Of course, as other responders pointed out, there is also OTP, an established framework (not syntax) to define processes with predefined, battle-tested behaviours.
- ProfHewitt 7y agoThe Actor Model attempts to be as general as possible to support direct modeling and efficient implementation of all digital computation. For example, an Actor is not required to have an external mailbox, which is required for communication in Erlang [Armstrong, et. al. 1992]. Requiring an external mailbox is problematical for Actors because the mailbox would itself necessarily be another Actor thereby immediately leading to an infinite regress. Also, requiring the use of external mailboxes can slow requests between Actors because it would always be necessary to first deposit a request in an Actor’s external mailbox so that the request could later be retrieved. That a request is almost always sent and received without ever residing in persistent storage, where it can be left and later retrieved, is an important engineering goal for Actors.
- ProfHewitt 7y agoIn Logic Programming, Actors continue processing. See the following: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3428114 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3428114
- triska 7y agoOne very interesting development in this direction is Web Prolog by Torbjörn Lager: https://github.com/Web-Prolog/swi-web-prolog/raw/master/book/web-prolog.pdf https://github.com/Web-Prolog/swi-web-prolog/raw/master/book... Quoting from the introduction: "In particular, we pick the features that make Erlang into an actor programming language, and on top of these we define the concept of a pengine – a programming abstraction in the form of a special kind of actor which closely mirrors the behaviour of a Prolog top-level." And quoting from Section 1.3 of the current draft: "Is the actor programming model compatible with the logic programming model, and does the combination of the two models make sense? Yes, we will try to show that the actor programming model of Web Prolog is able to co-exist harmoniously with its logic programming model, and that both models are usable in the same program, with actors used for modelling the reactive, deterministic interfaces to the user and other external entities, and with the non-deterministic component behaving as an actor, encapsulating the non-determinism." Chapter 3 cites your work directly: "Actors, as specified in (Hewitt et al., 1973), involve entities that have their own mailbox."
- ProfHewitt 7y agoUnfortunately, Actors cannot be efficiently implemented in browsers because of the way that they implement concurrency.
- 7thaccount 7y agoWhen you say "they", I assume you mean "browsers"? Sorry for the dumb question. I know precious little about web programming and concurrency.
- Izkata 7y ago
- mistrial9 7y agoI assert that the mental model held by the programmer, reducing complexity and making effective toolbox choices, is a significant benefit, too.
- jlokier 7y agoThis whole subthread about asynchronous objects, and the actor model, made me think of "background" processing where objects have a running life of their own, and it reminded me of a recent HN comment about almost the opposite approach, where nothing is allowed to be spawned off in the "background". The author contends that Go's "go" (and indeed async blocks in a number of languages) which launch new concurrent objects which the parent block doesn't have to wait for, are a form of badly structured programming. https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ https://news.ycombinator.com/item?id=21537706 The structured concurrency described there reminds me of "par" blocks in some languages (Occam, Handel-C, XMOS XC), where each statement inside the block runs in parallel and the whole block waits until all statements inside have completed. They do have asynchronous request/response patterns, but things can't be started and left to carry on running how they want, like you might think of bacteria.
- nurettin 7y agoThe "structured concurrency" pattern, simply amounts to starting some async jobs (concurrent or parallel) and collecting all of them at the end of some context. One antidote to unstructured concurrency is to use something like trio in order to make async job spawning a function of a context manager (called nursery in trio) so all job results will be collected when the nursery block ends.
- wwright 7y agoI believe the structured concurrency article is written by the author of Trio (I could be wrong.)
- matheusmoreira 7y ago> This maps nicely onto function calls, but considerably more power can be had by letting the actor optionally continue doing stuff while awaiting a response. > Bacteria continue to metabolize after sending chemical signals to their brethren after all! I absolutely love the metabolism metaphor but it doesn't map directly to computer programs as we write them today. Metabolic pathways form an intricate system: https://upload.wikimedia.org/wikipedia/commons/a/a8/Human_Metabolism_-_Pathways.jpg https://upload.wikimedia.org/wikipedia/commons/a/a8/Human_Me... Glycolysis, for example: starting from glucose at the top, we can follow its decomposition in the cell all the way to the mitochondrion. This is similar to Unix pipelines. However, on Unix we must manually construct the pipeline: find ~/notes | grep TODO In a metabolism-like system, the mere existence of these programs would be enough to provoke computation. I'd write "~/notes" somewhere and the find and grep programs would somehow know the data was meant for them and automatically execute themselves. Enzymes are analogous to programs running in parallel. They are completely independent and don't interface directly with each other. They implement a process just like functions do. However, they don't explicitly call upon each other to perform a task. Substrates and products are analogous to data of highly specific types. Catalysis occurs when substrate and enzyme come close enough to interact. The enzyme takes the substrate from a shared environment and releases the product into the same environment where the process repeats with other enzymes. This environment is most commonly the cytoplasm. Enzymes determine whether their substrates are compatible by their chemical structure. This points towards structural typing. When glucokinase phosphorylates glucose, it becomes a different substrate: glucose 6-phosphate. Likewise, when a function adds a property to an object, it's structure changes and so does its type. For example, let's take the following functions: f : A -> B g : B -> C h : C -> D In a metabolic system, there is no need to explicitly write code like: a = A(input()) h(g(f(a))) Rather, they would immediately consume values of type A when they enter the system and the output would be a value of type D in the environment. The computer would fully metabolize data whenever it becomes available and go idle afterwards. As if the programming language's virtual machine was constantly processing all objects in the system: for object in objects: for function in functions: if function.argument.type == object.type: result = function(object) objects.add(result) objects.remove(object) break It would be like polymerase chain reaction: throw DNA polymerase, nucleotides, some ions, the target DNA and its matching primers in a reaction tube, heat it up in a thermal cycler and the copying will begin happen because all the pieces are in place.
- senderista 7y agoI agree that message-passing should be asynchronous by default, but I disagree that message-passing "maps nicely" onto procedure calls in general. Only a particular subset of procedure calls can be naturally interpreted as message-passing: those with a distinguished receiver. Many mathematical functions lack such a distinguished argument, and Smalltalk and other OOP languages are unnecessarily awkward by forcing them to have one. IMO Erlang got it right by keeping a separate notion of function that doesn't involve message-passing.
- ProfHewitt 7y agoActor message passing "maps nicely" for use in procedure calls. For example Factor.[3] sends the message [3] to Factorial which sends back the return value 6. The procedural functions of Erlang are much more limited.
- senderista 7y agoSure, if functions are modeled as Actors. But I don't see the point of modeling the evaluation of a total mathematical function as asynchronous message passing (other than theoretical minimalism).
- ProfHewitt 7y agoAn Actor procedure need not be a mathematical function. For example, Random.[ ] could return a different result each time that it is invoked.
- sriku 7y agoI didn't think that Kay's thinking was exactly the Smalltalk model. It is just that it was one feasible implementation with some key compromises thrown in. I don't think he missed asynchronicity. Just that the machines of his time would've made it next to impossible to be purist about that. He is smart enough to see that the biological systems he was inspired by are asynchronous. In other words, the synchronicity of Smalltalk is somewhat accidental, with good benefits reaped from the idea of reified messages, which Smalltalk does have and C++ etc. don't. Erlang is indeed Smalltalk done right, but, as the OP wrote on the blog, it is not only about messaging and is about the additional constraints. We've seen REST principles used within a single computer in the AppleScript system and protocol, for example, where you could think of applications running on a single computer as being individual computers in their own right and you need to be able to manipulate them using messages that talk using representations of objects in these applications. For example, "window 1" could be a representation for the first window in an application according to some internal ordering in it. We also see REST-like interfaces at various system boundaries - for example, addressing textures on a GPU when preparing instructions on the host CPU. Databases too provide tables as resources and produce/consume representations of these tables to perform their functions. So it isn't surprising to see connectors to APIs exposed via ODBC or REST APIs to RDBMS tables as with PostgREST. So the "InProcess-REST" is in principle understandable as an application architecture pattern, though with the caveat that I haven't gone into the specifics of the OP's work on this (expensive book, etc.).
- specialist 7y ago"REST principles used within a single computer in the AppleScript system and protocol" In contrast to DLLs, shared data, COM+, ActiveX, plugins, and so forth. Terrific observation. Thank you.
- smabie 7y agoI’ve never used Erlang but have shipped production Akka+Scala systems and let me tell you, it’s hard. A big part of the problem is that Akka only supports cooperative multi-tasking: No blocking operations allowed (unless you pin the actor to a thread). This causes a big problem with the code: all implicit state must be made explicit. This creates a lot of boilerplate and makes some problems very difficult, especially with regards to TCP/UDP connections. Even with Erlang that doesn’t have these problems, debugging and writing actor systems are some of the hardest programming problems I’ve ever come across. Also actor systems are fundamentally stateful and don’t mesh well with FP. Are they better than threads? Of course, but it’s a low bar. Hopefully some abstraction will be discovered that offer significant improvement over actors, but I wouldn’t hold my breath. Stuff like futures are great and can solve some problem, but are not general enough to replace actors or threads.
- diroussel 7y agoCould you imagine a layer that compiles down to actors? If that it too much of a stretch maybe something that can lint the protocol flows between actors. So you can have proof that fragmentation and re-assembly is done correctly. Or that message sizes are bounded. Or some other higher level property is proven true?
- smabie 7y agoOne thing I’ve thought of is that instead of messages, each actor exports a list of functions that it provides. Then other actors can call these functions and everything looks synchronous but under the hood each actor is calling other actors functions transparently. This would eliminate message bloat (too many kinds of messages) and would end up looking kind of like OO. So instead of sending the message: Sum(x, y) and eventually getting the response: SumReturn(x), I could just do something like: actorA.sum(x, y) that would look and act like a regular function call. Then actorA could implement sum like: def sum(x: DbInt, y: DbInt) = DbActor.get(x) + DbActor.get(y) With Akka, none of this is possible. Once actorA received the Sum message, first it would have to send the Get messages to DbObject and update some record indicating I’m waiting for two Get responses while also saving who I’m supposed to send the data to. Then I need to have a big match statement and update the record whenever I get that specific response. Once I finally have received the two responses, I look up where to send my message, and then finally send my SumReturn() message. It’s a total nightmare and it sucks big-time. A lot of Akka code just ends up being maintaining these large dictionaries keeping track of all the unfinished stuff I eventually need to send various actors when I finally receive all the ingredients. And it starts to get really bad when you have hierarchical actor structure and one of the terminal actors needs some information held by the top nodes. Then I either need to forward the message up one by one maintaining state along the way, or find the parent of the parent of the parent and send the message directly. And if I do that, now my root actors are talking to everyone else, and the information partitioning advantages of the hierarchy are broken. There’s one actor topology that really shines though: directed acyclic graphs. If I only send information one way, like a waterfall, actors work really really well. Great for bioinformatics or other ML/data science pipelines.
- bad_user 7y ago> Erlang is Smalltalk done right I disagree ... In the Erlang model the messages are no longer just function calls with single dispatch. Imagine for example that method calls on String values would be asynchronous actor messages. That would be absolutely awful. OOP isn't just about the actor model. OOP is also about encapsulation and polymorphism. In a static language, we're talking about row or subtyping polymorphism, i.e. methods of "ad hoc polymorphism". And polymorphism and encapsulation transcend the actor model. I actually really hate the actor model, because asynchrony makes everything harder and actors are too low level, whereas OOP in general is passable as a paradigm in the right context.
- 0xcde4c3db 7y agoIt's not precisely the same distinction, but this reminds me of a CS professor who talked about "blocking send" and "non-blocking send" message systems. He wasted no time in abbreviating them to "BS" and "non-BS".
- raghava 7y ago>> As I've seen it said, Erlang is Smalltalk done right. I was just listening to this today morning, where I heard Joe mention in the podcast something similar on those lines (though I believe he even mentioned about prolog+concurrency was wat led to Erlang and Plex) https://softwareengineeringdaily.com/2015/11/02/erlang-with-joe-armstrong/ https://softwareengineeringdaily.com/2015/11/02/erlang-with-...