News for hackers. Stuff that matters.
Re:Alan Kay on the misunderstanding of OOP (1998) by kmiroslav on Friday June 24, 2016 @08:09AM (#11969099)
I don't really understand this obsession with messages.

We're moving away from it. This is not how we program in the 21st century. The last popular language that supported this paradigm (Objective C) is being replaced and will probably be all but gone in just a few years as Swift (not message based) takes it place.

Besides, this idea of message passing is really not that useful for modern programming anyway but a lot of people still have this weird idea that message passing magically solves the problem of data integrity in parallelism. It doesn't. It does nothing to solve it. You can still have deadlocks and you can still have data corruption.

The only approach that has provably improved our problems in this area is immutability, but even that paradigm comes at a cost that sometimes doesn't make it worth the trouble

Re:Alan Kay on the misunderstanding of OOP (1998) by macintux on Friday June 24, 2016 @08:53AM (#11969399)
Erlang and Elixir may not meet your criteria of popular, but message passing is one of several closely linked features (including immutability) that collectively make distributed, robust systems much easier.

No, it's not a silver bullet, but neither is it some misbegotten relic of an earlier era as you posit.

Re:Alan Kay on the misunderstanding of OOP (1998) by felixgallo on Friday June 24, 2016 @10:58AM (#11970252)
We're accelerating towards messages at a very high rate of speed.

This is in fact how we're starting to program in the 21st century and all programming will be of that type in the 22nd century.

The last popular languages that support this paradigm (Go, Rust, Erlang, Elixir) are exploding in popularity and entering the mainstream.

Message passing does in fact magically solve the problem of data integrity in parallelism when the data is immutable. Languages like Rust and Pony are starting to solve the deadlock problem, and 'data corruption' has nothing to do with messages or lack of messages.

Re:Alan Kay on the misunderstanding of OOP (1998) by the_why_of_y on Saturday June 25, 2016 @08:29AM (#11976110)
Rust does many a nice thing, but nothing to solve deadlocks.
Re:Alan Kay on the misunderstanding of OOP (1998) by _asummers on Friday June 24, 2016 @08:33AM (#11969248)
What about e.g. HTTP? The dynamics of server to server communication are all about message passing (REST is just a message conveying state, if you ignore the other rules). Look at things like Erlang and Elixir processes. Akka and the actor model. Map/Reduce to a certain extent. These are all founded on the idea of giving a task out with enough information that the worker can reasonably go and work on the task without having to look around for state. Also look at things like FRP and more event driven architectures. While not ThingA sends message to ThingB, ThingA still broadcasts a message, possibly containing the relevant state.

Also almost forgot. Look at the wealth of message queues that exist (RabbitMQ, ActiveMQ, SQS, Kafka, ... the list goes on).

Re:Alan Kay on the misunderstanding of OOP (1998) by pacala on Friday June 24, 2016 @08:50AM (#11969387)
Message passing implies one way broadcast. Think GOTO. HTTP is a request / reply protocol, i.e. a function call. Map / Reduce is an implementation device for SQL-like collection-based processing, modern Map / Reduce systems [Google's Flume / Dataflow] offer directly the collection API, using Map / Reduce as an implementation detail. FRP is a device for adding a collection API on top of streams of events. Collection APIs are conceptually function calls over collections [duh].

Just because your compiler uses GOTO / messaging behind the scenes to implement function calls, it doesn't follow that GOTO / messaging is the right API level for designing applications. We know this since 1968.

Re:Alan Kay on the misunderstanding of OOP (1998) by protomyth on Friday June 24, 2016 @09:18AM (#11969550)
> Message passing implies one way broadcast.

Can you explain that since its contrary to my experience. PDO and normal Objective-C methods had a return and are not one way.

Re:Alan Kay on the misunderstanding of OOP (1998) by pacala on Saturday June 25, 2016 @12:01PM (#11976768)
There are two distinct meanings mushed together under the "messaging" umbrella:

A. One way communication, aka events, goto. Very useful as an implementation concept, but generally a poor idea for structuring applications, as it makes local reasoning about code harder than necessary.

B. Polymorphism, aka closures. This is a very useful device for modularizing code, albeit, in practice, vastly overused. It also happens to trivially fall out from the concept of "first class function". To have first class functions, we need to be able to create them at any point in the program, thus we need some form of variable capture to allow value capture, which was named "closure", in the example below "function g closes over variable x". Furthermore, we need to be able to return the function value we just created and invoke it later, in the example below the invocation of q(4) actually invokes the closure of g over 3. Once we have first class functions, we can add any number of concrete syntactic sugar constructs [classes, vtables, etc, etc, etc].

   def f(x) = {
     def g(y) = {
       x + y
     }
     g
   }
   val q = f(3)
   q(4)
IMHO, the "misunderstanding of OOP" is strongly attributable to a propensity in OOP community for using ambiguous terminology to pretend it possesses some sort of silver bullet, instead of recognizing the rather elementary computation constructs obscured by said terminology. In some alternate universe, we'd use "events" and "closures", and there will be very little misunderstanding. "messaging" is a false friend between computer languages and real world experience.
Re:Alan Kay on the misunderstanding of OOP (1998) by ivan_gammel on Friday June 24, 2016 @09:29AM (#11969612)
In modern enterprise programming message is very different concept (probably more widespread, if we'll look at popularity of Java and .Net, compared to Objective-C), which is not related to OOP. It's a pattern of integration, in which systems exchange with messages through a message broker, that abstracts them from each other. By their nature such messages are asynchronous and unidirectional.
Re:Alan Kay on the misunderstanding of OOP (1998) by infinite8s on Friday June 24, 2016 @10:50AM (#11970183)
That was also the original model of messaging in Smalltalk (well, without the necessity of a broker).
Re:Alan Kay on the misunderstanding of OOP (1998) by coldtea on Friday June 24, 2016 @08:58PM (#11974645)
Smalltalk receivers returned values to the senders of the message. Plus, they were synchronous.

So, while indeed still messaging, I'm not sure about the similarity to message queues/brokers in modern enterprise, where, as the parent said "By their nature such messages are asynchronous and unidirectional".

Re:Alan Kay on the misunderstanding of OOP (1998) by coldtea on Friday June 24, 2016 @08:55PM (#11974635)
>Message passing implies one way broadcast.

Where did you see that? That's not what the kind of messages we talk about are (e.g. in Smalltalk).

Perhaps (as some other commenter said) you have modern message queues in mind?

Re:Alan Kay on the misunderstanding of OOP (1998) by ivan_gammel on Friday June 24, 2016 @08:41AM (#11969304)
HTTP is closer to RPC. You always know the address of the routine to call, so it's not actually a message (except in HATEOAS, in which you first need to learn the next address from last API call).

Closest analogy is the message queue (e.g. ESB) like Active MQ or Rabbit MQ (and the whole JMS tech), in which you do actually send a message and infrastructure does actually figure out who will receive and process it.

Re:Alan Kay on the misunderstanding of OOP (1998) by specialist on Friday June 24, 2016 @01:39PM (#11971809)
HTTP(S) is the opposite of RPC (meaning: message-based). Both SOAP and XML-RPC tried to remedy that.
Re:Alan Kay on the misunderstanding of OOP (1998) by ivan_gammel on Saturday June 25, 2016 @03:54AM (#11975606)
How exactly it is opposite?
Re:Alan Kay on the misunderstanding of OOP (1998) by specialist on Saturday June 25, 2016 @11:01AM (#11976523)
Difference between document (message-passing) and RPC styles:

http://stackoverflow.com/questions/9062475/what-is-the-diffe...

Replace SOAP with HTTP, since SOAP is just an ill-advised, unnecessary, redundant obfuscation layer on top of HTTP, and so contrast still applies.

Re:Alan Kay on the misunderstanding of OOP (1998) by kmiroslav on Friday June 24, 2016 @08:41AM (#11969311)
I was talking about programming languages.

Obviously, message passing is alive and well for network protocols.

Re:Alan Kay on the misunderstanding of OOP (1998) by aryehof on Friday June 24, 2016 @09:39AM (#11969670)
>>> This is not how we program in the 21st century.

Actually, for many if not most, programming today means using procedures and subroutines, organized through functional decomposition, just like was done in the 1950s and 60s. We haven't gotten that far have we.

OO is a different paradigm from organizing the concepts in a domain through functional decomposition, and understanding how it is different, is key to understanding OO and messaging.

Re:Alan Kay on the misunderstanding of OOP (1998) by hackits on Friday June 24, 2016 @09:56AM (#11969757)
Could you elaborate leading by example `how it is different`?

Seriously because unless you can define it, and quantify it then it is just rhetoric.

Re:Alan Kay on the misunderstanding of OOP (1998) by aryehof on Friday June 24, 2016 @10:43AM (#11970112)
> "Could you elaborate leading by example `how it is different`?"

I'll try.

By the end of the 1950's, modular programming based on procedures and subroutines had become problematic. It was hard to have large teams of programmers working on parts of the code at the same time, and it was hard to create large well-structured programs.

The answer in the 1960's was to break down a problem into pieces, then sub-components, then subroutines through functional decomposition. This better allowed large problems to be understood, and worked on by different teams at the same time. This approach is known as structured programming.

This approach has resulted in quality software over the years, but suffers from painful limitations. One of the big ones is that as one works on a problem and discovers its requirements, the decomposition used needs to be modified, often from the top down.

Object orientation (much as for the "data" movement) represented a different way to approach a problem. Let's break down a large problem or system into entirely independent concepts that know how to to do things themselves. Let's not orchestrate concepts (objects) centrally, but instead have them do things themselves together to solve a problem. This comes close to the way we think. We recognize and organize things in our minds around us as objects. We differentiate between them by their attributes, and we classify them. When we see a tree we recognize it as such, and differentiate it from other by its attributes and also by its place in the hierarchy of types of trees we know. Behavior on the other hand is only immediately important to us if it is causal - for example if it threatens us. That unknown thing moving fast towards you prompts changes in your body, but once you recognize the object is a beetle and not a spider, you change.

Hopefully that helps.

Re:Alan Kay on the misunderstanding of OOP (1998) by hackits on Friday June 24, 2016 @11:14AM (#11970379)
Thanks aryehof for the explanation. It answered a question that I have had in the back of my head all week.
Re:Alan Kay on the misunderstanding of OOP (1998) by Retric on Friday June 24, 2016 @10:11AM (#11969865)
Functions have no internal state. Early languages used global variables to share state across functions without explicit message passing (everything was a singleton). This created worlds of pain. The alternative was passing state with each function call. This also got painful as people often passed data down through functions.

OOP lets chunks of functions share state and hide that state from the wider application. More importantly you could have multiple instances of that shard state without explicit management, saving a lot of complexity and effort.

Re:Alan Kay on the misunderstanding of OOP (1998) by jdmichal on Friday June 24, 2016 @10:36AM (#11970058)
> Functions have no internal state.

But closures do. And thus, why closures are a poor man's objects, and objects are a poor man's closures. As an example, Java closures are really anonymous objects with the closed state as instance variables.

> More importantly you could have multiple instances of that shard state without explicit management, saving a lot of complexity and effort.

Technically that's what classes gives you, not objects. But agreed on the sentiment.

Re:Alan Kay on the misunderstanding of OOP (1998) by jstimpfle on Friday June 24, 2016 @01:04PM (#11971500)
If you apply this common understanding of "closure" where the values that closures close over are not really values but mutable objects, then closures don't count as (pure) functions.

If one thinks of them as proxies to the closed-over objects, they are quite like "procedures". Another way to think about them is simply as objects with only a single method.

Re:Alan Kay on the misunderstanding of OOP (1998) by jdmichal on Friday June 24, 2016 @02:11PM (#11972073)
They are definitely still "functions", barring the fact that Java doesn't have first-class functions and SAMs are the closest thing. C# does have first-class functions, and it is even more liberal in its closure rules. (Java can only close over `final` variables, which are immutable variable bindings. C# doesn't even have immutable variable bindings, only member bindings.)

Also, they can still be "pure functions". Purity is a relation of side effects, not of mechanisms. (Even then, it's a somewhat loose definition -- is allocating memory a side effect?) If you don't allow closures to escape their declared scope, you can handle closed values as extra parameters. So closures don't mean you suddenly can't write pure functions, it means that some input to the function is pre-determined. In other words, closures have the same implications to purity as parameter binding -- absolutely none.

Re:Alan Kay on the misunderstanding of OOP (1998) by jstimpfle on Friday June 24, 2016 @05:15PM (#11973533)
You are kind-of making my point. It's clearer to use "function" fore pure, mathematical functions, and otherwise "procedure"/"object"/"proxy"/"closure" whatever. Even if some popular languages misuse the term "function".

> Even then, it's a somewhat loose definition -- is allocating memory a side effect?

This is leading nowhere. Is loading a value into a register a side effect? If you care.

Re:Alan Kay on the misunderstanding of OOP (1998) by jdmichal on Friday June 24, 2016 @05:54PM (#11973802)
I mean, if you're only point is that programmers use the term "function" to mean something other than a pure mathematical mapping from one set to another... You won't get any arguments from me.
Re:Alan Kay on the misunderstanding of OOP (1998) by gnaritas on Friday June 24, 2016 @02:06PM (#11972037)
> Technically that's what classes gives you, not objects. But agreed on the sentiment.

No, that's what objects give you. Classes are merely one means of creating objects (others exist), but the benefits come from the objects, not their means of construction.

Re:Alan Kay on the misunderstanding of OOP (1998) by jdmichal on Friday June 24, 2016 @02:14PM (#11972098)
My point is that you can have an OOP language / system that consists entirely of singletons. The ability to create multiple object instances from a template is classes or prototypes or whatever other mechanism. It's not something strictly necessary to OOP.
Re:Alan Kay on the misunderstanding of OOP (1998) by gnaritas on Saturday June 25, 2016 @11:40PM (#11979286)
Yea, I have no idea what you're trying to convey. Additionally, a system built entirely with singletons isn't object oriented, it's procedural with modules.
Re:Alan Kay on the misunderstanding of OOP (1998) by zeveb on Friday June 24, 2016 @10:39AM (#11970078)
> I don't really understand this obsession with messages.

> We're moving away from it. This is not how we program in the 21st century.

Maybe it should be? Languages like Erlang and — to a much lesser extent — Go use message-passing semantics in at least some places.

To paraphrase Chesterton, message-passing has not been tried and found wanting; it's been found unusual and not tried.

Re:Alan Kay on the misunderstanding of OOP (1998) by infinite8s on Friday June 24, 2016 @11:13AM (#11970373)
>> This is not how we program in the 21st century

Sadly, how we program in the 21st century isn't much different to how we programmed in the early 20th century when computers were first invented (at least to a 1st order approach).

Where are the Maxwell equations of Computer Science?

Re:Alan Kay on the misunderstanding of OOP (1998) by ruraljuror on Friday June 24, 2016 @12:35PM (#11971171)
Perhaps this is what you're referring to, but according to Kay they can be found in Lisp.

http://queue.acm.org/detail.cfm?id=1039523

https://www.amazon.com/LISP-Programmers-Manual-Michael-Levin...

Re:Alan Kay on the misunderstanding of OOP (1998) by njharman on Friday June 24, 2016 @12:38PM (#11971204)
Every http request/response is a message.

Every task queue, every AMQP/message system are message based systems.

Modern development is lousy with message based architectures. It's just at the system level and not natively supported paradigm in most languages.

Re:Alan Kay on the misunderstanding of OOP (1998) by tamana on Saturday June 25, 2016 @05:18PM (#11978049)
Message passing (and by extension Smalltalk/Squeak) suffers from LISP disease, the notion that because the system makes no constraints on program structure, it can do anything, and therefore is maximally powerful. But "can do anything" is different from "does anything". In real programs you have to solve performance, security, evolving product features needs, a growing team of contributors , static analysis tools to make global changes to the axioms of the system, all those details that matter when software leaves the lab and enters industry.
Re:Alan Kay on the misunderstanding of OOP (1998) by sb8244 on Friday June 24, 2016 @09:29AM (#11969615)
Is message passing that you're referring to different than the Ruby concept of messages? Objects respond to messages in Ruby, and it is encouraged to think of it that way rather than calling functions.
Re:Alan Kay on the misunderstanding of OOP (1998) by mercer on Friday June 24, 2016 @09:34AM (#11969636)
Is that actually the case in practice? I haven't used Ruby enough to know, but my experience so far is that most of the time the approach is still mostly just plain method calling in practice. I vaguely recall Rails moving away from some usage of method_missing (which I'd argue is one explicit example of message passing vs method calling).

Honest question, btw, I really don't know.

Re:Alan Kay on the misunderstanding of OOP (1998) by cheshire_cat on Friday June 24, 2016 @09:55AM (#11969754)
He said "[...] it is encouraged to think of it that way rather than calling functions."

This is what Sandi Metz talks about when she speaks about message/responsibility centric design vs data-centric design in OOP. The conceptual difference is said to lead to different designs. You don't start out your design by thinking about what data you hold but you think about which responsibilities/roles you have and create objects around those by thinking how they might talk to each other to reach their goals. (I'm currently reading POODR by Sandi Metz, so this is still new to me, if I got anything wrong there then please feel free to correct me)

https://www.practicingruby.com/articles/responsibility-centr...

Re:Alan Kay on the misunderstanding of OOP (1998) by hackits on Friday June 24, 2016 @10:05AM (#11969818)
Another good book if you're interested in actors/behaviour decomposition instead of data decomposition is: Object Design: Roles, Responsibilities, and Collaborations and also https://www.amazon.com/Object-Thinking-Developer-Reference-D...

Also David West Presentation https://www.youtube.com/watch?v=RdE-d_EhzmA

Re:Alan Kay on the misunderstanding of OOP (1998) by mikekchar on Friday June 24, 2016 @10:27AM (#11969986)
I personally don't know how it is implemented under the hood, but it is important to understand as a Ruby programmer that methods are not just functions. In fact functions are not really first class entities in Ruby. Instead you have a mishmash of procs, blocks, instance methods and class methods and they are all different to a certain degree. It's one of the big frustrations of programming in Ruby sometimes.

But when it comes down to it what really is message passing? You have a reference to an object, a method name and a collection of parameters. When you dispatch the message you look for the method on the object and run the function passing in the parameters. Does it matter if you optimise the situation by placing the parameters on a stack and using a dictionary with a reference to the method? Or if you optimise by doing static analysis to look up the method and replace the dispatch with a direct call to the method? Or if you optimise further by inlining the code altogether?

The point is not how it is implemented but how the programmer thinks of it. Object Oriented programming is a thing humans do, not a thing computers do. Object Oriented Programming Languages have features that make it more convenient to do Object Oriented programming. Whether the code is OO or not is only up to the programmer, not the compiler/interpreter.

Having said all that, is Ruby my first choice for (what I understand to be) Alan Kay's model of OOP? No. But then I really don't know what my first choice would be. It is possible that the language hasn't been written yet ;-)

Re:Alan Kay on the misunderstanding of OOP (1998) by al2o3cr on Friday June 24, 2016 @07:44PM (#11974368)
Anything you can call with `foo.bar` you can also call with `foo.send(:bar)`. Messages all the way down.

Whether that conforms to Kay's (or your) definition of "message passing" is left to the reader.

Re:Alan Kay on the misunderstanding of OOP (1998) by coldtea on Friday June 24, 2016 @08:43PM (#11974598)
>I don't really understand this obsession with messages. We're moving away from it.

On the contrary. We use it more than ever -- only similarly to Greenspun's tenth rule -- in "ad-hoc" and crappier implementations.

What do you think REST microservices are beneath the surface for example? Or AJAX, WebWorkers, SOAP. Etc. The bad parts of messaging without the flexibility (or even the performance of Smalltalk of the 90s) (Incidentally, Erlang/Elixir gets this right, Akka, etc). Or, all the Rabbit, Duck, Donkey MQs, ZeroMQs, pub/sub, event emitters etc out there.

>This is not how we program in the 21st century

That's more of a problem of the 21st century that messages.

>Besides, this idea of message passing is really not that useful for modern programming anyway but a lot of people still have this weird idea that message passing magically solves the problem of data integrity in parallelism. It doesn't. It does nothing to solve it. You can still have deadlocks and you can still have data corruption.

Deadlocks are not related to data integrity, so they're another story. As for "data corruption", messages where values are copied (and thus immutable) are not really prone to it compared to "how we program in the 21st century".

Re:Alan Kay on the misunderstanding of OOP (1998) by lbenes on Friday June 24, 2016 @12:36PM (#11971185)
No, message passing doesn’t solve all the problem of parallelism, but it is one of the most powerful and useful tools to have in our toolkit when attacking these problems.

I hope it doesn’t dominate as OOP did in the 90s, as many other models such as actor and dataflow still have a lot of room for research and improvement.

Re:Alan Kay on the misunderstanding of OOP (1998) by chc on Friday June 24, 2016 @02:04PM (#11972018)
Actors are based on message-passing as well. The paradigm favored by Go and Erlang is CSP, which is a pretty interesting idea that revolves around message-passing, but it doesn't have a monopoly on the practice.
Re:Alan Kay on the misunderstanding of OOP (1998) by notduncansmith on Friday June 24, 2016 @01:02PM (#11971481)
Message-passing is a necessary but insufficient abstraction. It's not pixie dust, but if you want to build a robust and organized system you'll probably want to reach for it. For the data integrity issue, you need to have a strong data model implemented upon your message-passing architecture, like an immutable event log. Project useful aggregations and indices from that. I'm wrapping up an implementation of exactly this today (Node.js + Kafka = poor man's Erlang actors), AMA. Email is in my profile as well.
Re:Alan Kay on the misunderstanding of OOP (1998) by jrochkind1 on Friday June 24, 2016 @09:04AM (#11969476)
> The last popular language that supported this paradigm (Objective C)

Ruby.

Re:Alan Kay on the misunderstanding of OOP (1998) by somethingsimple on Friday June 24, 2016 @12:01PM (#11970839)
This is anecdotal, but my 8-year old daughter found it quite intuitive to learn programming based on message passing (on Scratch).
Re:Alan Kay on the misunderstanding of OOP (1998) by watchxxx on Friday June 24, 2016 @03:57PM (#11972937)
Well said Cedric!