Foundational Features of Programming Languages

Analysis Requirements & Principles architecture:
Paradigms
substance:
Abstractions
structure:
Domains
building blocks: Features surface:
Syntactics
Defining PLs Language
List
foundational safety flexibilized

 Features that extend or elaborate the model of computation[^], i.e., the "ontological foundation" of the programming language
  1. Inheritance and Delegation Mechanisms
  2. Other Mechanisms, etc.

 
If you know further references, please don't hesitate to tell me (Ulf Schünemann), likewise if you have any suggestions.

Inheritance and Delegation Mechanisms

C.f. subtyping.
  1. Inheritance mechanisms on the class level: subclassing, behavioral extension, mixin, features, type-oriented, extension hierarchies
  2. Delegation: sound delegation, encapsulated inheritance, viewpoints, traits, wixins
  3. Forwarding: environmental acquisition, fashioning
  4. Constraint slots
Feature Description Argument
1. Class-based inheritance -- the reuse mechanism in classical OO. Classes, the generators of object, are at a different level than their instances, the objects (see the following entries up to Delegation). [C/OInh]
(+) clear distinction: inheritable classes with specialization interface, vs. objects with client interface.
1.1 Subclassing

Common in Simula, Smalltalk, C++, Eiffel, Java etc

A new class C (the subclass) is defined by a list of superclasses S (having members MS) and own member definitions D (for members MD). C inherits MS-MD from S; overrides the intersection of MS and MD with D; extends MS by MD-MS.
[SplitO]: Inheriting leads to sharing method properties with S and to sharing attribute names/definitions.
(+) A class does not need to prepare for subclassing [Mix]
(+) The behavior of an operation in a subclass can be completely different [Mix]
(-) The superclass cannot control it [Mix]
(-) The increments of a subclass cannot be reused independently from the superclass [Mix]
(-) Cannot extend existing (persistent) instances, or instances created in legacy code [CombiInhHier]
W.r.t. overriding, the following approaches can be distinguished (c.f. [Strongtalk] Gilda Bracha, David Griswold: Strongtalk: Typechecking Smalltalk in a Production Environment; 215-230 OOPSLA'93):
a. invariant overriding
in Modula-3
signature of new method must be unchanged to old one (-) most inflexible
(+) modular type-safety
b. covariant result overriding
in Simula, C++
only result can be changed, to subtype (~) could be more flexible
(+) modular type-safety
c. subtype overriding
in Trellis
result can be changed to subtype, parameters to supertypes (-) relaxing parameters is not the ``natural'' direction of program development ... c.f. Bertrand Meyer
(+) modular type-safety
d. F-bounded (e.g. matching) overriding
in Strongtalk, PolyTOIL, TOOPL
parameters (and results) can be MyType, i.e. always the same type as self (+/-) only in conjunction with separation of subtyping and subclassing
(+) modular type-safety
e. Covariant overriding
in Eiffel
parameters and results can be changed to subtypes (~) type-save, but not modular: requires system-wide check
f. Covariant overriding with dynamic overloading
in O2(?), KOOL [OOPUA]
as in (e), but if parameter at run-time is not of the subtype, the the inherited method is executed. (-) runtime tags
(+) type-save
(+) easy to generalize to multiple dispatch
g. Unlimited overriding
in Smalltalk, Self
all changes are allowed (+) most flexible
(-) not type-save
1.2 Behavioral extension

In Beta

Like subclassing, but instead of overriding an operation, the inherited operation calls the new code via inner. [Mix]:
(-) A class needs to prepare for subpatterns.
(+) A superclass controls at which point the behavior of an operation is ``extended.''
(-) The increments of a subclass cannot be reused independently from the superclass.
1.3 Mixins

As an extension to Modula-3: [Mix] G Bracha, W Cook: Mixin-based Inheritance; OOPSLA/ECOOP'90

A mixin is a subclass without a fixed superclass (virtual superclass). [Mix]:
(+) A class does not need to prepare for subclassing.
(+) The behavior of an operation can be changed completely.
(+) A mixin can be reused with several superclasses.
1.4 Feature-oriented programming

As an extension to Java: C Prehofer: Feature-Oriented Programming: A Fresh Look at Objects; ECOOP'97

Features are similar to mixins/subclasses. Lifters define how the operations from two features are merged when they are combined for the instantiation of an object (or the definition of a class). E.g. a stack lifted to a counter:
feature Stack implements IStack {...}
feature Counter implements ICounter {...}
feature Counter lifts IStack
{  pop() { decr(); super.pop(); } }
  • (+) Modularity: The handling of interaction between features is factored out into the lifters.
  • 1.5 Type-oriented programming (cf. type classes)

    As a proposal for Java: K De Volder, W De Meuter: Type Oriented Programming; [LSDF97]

    For Java: An operation (contains) can be added to all types T of enumerating containers with comparable elements El:
    any T implements Searchable<El>
    whenever
    T implements Enumerable<El>
    and El implements Equality
    { bool contains(El e) {...} }
    (+) Methods (e.g. contains) can be added generically to existing classes only requiring that they implement certain interfaces.
    1.6 Extension hierarchies

    [CombiInhHier] Harald Ossher, Wiiliam Harrison: Combination of Inheritance Hierarchies; OOPSLA'92.

    Hierarchies of class extensions exist in parallel to the (base) hierarchy of classes. Adding an extension E for class C to the application works like renaming C to C' and adding class C inherit C' extendby E. (+) Possible extensions of a class collected in libraries can be combined as needed.
    (+) Existing classes, their instances created in legacy code, and their persistent instances can be extended.

    2.1 Delegation (object-based inheritance)

    In delegation-based languages
    [InhMod] F J Hauck: Inheritance Modeled with Explicit Bindings: An Approach to Typed Inheritance; OOPSLA'93.

    Delegation is a method forwarding mechanism entailing property sharing of methods and variables (not just their declarations!) [SplitO].
    Methods delegated from A to object B are executed in A's context (not in B's, as in Forwarding) [EnvAcq]

    (A) --super--> (B)
     ^------self----'
    			
    [InhMod]
    (+) sharing variables useful for JoeAsSportsman delegating to JoeAsPerson [SplitO]
    (-) breaches encapsulation. ``Full access to an object's properties can be gained ... by creating a child of it'' [SplitO] No distinction between client and inheritor: A object cannot hilde its specialization interface [C/OInh].
    2.2 Sound Delegation

    In prototype systems (KR), actor systems (Act1), framebased systems (Y3)

    [SplitO]: A kind of copy-on-write: Before the delegator writes an inherited variable a new variable is created for it. [SplitO]:
    (+) The frontiers between objects are clear.
    2.3 Encapsulated Inheritance

    [C/OInh] P Steyaert, W DeMeuter: A Marriage of Class- and Object-Based Inheritance Without Unwanted Children; ECOOP'95.

    Only the object itself can define new objects inheriting from itself. For this mixin-methods are used. (+) No client can access the specialization interface, it is encapsulated within the object.
    2.4 Viewpoints

    [DelegInSplit] D Bardou, C Dony: Split Objects: a Disciplied Use of Delegation within Objects; OOPSLA'96.

    Delegating objects are viewpoints (aspects, roles) organized in a property-sharing delegation hierarchy. Viewpoints and delegators together are the ``pieces'' (of the representation) of a ``split object''. ``Pieces do not have an objects status, whereas split objects do.'' In a message send the viewpoint must be named. self = the split object receiver, thisViewpoint = the used viewpoint. (+) solves the question of the identity of viewpoint objects.
    (+) ``may perhaps be a well-adapted tool for the implementation of role models''
    2.5 Prototypes + Traits

    [PWoC] D Ungar et.al.: Organizing Programs Without Classes; Lisp and Symbolic Computation 4(3); 1991.
    see also Self

    Prototype objects are the objects replicated for cloning. Trait objects are parent objects, not cloned but shared among descendents; they represent classes. (+) Traits requires no additional language support. Concrete data type = prototype + trait; abstract data type = trait; singleton = prototype.
    (+) dynamic migration to another class = redirecting the trait reference.
    2.6 Wixins

    Sheldon Nicholi: Wixins: a new object model.; JOOP Nov/Dec'99.

    A wrapper object corresponding to a mixin (static). The parent pointer `inner' (corresponding to a mixin's static `super' parameter) can be changed dynamically. ...

    3 Forwarding Methods forwarded from A to object B are executed in B's context (not in A's as in Delegation) [EnvAcq]

    (A) --fwd--> (B) ------.
                  ^--self--'
    			
    (+) B is reused as an encapsulated black-box.
    (-) internal working of B's method cannot be adapted (by overriding methods).
    3.1 Environmental Acquisition (forwarding part -> whole)

    [EnvAcq] J Gil, D H Lorenz: Environmental Acquitision -- A New Inheritance-Like Abstraction Mechanism; OOPSLA'96.

    An object (e.g a part) acquires attributes and methods from its environment (e.g its whole). Class defines (1) features mandatoryily or optionally to be acquired, (2) default implementation for optionally acquired feature, (3) specialization of acquired feature. (+) supports graphics: when car changes color, so do its doors.
    (+) forwarding to environment less complex than delegation.
    (!) the acquirer cannot substitute the acquiree.
    3.2 Fashioning (forwarding whole -> part)

    [Fash] G Moerkotte, A Zachmann: Multiple Substitutability Without Affecting the Taxonomy; 120-135; EDBT'92, LNCS 580.

    Whole forwards requests to its part, if it used in place of a part without exposing the part. (+) aGasStationAttendant .fillup (myPorsche) more natural than aGasStationAttendant .fillup (myPorsche .getGastank())
    (+) A department object can substitute for an employee by forwarding to a representative.

    navigation bar: Coupling
  • coupling relations / bonds
  • quantity-dependency system view
  • object change propagation systems
  • object constraint programming
  • Object Constraint Programming in Object Change Propagation Systems

    4. Constraints / always-statements
    (as features/ members/ attributes/ slots of an object) in Garnet [DeclOO] and [SAOS].
  • [DeclOO] B Myers, D Guise, B Zanden: Declarative programming in a prototype-instance system: object-oriented programming without writing methods; OOPSLA'92.
  • [SAOS] Toshimi Minoura, Shirish S Pargaonkar, Kurt Rehfuss: Structural Active Object Systems for Simulation; 338-355 OOPSLA'93]
  • [CstrPat] Bruce Horn: Constraint Patterns As a Basis For Object Oriented Programming; 218-234 OOPSLA'92.
  • In [DeclOO]: Constraints. «A constraint is a relationship that is declared once and then maintained automatically by the system.» «[C]onstraints are automatically evaluated when necessary, rather than requiring the programmer to invoke them at appropreate times ... [They] have no side-effect.»

    In [SAOS]: Always-statements are ``equational assignment statements.'' «The execution of the always statement should be triggered whenever any of the variables used in the expression of the always statement changes.»

    In [CnstrPat]: Constraint equations in classes / methods are maintained in the object's lifetime / during (and after) method execution. Equations are solved by augmented term rewriting. Only attributes not declared fixed in the method ("event pattern") are changed to maintain the constraints.

    «[P]rogramming with constraints is a different style from programming with methods ... By focusing on data values, constraints make programming more data oriented, rather than procedure oriented.» The programmer is neither forced to fix the order of execution, nor has to care avoiding repeated (cyclic) update calls.
    «Any slot can get its value from any slot of any other object through constraints. Therefore, the constraints can be used as a form of inheritance. Of course, constraints are more powerful than conventional inheritance since they can perform arbitrary transformations on the values.» [DeclOO]

    Other Mechanisms, etc.

    Note: In pure descriptions no argument or rationale is given besides the description of the feature.

    Some proposals describing new features for ISO C can be found in the ISO C Standard.
    Feature Description Argument
    exception handling mechanism

    [1] Wong, Ooi: Treating failure as a value; 29-32: SIGPLAN Notices 25/1, ACM Jan 1990.
    [2] Meek: Failure is not just one value; 80-83: Sigplan Notices 25/8; ACM Aug 1990.
    [3] Wong, Ooi: Treating Failure as State; SIGPLAN Notices 25/8, 1990.
    [4] Stroustroup's C++PL 3rd edition, ch 14
    [5] Patrick Doyle (doylep@ecf.toronto.edu):
    Message-ID EKq5AL.DpL@ecf.toronto.edu
    Subject: Exception Handling in OO?
    In: comp.object
    Date: 5 Dec 1997.

    When an exception is raised (throw in C++), computation switches to "exceptional mode" and continues with special "exception handling code" (catch in C++).
    1. exceptional return to caller (without exception information) - eg. Eiffel
    2. throw/catch: throw exception-information back to caller [4]
    3. forward skipping exceptions: An exception sets a flag (state). Then all instructions are skipped until an exception handler is found [3].
    Without MOC-support, the alternative is a convention: Certain result values indicate failure. Then the caller must check the result and branch to error handling
  • «[T]reating failure as a value brings no benefits to anyone» [2]
  • Handling exceptional cases inline with the main code for an algorithm can be very distracting to the readability of the code. Using exceptions in the appropriate places can make the intent of a routine clearer, and move the exceptional cases somewhere else, to be considered only when they are needed. [5]
  • Throw-catch exception handling allows a non-exceptional (mis)use: The code for deeply recursive tree searches may be vastly simplified by "throwing" the found object back to the original caller [4].
  • Forward skipping exceptions: Simple implementation [3].
  • value-based reference schemes
    vs
    OIDs

    [ORM1]

    «Because of reliance on oids, UML does not require entities to have a value-based reference scheme.» ... ... «This can make it impossible to communicate naturally at the instance level, and ignores the real world database application requirement that humans have a verbal way of identifying objects.»
    should your MOC-with-nonlinear-control be based on events or threads

    Why Threads Are A Bad Idea (for most purposes) (8 Slides PS)

    ... Concurrency is fundamentally hard. Only use threads where true CPU concurrency is needed/ Use events for GUIs, distributed systems, low-end servers
    RPC - should different semantics be hidden from programmer?

    Some technical paper from sun?

    ... remote calls (distributed applications) should not look like local calls because failure semantics are totally different.
    weak references

    In Java 1.2: class Reference reifies references

    do not prevent to GC the referent --


    Analysis Requirements & Principles Paradigms Abstractions Domains Features foundational safety flexibile typing Syntactics Defining PLs Language List
    Ulf Schünemann 101297, 140801