Languages / The durable layer

1967

Objects and Messages

Bundle state with the behavior that guards it.

As a program grows, the data and the code that keeps that data sane tend to drift apart, until anything can corrupt anything from anywhere. The idea of the object is to fuse them: hide state behind an interface, so the only way to touch it is to go through the behavior that protects its invariants.

The people who saw it first

  • Kristen Nygaard came to this from operations research, running simulations of messy real systems — ships queuing for a harbour, parts moving through a factory — and hating that his code was a soup of loose variables with no way to mirror the actual things he was modelling. With Ole-Johan Dahl in Oslo he built Simula so a program could hold a little stand-in for each ship and each berth, every one carrying its own state and behaviour. Classes, objects and inheritance were invented to simulate reality — which is exactly why an “object” still maps so cleanly onto a “thing in the world.” (Turing Award, 2001.)
  • Alan Kay had studied molecular biology before computing, and at Xerox PARC around 1972 he pictured software the way he pictured cells: vast numbers of tiny, self-contained units that never reach into one another and cooperate only by sending messages. His Smalltalk made that literal. The lasting lesson is the one people keep missing: for Kay the point was never classes, it was messaging and late binding. He has said he regrets the word “object” and wishes he had called the whole thing “messaging.” (Turing Award, 2003.)

Side by side, and a bridge

A C struct is data with no guard: any code can reach in and break it. A Simula or Smalltalk object hides its state and exposes behavior. And here is the bridge that ties this whole spine together: Erlang and The Actor Model are Kay’s messaging idea taken to its limit. An actor is an object you can only reach by sending it a message, that shares no memory with anyone, and that runs concurrently. Encapsulation becomes isolation, and isolation is what made Failure survivable.

Why it endures

The genuinely good part of OO — encapsulation and interfaces — is everywhere. And Kay’s deeper point, messaging over shared state, is exactly the principle behind actors, microservices, and message-driven systems today.

The shape of it

"Smalltalk — everything is an object; you compute by sending messages."
| account |
account := Account new.
account deposit: 100.
account withdraw: 30.
Transcript showCr: 'balance: ', account balance printString.

[!recall] Alan Kay said the big idea of OO was not “objects.” What was it, and why does it matter? Messaging and late binding: an object is defined by the messages it responds to, not its internals, and the binding is resolved at run time. It matters because that is what delivers real encapsulation and decoupling — and it is the same idea that scales up into actors (Erlang), microservices, and message-driven architectures, where isolation between message-passing components is the whole point.

Sources

See also: Smalltalk, The Actor Model, Erlang, ALGOL, C.