Prototype-based programming

related topics
{math, number, function}
{system, computer, user}
{theory, work, human}
{woman, child, man}
{language, word, form}
{style, bgcolor, rowspan}

Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse (known as inheritance in class-based languages) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as class-less, prototype-oriented or instance-based programming. Delegation is the language feature that supports prototype-based programming.

The original, and most canonical, example of a prototype-based language is the programming language Self developed by David Ungar and Randall Smith. Since the late 1990s, the classless programming style has grown increasingly popular, and has been adopted for the languages JavaScript, ActionScript, Cecil, NewtonScript, Io, MOO, REBOL, Lisaac, Lua and several others.

Contents

Comparison with class-based models

With class-based languages, the structure of objects is specified in programmer-defined types called classes. While classes define the type of data and functionality that objects will have, instances are "usable" objects based on the patterns of a particular class. In this model, classes act as collections of behavior (methods) and structure that are the same for all instances, whereas instances carry the objects' data. The role distinction is thus primarily based on a distinction between structure and behavior on the one hand, and state on the other.

Advocates of prototype-based programming often argue that class-based languages encourage a model of development that focuses first on the taxonomy and relationships between classes. In contrast, prototype-based programming is seen as encouraging the programmer to focus on the behavior of some set of examples and only later worry about classifying these objects into archetypal objects that are later used in a fashion similar to classes. As such, many prototype-based systems encourage the alteration of prototypes during runtime, whereas only very few class-based object-oriented systems (such as the dynamic object-oriented system, Common Lisp, Smalltalk, Python, Perl, or Ruby) allow classes to be altered during the execution of a program.

Full article ▸

related documents
Comparison of Java and C++
Interpreter (computing)
Java Database Connectivity
Cryptanalysis
INTERCAL
Linear
Character encodings in HTML
Automated theorem proving
Bresenham's line algorithm
Heapsort
Hilbert's second problem
Mersenne twister
Cardinality
Tychonoff space
Banach fixed point theorem
Inverse limit
Separation axiom
Gamma function
Golomb coding
Quine (computing)
Probability space
Search algorithm
Separable space
Mersenne prime
Linear equation
Exact sequence
Division algebra
Constant of integration
Supervised learning
Julia set