Oberon-2 is an extension of the original Oberon programming language that adds limited reflection and object-oriented programming facilities, open arrays as pointer base types, read-only field export and reintroduces the FOR loop from Modula-2. It was developed in 1991 at ETH Zurich by Niklaus Wirth and Hanspeter Mossenbock, who is now at Institut fur Systemsoftware SSW of the University of Linz, Austria. Oberon-2 is a superset of Oberon, and is fully compatible with it. Oberon-2 was a redesign of Object Oberon. Oberon-2 inherited limited reflection and single inheritance "type extension" ...
ⓘ Oberon (programming language)
Oberon is a general-purpose programming language first published in 1987 by Niklaus Wirth and the latest member of the Wirthian family of ALGOL-like languages. Oberon was the result of a concentrated effort to increase the power of Modula-2, the direct successor of Pascal, and simultaneously to reduce its complexity. Its principal new feature is the concept of type extension of record types: It permits the construction of new data types on the basis of existing ones and to relate them, deviating from the dogma of strictly static data typing. Type extension is Wirths way of inheritance reflecting the viewpoint of the parent site. Oberon was developed as part of the implementation of the Oberon operating system at ETH Zurich in Switzerland. The name is from the moon of Uranus, Oberon.
Oberon is still maintained by Wirth and the latest Project Oberon compiler update is dated Mar 6, 2020.
Oberon is designed with a motto attributed to Albert Einstein in mind:" Make things as simple as possible, but not simpler.” The principal guideline was to concentrate on features that are basic and essential and to omit ephemeral issues. Another factor was recognition of the growth of complexity in languages such as C++ and Ada: in contrast to these, Oberon emphasizes the use of the library concept for extending the language. Enumeration and subrange types, which were present in Modula-2, have been removed; similarly, set types have been limited to small sets of integers, and the number of low-level facilities has been sharply reduced most particularly, type transfer functions have been eliminated. Elimination of the remaining potentially-unsafe facilities concludes the most essential step toward obtaining a truly high-level language. Very close type-checking even across modules, strict index-checking at run time, null-pointer checking, and the safe type extension concept largely allow the programmer to rely on the language rules alone.
The intent of this strategy was to produce a language that is easier to learn, simpler to implement, and very efficient. Oberon compilers have been viewed as compact and fast, while providing adequate code quality compared to commercial compilers.
The following features characterize the Oberon language:
- String operations
- Case sensitive syntax with uppercase keywords
- Support for system programming
- Modules and separate compilation
- Isolation of unsafe code
- Type-extension with type test
3. Object orientation
Oberon supports extension of record types for the construction of abstractions and heterogeneous structures. In contrast to the later dialects - Oberon-2 and Active Oberon - the original Oberon doesnt have a dispatch mechanism as a language feature but rather as programming technique or design pattern. This gives great flexibility in the OOP world. In the Oberon operating system two programming techniques have been used in conjunction for the dispatch call: Method suite and Message handler.
3.1. Object orientation Method suite
In this technique a table of procedure variables is defined and a global variable of this type is declared in the extended module and assigned back in the generic module:MODULE Figures; * Abstract module * TYPE Figure* = POINTER TO FigureDesc; Interface* = POINTER TO InterfaceDesc; InterfaceDesc* = RECORD draw*: PROCEDURE f: Figure; clear*: PROCEDURE f: Figure; mark*: PROCEDURE f: Figure; move*: PROCEDURE f: Figure; dx, dy: INTEGER; END ; FigureDesc* = RECORD if: Interface; END ; PROCEDURE Init* f: Figure; if: Interface; BEGIN f.if:= if; END Init; PROCEDURE Draw* f: Figure; BEGIN f.if.drawf; END Draw; * Other procedures here * END Figures.
We extend the generic type Figure to a specific shape:MODULE Rectangles; IMPORT Figures; TYPE Rectangle* = POINTER TO RectangleDesc; RectangleDesc* = RECORD Figures.FigureDesc x, y, w, h: INTEGER ; END ; VAR if: Figures.Interface; PROCEDURE New* VAR r: Rectangle; BEGIN NEW r; Figures.Initr, if; END New; PROCEDURE Draw* f: Figure; VAR r: Rectangle; BEGIN r:= fRectangle; * f AS Rectangle * *. * END Draw; * Other procedures here * BEGIN * Module initialisation * NEW if; if.draw:= Draw; if.clear:= Clear; if.mark:= Mark; if.move:= Move; END Rectangles.
Dynamic dispatch is only done via procedures in Figures module that is the generic module.
3.2. Object orientation Message handler
This technique consists of replacing the set of methods with a single procedure, which discriminates among the various methods:MODULE Figures; * Abstract module * TYPE Figure* = POINTER TO FigureDesc; Message* = RECORD END ; DrawMsg* = RECORD Message END ; ClearMsg* = RECORD Message END ; MarkMsg* = RECORD Message END ; MoveMsg* = RECORD Message dx*, dy*: INTEGER END ; Handler* = PROCEDURE f: Figure; VAR msg: Message; FigureDesc* = RECORD * Abstract * handle: Handler; END ; PROCEDURE Handle* f: Figure; VAR msg: Message; BEGIN f.handlef, msg; END Handle; PROCEDURE Init* f: Figure; handle: Handler; BEGIN f.handle:= handle; END Init; END Figures.
We extend the generic type Figure to a specific shape:MODULE Rectangles; IMPORT Figures; TYPE Rectangle* = POINTER TO RectangleDesc; RectangleDesc* = RECORD Figures.FigureDesc x, y, w, h: INTEGER; END ; PROCEDURE Draw* r: Rectangle; BEGIN *. * END Draw; * Other procedures here * PROCEDURE Handle* f: Figure; VAR msg: Figures.Message; VAR r: Rectangle; BEGIN r:= fRectangle; IF msg IS Figures.DrawMsg THEN Drawr ELSIF msg IS Figures.MarkMsg THEN Markr ELSIF msg IS Figures.MoveMsg THEN Mover, msgFigures.MoveMsg.dx, msgFigures.MoveMsg.dy) ELSE * ignore * END Handle; PROCEDURE New* VAR r: Rectangle; BEGIN NEW r; Figures.Initr, Handle; END New; END Rectangles.
In the Oberon operating system both of these techniques are used for dynamic dispatch. The first one is used for a known set of methods; the second is used for any new methods declared in the extension module. For example, if the extension module Rectangles were to implement a new Rotate procedure, within the Figures module it could only be called via a message handler.
4.1. Implementations and variants Oberon
No-cost implementations of Oberon the language and Oberon the operating system can be found on the Internet several are from ETHZ itself.
4.2. Implementations and variants Oberon-2
A few changes were made to the first released specification ; the result was Oberon-2, currently the most common implementation. There is a release called Native Oberon which includes an operating system, and can directly boot on PC class hardware. A.NET implementation of Oberon with the addition of some minor.NET-related extensions has also been developed at ETHZ. In 1993 an ETHZ spin off company brought a dialect of Oberon-2 to the market with the name Oberon-L, which was renamed to Component Pascal in 1997.
Oberon-2 compilers maintained by ETH include versions for Microsoft Windows, Linux, Solaris, and classic Mac OS. Furthermore, there are implementations for various other operating systems, such as Atari-TOS or AmigaOS.
There is an Oberon-2 Lex scanner and Yacc parser by Stephen J Bevan of Manchester University, UK, based on the one in the Mossenbock and Wirth reference. It is at version 1.4.
There is also the Oxford Oberon-2 Compiler, which also understands Oberon-07 and Vishap Oberon. The latter is based on Josef Templs Oberon to C transpiler called Ofront, which in turn is based on the OP2 Compiler developed by Regis Crelier at ETHZ.
4.3. Implementations and variants Oberon-07
Oberon-07, defined by Niklaus Wirth in 2007 and revised in 2011, 2013, 2014, 2015 and 2016 is based on the original version of Oberon rather than Oberon-2. The main changes are: explicit numeric conversion functions e.g. FLOOR and FLT must be used, the LOOP and EXIT statements have been eliminated, WHILE statements have been extended, CASE statements can be used for type extension tests, RETURN statements can only be connected to the end of a function, imported variables and structured value parameters are read-only and arrays can be assigned without using COPY. For full details, see The Programming Language Oberon-07.
4.4. Implementations and variants Related languages
Development has continued on languages in this family. A further extension of Oberon-2, originally named Oberon/L but later renamed to Component Pascal, was developed for Windows and classic Mac OS by Oberon microsystems, a commercial company spin-off from ETHZ, and for.NET by Queensland University of Technology. In addition, the Lagoona and Obliq languages carry the Oberon spirit into specialized areas.
Recent.NET development efforts at ETHZ have been focused on a new language called Zonnon. This includes the features of Oberon and restores some from Pascal enumerated types, built-in IO but has some syntactic differences. Additional features include support for active objects, operator overloading and exception handling. Zonnon is available as a plug-in language for the Microsoft Visual Studio for.NET development environment.
Oberon-V originally called Seneca, after Seneca the Younger is a descendant of Oberon designed for numerical applications on supercomputers, especially vector or pipelined architectures. It includes array constructors and an ALL statement.