ArticleslgStudy

computer science

Self (programming language)

Self (programming language) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Self (programming language) rather than just read about it. In short: Self is a general-purpose, high-level, object-oriented programming language based on the concept of prototypes. Self began as a dialect of Smalltalk, being dynamically typed and using just-in-time compilation (JIT) with the prototype-based approach to objects: it was first used as an experimental test system for language design in the 1980s and 1990s.

Self (programming language) — main illustration
Self (programming language) — illustration

Key takeaways

  • Self (programming language) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Self (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Self (programming language) from memory before moving on to harder problems.

Reference excerpt

Self is a general-purpose, high-level, object-oriented programming language based on the concept of prototypes. Self began as a dialect of Smalltalk, being dynamically typed and using just-in-time compilation (JIT) with the prototype-based approach to objects: it was first used as an experimental test system for language design in the 1980s and 1990s. In 2006, Self was still being developed as part of the Klein project, which was a Self virtual machine written fully in Self. The latest version, 2024.1 was released in August 2024. Several just-in-time compilation techniques were pioneered and improved in Self research as they were required to allow a very high-level object-oriented language to perform at up to half the speed of optimized C. Much of the development of Self took place at Sun Microsystems, and the techniques they developed were later deployed for Java's HotSpot virtual machine. At one point a version of Smalltalk was implemented in Self. Because it was able to use the JIT, this also gave extremely good performance.

History Self was designed mostly by David Ungar and Randall Smith in 1986 while working at Xerox PARC. Their objective was to advance the state of the art in object-oriented programming language research, once Smalltalk-80 was released by the labs and began to be taken seriously by the industry. They moved to Stanford University and continued work on the language, building the first working Self compiler in 1987. Then, focus changed to working to build a full system for Self, in contrast to only the language. The first public release was in 1990, and the next year the team moved to Sun Microsystems where they continued work on the language. Several new releases followed until falling largely dormant in 1995 with version 4.0. In 2006, version 4.3 was released, for Mac OS X and Solaris. in 2010, a new release, version 4.4, was developed by a group comprising some of the original team and independent programmers, for Mac OS X and Linux, as are all later versions. In January 2014, a follow-up, 4.5 was released, and three years later, version 2017.1 was released in May 2017. The Morphic user interface construction environment was originally developed by Randy Smith and John Maloney for the Self programming language. Morphic has been ported to other notable programming languages including Squeak, JavaScript, Python, and Objective-C. Self also inspired a number of languages based on its concepts. Most notable, perhaps, were NewtonScript for the Apple Newton and JavaScript used in all modern browsers. Other examples include Io, Lisaac and Agora. The IBM Tivoli Framework's distributed object system, developed in 1990, was, at the lowest level, a prototype-based object system inspired by Self.

Prototype-based programming languages

Traditional class-based OO languages are based on a deep-rooted duality:

Classes define the basic qualities and behaviours of objects. Object instances are particular manifestations of a class. For example, suppose objects of the Vehicle class have a name and the ability to perform various actions, such as drive to work and deliver construction materials. Bob's car is a particular object (instance) of the class Vehicle, with the name "Bob's car". In theory, one can then send a message to Bob's car, telling it to deliver construction materials. This example shows one of the problems with this approach: Bob's car, which happens to be a sports car, is not able to carry and deliver construction materials (in any meaningful sense), but this is a capability that Vehicles are modelled to have. A more useful model arises from the use of subclassing to create specializations of Vehicle; for example Sports Car and Flatbed Truck. Only objects of the class Flatbed Truck need to provide a mechanism to deliver construction materials; sports cars, which are ill-suited to that sort of work, need only drive fast. However, this deeper model requires more insight during design, insight that may only come to light as problems arise. This issue is one of the motivating factors behind prototypes. Unless one can predict with certainty what qualities a set of objects and classes will have in the distant future, one cannot design a class hierarchy properly. All too often the program would eventually need added behaviours, and sections of the system would need to be re-designed (or refactored) to break out the objects in a different way. Experience with early OO languages like Smalltalk showed that this sort of issue came up again and again. Systems would tend to grow to a point and then become very rigid, as the basic classes deep below the programmer's code grew to be simply wrong. Without some way to easily change the original class, serious problems could arise. Dynamic languages such as Smalltalk allowed for this sort of change via well-known methods in the classes; by changing the class, the objects based on it would change their behaviour. However, such changes had to be done very carefully, as other objects based on the same class might be expecting this wrong behavior: wrong is often dependent on the context. (This is one form of the fragile base class problem.) Further, in languages like C++, where subclasses can be compiled separately from superclasses, a change to a superclass can actually break precompiled subclass methods. (This is another form of the fragile base class problem, and also one form of the fragile binary interface problem.) In Self, and other prototype-based languages, the duality between classes and object instances is eliminated. Instead of having an instance of an object that is based on some class, in Self, one makes a copy of an existing object, and changes it. So Bob's car would be created by making a copy of an existing Vehicle object, and then adding the drive fast method, modelling the fact that it happens to be a Porsche 911. Basic objects that are used primarily to make copies are known as prototypes. This technique is claimed to greatly simplify dynamism. If an existing object (or set of objects) proves to be an inadequate model, a programmer may simply create a modified object with the correct behavior, and use that instead. Code which uses the existing objects is not changed.

Description Self objects are a collection of slots. Slots are accessor methods that return values, and placing a colon after the name of a slot sets the value. For example, for a slot called "name",

returns the value in name, and

… excerpt ends here. Continue reading the full article.

Illustrations

Self (programming language) illustration

Worked examples

Example 1 — a first encounter with Self (programming language)

Start with the simplest possible case. Write down what Self (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Self (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Self (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Self (programming language)

In research
Self (programming language) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Self (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Self (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1987 software, Cross-platform free software, Dynamic programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Self (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Self (programming language)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Self (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Self (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Self (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Self (programming language) in simple terms?

Self is a general-purpose, high-level, object-oriented programming language based on the concept of prototypes. Self began as a dialect of Smalltalk, being dynamically typed and using just-in-time compilation (JIT) with the prototype-based approach to objects: it was first used as an experimental t…

Why does Self (programming language) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Self (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Self (programming language).

Tags

  • 1987 software
  • Cross-platform free software
  • Dynamic programming languages
  • Dynamically typed programming languages
  • Free and open source compilers
  • Object-oriented programming languages
  • Programming languages
  • Programming languages created in 1987
  • Prototype-based programming languages
  • Software using the BSD license

Keep exploring