Jump to content

Classless-objects

From Rosetta Code

Classless-based (or class-free) programming is a kind of generalized object using or object-oriented programming which is distinct from what is done in class-based object-oriented languages. With classless, objects can be made directly and created by other objects. One object can be reused by another object without the need for creating any parent class. This model can also be known as classless object-oriented programming (classless OOP or class-less OOP), class-free object-oriented programming (class-free OOP), prototypal, prototype-oriented, or instance-based programming. Since the late 1980s, the classless paradigm has grown increasingly popular. Examples of languages that use the classless paradigm: Self (1987), Oberon-2, MOO, Cecil, NewtonScript, Io, Ioke, Lua, JavaScript, REBOL, AHK (v1), Nim, Go (Golang), Red, Julia, Rust, V (Vlang), and Zen C.

In class-based OOP languages, a new instance is constructed through a class's constructor function, a special function that reserves a block of memory for the object's members (properties and methods) and returns a reference to that block. An optional set of constructor arguments can be passed to the function and are usually held in properties. The resulting instance will inherit all the methods and properties that were defined in the class, which acts as a kind of template from which similarly typed objects can be constructed.

Class-free languages, which use objects, differ in regards to how they create groups of objects with shared behaviors. Moreover, one can distinguish the differences between the concepts in the following four key areas of divergence: 1) object creation, 2) hierarchical structures, 3) how objects share behavior amongst one another and 4) the creation or deletion of an object’s properties. We do not have classes inheriting from other classes, rather objects inherit directly from other objects. We can start with a generalized object, which is a working object instance. In such class-free languages, it can also be possible to assign methods to objects or types, along with having interfaces.

Citation

Cookies help us deliver our services. By using our services, you agree to our use of cookies.