The language with no classes…
that taught JavaScript how to be fast.
Self is a tiny, radical programming language from 1986. No classes, no variables, not even an if statement — just objects talking to objects. It sounds impossible. It quietly shaped the code you run every day.
Three ideas. That's the whole language.
Most languages give you classes, instances, variables, constructors, static methods, getters, setters… Self looked at all that and said: what if it's all just objects?
Objects are bags of slots
An object is a list of named slots. A slot holds a value or a method — and reading a slot and calling a method look exactly the same.
Copy, don't instantiate
No classes, no new. Want a new dog? Copy an existing one — the prototype — and change what's different.
Ask your parents
If an object doesn't understand a message, it asks its parent objects. Parents are just slots too, so you can swap them while the program runs.
Learn Self by poking it
Every box below runs real Self, compiled to WebAssembly, right in your browser. Edit anything and press Run (or Ctrl/⌘ + Enter). The steps share one world, so later steps can use what earlier ones made.
Everything is a message
There are no operators in Self, only messages. 3 + 4 sends the message + to the object 3. Binary messages go strictly left to right, so the answer here might surprise you.
Integers never overflow, by the way — try 1000 factorial.
Messages read like sentences
Unary messages (reverse) bind tightest, then binary ones (, joins strings), then keyword messages like copyFrom:UpTo:, whose parts after the first are capitalised.
An object is just slots
Write an object between (| and |). x <- 3 is a slot you can change, y = 4 is constant, and sum = ( … ) is a method. Notice that the method reads x by sending itself the message x.
Make a prototype…
Let's put a dog in the lobby, the object where every program starts. Its parent* slot (the star makes it a parent) gives it the ability to be copied.
…then copy it
No class, no constructor: dog copy makes a new dog with its own slots. Change the copy and the original doesn't mind. Local variables go between bars at the start.
Inherit by delegation, and call "super"
A puppy whose parent is dog gets everything dog can do. resend.speak runs the inherited version — it's what other languages call super.
Change your parents mid-sentence
Because a parent is just a slot, an object can switch who it inherits from while the program runs. Self folks call this dynamic inheritance. Here a shapeshifter starts as a dog and becomes a cat.
No if statement? Blocks!
Square brackets make a block, a piece of code you can pass around (a closure). ifTrue:False: is just a message to true or false, which decide which block to run.
Look inside anything
Self is fully reflective: you can ask any object what slots it has. In the full desktop, every object can be opened in an outliner, read, and edited live — and on-screen things are objects too, called morphs.
A short history of a very influential "failure"
Self never became a mainstream language. Its ideas did — they just moved into other people's languages.
- 1967
Simula invents objects
Ole-Johan Dahl and Kristen Nygaard add classes and objects to a simulation language in Norway. Object-oriented programming is born.
- 1972 – 1980
Smalltalk: everything is an object
Alan Kay, Dan Ingalls, Adele Goldberg and colleagues at Xerox PARC build Smalltalk, a live world of objects sending messages, with windows and a mouse.
- 1986
Self is designed at Xerox PARC
David Ungar and Randall B. Smith ask how simple an object language could be. Their answer throws away classes entirely. The paper "Self: The Power of Simplicity" appears at OOPSLA in 1987.
- 1987 – 1991
Stanford makes it fast
Everyone said a language this dynamic would be hopelessly slow. Craig Chambers, Urs Hölzle and Ungar answered with "maps" (hidden classes), customised compilation and polymorphic inline caches. Self 1.0 ships in 1990, at about half the speed of optimised C.
- 1991 – 1995
At Sun Labs: Morphic and adaptive compilation
The project moves to Sun Microsystems. Self 4.0 brings Morphic — a UI where you grab any on-screen object and change it while it runs — and a compiler that optimises the code you actually use.
- 1995
JavaScript borrows the prototypes
Brendan Eich writes JavaScript at Netscape in about ten days, mixing Scheme's functions with Self's prototype-based objects — wrapped in a Java-like syntax.
- 1994 – 1999
Self's VM team makes Java fast
Former Self people found Animorphic Systems and build Strongtalk, a very fast Smalltalk. Sun buys the company in 1997, and its technology becomes Java's HotSpot virtual machine in 1999.
- 2008
…and then JavaScript
Lars Bak, who worked on Self, Strongtalk and HotSpot, leads Google's V8 engine for Chrome. Hidden classes and inline caches — Self's tricks — are why modern JavaScript is fast. Node.js runs on V8 from 2009.
- Today
Still alive
Self is open source and still maintained by its community. And now there's this: a Self written in Rust that runs in your browser.
Self's family tree
Self has two kinds of children: languages that took its ideas about objects, and virtual machines that took its ideas about speed. Its user interface ideas had children too.
🧬 Prototype languages
⚡ Fast virtual machines
🖱️ Live interfaces
You already know Self. It's hiding in JavaScript.
JavaScript put Self's object model in Java-style clothes. Look past the syntax and it's the same idea: objects that delegate to other objects. Here's the same program in both. (The whole family saga is in the mini book, No, I Am Your Father.)
| rex |
lobby _AddSlots: (|
animal = (| parent* = traits clonable.
speak = ( 'some noise' ) |)
|).
lobby _AddSlots: (|
dog = (| parent* <- animal.
speak = ( resend.speak, '... woof!' ) |)
|).
rex: dog copy.
rex speak. "'some noise... woof!'"
rex parent: animal. "change parents at run time"const animal = {
speak() { return 'some noise'; }
};
const dog = {
__proto__: animal,
speak() { return super.speak() + '... woof!'; }
};
const rex = Object.create(dog);
rex.speak(); // 'some noise... woof!'
Object.setPrototypeOf(rex, animal); // same trick| Idea | Self (1986) | JavaScript |
|---|---|---|
| Inherit from an object | parent* <- animal | __proto__: animal, Object.create(animal) |
| Make a new object | dog copy | Object.create(dog), {...dog} |
| Call the inherited method | resend.speak | super.speak() |
| Change parents at run time | rex parent: animal | Object.setPrototypeOf(rex, animal) |
| Add slots to a live object | dog _AddSlots: (| age <- 3 |) | dog.age = 3 |
| Closures | [| :x | x * 2 ] | x => x * 2 |
| Speed trick: shared layouts | "maps" (1989) | V8's "hidden classes" / "shapes" |
| Speed trick: remember lookups | polymorphic inline caches (1991) | inline caches in V8, SpiderMonkey, JavaScriptCore |
Because the two are so close, Self World can translate Self straight to JavaScript. Write Self and watch the JavaScript appear → Run the result, or download it as a web app: one HTML file that runs your Self program, its objects and its windows in any browser.
Things that sound made up (but aren't)
if. true and false are objects that answer ifTrue:False: by running one block or the other.dog name might read a slot or run a method — the caller can't tell, and doesn't need to.self are so common in Self that you can leave the receiver out: speak on its own means "send speak to myself".Self World on your desktop
The same program as the in-browser desktop, as a native app for macOS, Windows and Linux: outliners, shells, Morphic windows and loading .self files from your disk. Free and open source.
macOS
Open the disk image and drag Self World to Applications. The app isn't signed by Apple yet, so the first time, right-click it and choose Open — or run xattr -dr com.apple.quarantine "/Applications/Self World.app".
Windows
The installer adds Self World to the Start menu, with an uninstaller. If SmartScreen warns about an unknown publisher, choose More info → Run anyway.
Linux
AppImage: chmod +x SelfWorld-Linux-x86_64.AppImage, then run it. The .deb installs with sudo apt install ./SelfWorld-Linux-amd64.deb.
Or run it in your browser — nothing to install. Older versions and release notes: all releases. Building from source works too: see the README.
Ready to play in a world of objects?
Open the full Self World desktop: outliners for every object, a shell, Morphic windows and buttons made of Self objects, bouncing balls, and the original Self file format.