Oberon-2

Oberon-2
ParadigmsImperative, structured, modular, object-oriented
FamilyWirth Oberon
Designed byNiklaus Wirth
Hanspeter Mössenböck
DeveloperETH Zurich
First appeared1991; 33 years ago (1991)
Typing disciplineStrong, hybrid (static and dynamic)
ScopeLexical
PlatformCeres (NS32032), IA-32, x86-64
OSWindows, Linux, Solaris, macOS
Websitewww.ethoberon.ethz.ch
Influenced by
Oberon, Modula-2, Object Oberon
Influenced
Oberon-07, Zonnon, Active Oberon, Component Pascal, Go, Nim

Oberon-2 is an extension of the original Oberon programming language that adds limited reflective programming (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 Mössenböck, who is now at Institut für Systemsoftware (SSW) of the University of Linz, Austria. Oberon-2 is a superset of Oberon, is fully compatible with it, and was a redesign of Object Oberon.

Oberon-2 inherited limited reflection and single inheritance ("type extension") without the interfaces or mixins from Oberon, but added efficient virtual methods ("type bound procedures"). Method calls were resolved at runtime using C++-style virtual method tables.

Compared to fully object-oriented languages like Smalltalk, in Oberon-2, basic data types and classes are not objects, many operations are not methods, there is no message passing (it can be emulated somewhat by reflection and through message extension, as demonstrated in ETH Oberon), and polymorphism is limited to subclasses of a common class (no duck typing as in Python,[1] and it's not possible to define interfaces as in Java). Oberon-2 does not support encapsulation at object or class level, but modules can be used for this purpose.

Reflection in Oberon-2 does not use metaobjects, but simply reads from type descriptors compiled into the executable binaries, and exposed in the modules that define the types and/or procedures. If the format of these structures are exposed at the language level (as is the case for ETH Oberon, for example), reflection could be implemented at the library level. It could thus be implemented almost entirely at library level, without changing the language code. Indeed, ETH Oberon makes use of language-level and library-level reflection abilities extensively.

Oberon-2 provides built-in runtime support for garbage collection similar to Java and performs bounds and array index checks, etc., that eliminate the potential stack and array bounds overwriting problems and manual memory management issues inherent in C and C++. Separate compiling using symbol files and namespaces via the module architecture ensure fast rebuilds since only modules with changed interfaces need to be recompiled.

The language Component Pascal[2] is a refinement (a superset) of Oberon-2.

  1. ^ "Related Reading". Dr. Dobb's.
  2. ^ Pfister, Cuno (2001). "What's New in Component Pascal (changes from Oberon-2 to CP)" (PDF). Oberon microsystems. Archived from the original (PDF) on 15 May 2011. Retrieved 10 January 2007.