This report is a an introduction to the BETA language. The BETA language is presented to someone who is familiar with one or more object-oriented language such as C++ or Eiffel.
The overall aspects of the BETA language is presented. The presentation focuses on the concepts and ideas behind the design of BETA, and includes examples on the use of most constructs. The tutorial contains sections on basic constructs, patterns and objects, singular objects, subprocedure, control patterns, nested patterns, virtual patterns, coroutines, concurrency, and inheritance.
For more details about the BETA language than presented in this tutorial please see [MMN 93]. For a tutorial on the Mjølner System, please see [MIA 94-24]
This introduction is based on a chapter in the book [Knudsen 94] written by Ole Lehrmann Madsen.
BETA is a modern object-oriented language from the Scandinavian school of object-orientation where the first object-oriented language Simula was developed. BETA supports the object-oriented perspective on programming and contains comprehensive facilities for procedural and functional programming. BETA has powerful abstraction mechanisms for supporting identification of objects, classification and composition. BETA is a strongly typed language like Simula, Eiffel and C++ with most type checking being carried out at compile-time. It is well known that it is not possible to obtain all type checking at compile time without sacrificing the expressiveness of the language. BETA has an optimum balance between compile-time type checking and run-time type checking.
BETA has powerful abstraction mechanisms that provide excellent support for design and implementation, including data definition for persistent data. The powerful abstraction mechanisms greatly enhance reusability of designs and implementations.
The abstraction mechanisms include class, procedure, function, coroutine, process, exception and many more, all unified into the ultimate abstraction mechanism: the pattern. In addition to the pattern, BETA has subpattern, virtual pattern and pattern variable. This unification gives a uniform treatment of abstraction mechanisms and a number of new ones. Most object-oriented languages have classes, subclasses and virtual procedures, and some have procedure variables. Since a pattern is a generalization of abstraction mechanisms like class, procedure, function, etc., the notions of subpattern, virtual pattern and pattern variable also apply to these abstraction mechanisms. In addition to the above mentioned abstraction mechanisms, the pattern subsumes notions such as generic package and task type as known from Ada.
The subpattern covers subclasses as in most other object-oriented languages. In addition, procedures may be organized in a subprocedure hierarchy in the same way as classes may be organized in a subclass hierarchy. Since patterns may also be used to describe functions, coroutines, concurrent processes, and exceptions, these may also be organized in a pattern hierarchy.
The notion of virtual pattern covers virtual procedures as in C++. In addition, virtual patterns cover virtual classes, virtual coroutines, virtual concurrent processes, and virtual exceptions. Virtual classes provide a more general alternative to generic classes as in Eiffel or templates as in C++.
BETA includes the notion of pattern variable. This implies that patterns are first class values, that may be passed around as parameters to other patterns. By using pattern variables instead of virtual patterns, it is possible dynamically to change the behavior of an object after its generation. Pattern variables cover procedure variables (i.e. a variable that may be assigned different procedures). Since patterns may be used as classes, it is also possible to have variables that can be assigned classes, etc.
BETA does not only allow for passive objects as in C++ and Eiffel. BETA objects may also act as coroutines, making it possible to model alternating sequential processes and quasi-parallel processes. BETA coroutines may be executed concurrent (non pre-emptive scheduling in current implementation). The basic mechanism for synchronization is semaphores, but high-level abstractions for synchronization and communication, hiding all details about semaphores, are easy to implement, and the standard library includes monitors, and rendezvous. The user may easily define new concurrency abstractions including schedulers for processes.
BETA supports the three main subfunctions of abstraction: identification, classification, and composition as described in the following.
It is possible to describe objects that are not generated as instances of a class pattern, so-called 'class-less objects'. This is in many cases useful when there is only one object of a kind. In most object-oriented languages, it is necessary to define superfluous classes for such objects. In analysis and design, it is absolutely necessary to be able to describe singular objects without having them as instances of classes.
Classification is supported by patterns, subpatterns, and virtual patterns that make it possible to describe classification hierarchies of objects and patterns (objects, classes, procedures, functions, coroutines, processes, exceptions, etc.).
Objects and patterns may be defined as a composition of other objects and patterns. The support for composition includes:
In BETA, inheritance is not only restricted to inheritance from superpatterns. It is also possible to inherit from a part-object. Virtual patterns in the part-object may be redefined to influence the enclosing object. Multiple inheritance is supported through inheritance from multiple part-objects. This gives a much cleaner structure than inheritance from multiple superpatterns.
BETA is intended for modeling and design as well as implementation. During the design of BETA the development of the underlying conceptual framework has been just as important as the language itself.
BETA is a language for representing/modeling concepts and phenomena from the application domain and for implementing such concepts and phenomena on a computer system. Part of a BETA program describes objects and patterns that represent phenomena and concepts from the application model. This part is said to be representative since BETA elements at this level are meaningful with respect to the application domain. Other parts of a BETA program are non-representative, since they do not correspond to elements of the application domain, but are intended for realizing the model as a computer system.
The BETA language as presented in this introduction is for describing objects and patterns. The objects and patterns constitute the logical structure of a program execution. The physical structure of a program execution is handled by other components of the Mjølner System. A tutorial on using the this system is given in [MIA 94-24].
BETA Language Introduction | © 1994-2002 Mjølner Informatics |
[Modified: Saturday October 21st 2000 at 18:34]
|