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), class-free object-oriented programming (class-free OOP), prototypal, prototype-oriented, or instance-based programming. Since the late 1990s, the classless paradigm has grown increasingly popular. Some of the languages which use the classless paradigm are Oberon-2, JavaScript, Lua, Go (Golang), Rust, Cecil, NewtonScript, Io, Ioke, MOO, REBOL, V (Vlang), and AHK.

In class-based 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.

Classless-based languages 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 don’t 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. It can also be possible to assign methods to objects.

Citation