Lably
Skip to content

Prototype-based programming

Style of object-oriented programming in which inheritance is based on reusing objects

  • 12 min read
  • 7 chapters

Related on Lably

Through Object-oriented programming, Inheritance (object-oriented programming) and Object (computer science)

Prototype-based programming uses the process generalized objects, which can then be cloned and extended. Using fruit as an example, a "fruit" object would represent the properties and functionality of fruit in general. A "banana" object would be cloned from the "fruit" object and general properties specific to bananas would be appended. Each individual "banana" object would be cloned from the generic "banana" object. Compare to the class-based paradigm, where a "fruit" class would be extended by a "banana" class.

History

The first prototype-based programming language was Daniel G. Bobrow and Terry Winograd’s KRL. The 1976 Stanford AIM-293 makes it the first language to claim the term object-oriented in the modern sense, the one that formally introduced the term "inheritance" ("of properties"), actually implementing multiple inheritance, and the one that introduced the term "prototype" with the present meaning.

Other early prototype systems include Director a.k.a. Ani (on top of MacLisp) (1976-1979), and contemporaneously and not independently, ThingLab (on top of Smalltalk) (1977-1981), respective PhD projects by Kenneth Michael Kahn at MIT and Alan Hamilton Borning at Stanford (but working with Alan Kay at Xerox PARC). Hewitt's Actors team at MIT added support for Prototype OO to ACT-1 in 1979 based on Kahn's work, calling the underlying mechanism "delegation" to distinguish it from the Class OO support they also added as "inheritance". Borning popularized the word "prototype" in this context in his 1981 paper in ACM Transactions on Programming Languages and Systems (TOPLAS). Meanwhile, Rees and Adams's implemented class-less OO using lexical closures in Yale T Scheme (1981-1989)—they didn't say "prototype", but it was isomorphic. Ken Dickey later published their OO model as portable Scheme code in 1992 as YASOS.

The language that made the name and notion of prototypes popular among academics was Self (1985-1995), developed by David Ungar and Randall Smith. But the language that made prototypes common and ubiquitous is JavaScript (1995–present) by Brendan Eich.

Since the late 1990s, the classless paradigm has grown increasingly popular. Some current prototype-oriented languages are JavaScript (and other ECMAScript implementations such as JScript and Flash's ActionScript 1.0), Lua, Cecil, NewtonScript, Io, Ioke, MOO, Rebol and AutoHotkey (AHK).

Since the 2010s, a new generation of languages with pure functional prototypes has appeared, that reduce OOP to its very core: Jsonnet is a dynamic lazy pure functional language with a builtin prototype object system using mixin inheritance; Nix is a dynamic lazy pure functional language that builds an equivalent object system (Nix "extensions") in just two short function definitions (plus many other convenience functions). Both languages are used to define large distributed software configurations (Jsonnet being directly inspired by GCL, the Google Configuration Language, with which Google defines all its deployments, and has similar semantics though with dynamic binding of variables). Since then, other languages like Gerbil Scheme have implemented pure functional lazy prototype systems based on similar principles.

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Computing and communication