This article'suse ofexternal links may not follow Wikipedia's policies or guidelines. Pleaseimprove this article by removingexcessive orinappropriate external links, and converting useful links where appropriate intofootnote references.(November 2024) (Learn how and when to remove this message) |
| Oberon | |
|---|---|
| Paradigms | Imperative,structured,modular,object-oriented |
| Family | Wirth Oberon |
| Designed by | Niklaus Wirth |
| Developer | Niklaus Wirth |
| First appeared | 1987; 38 years ago (1987) |
| Stable release | Oberon-07 / 6 March 2020; 5 years ago (2020-03-06) |
| Typing discipline | Strong, hybrid (static anddynamic) |
| Scope | Lexical |
| Platform | ARM,StrongARM;IA-32,x86-64;SPARC,Ceres (NS32032) |
| OS | Windows,Linux,Solaris,classic Mac OS,Atari TOS,AmigaOS |
| Website | projectoberon |
| Influenced by | |
| Modula-2 | |
| Influenced | |
| Oberon-2,Oberon-07,Active Oberon,Component Pascal,Zonnon,Go,V (Vlang),Nim | |
Oberon is a general-purposeprogramming language first published in 1987 byNiklaus Wirth and the latest member of the Wirthian family ofALGOL-like languages (Euler,ALGOL W,Pascal,Modula, andModula-2).[1][2][3][4] Oberon was the result of a concentrated effort to increase the power ofModula-2, the direct successor ofPascal, and simultaneously to reduce its complexity. Its principal new feature is the concept ofdata type extension ofrecord types.[5] It permits constructing new data types on the basis of existing ones and to relate them, deviating from the dogma of strictstatic typing of data. Type extension is Wirth's way of inheritance reflecting the viewpoint of the parent site. Oberon was developed as part of the implementation of anoperating system, also namedOberon atETH Zurich inSwitzerland. The name was inspired both by the Voyager space probe's pictures of the moon of the planetUranus, namedOberon, and because Oberon is famous as the king of the elves.[6]
Oberon was maintained by Wirth and the latest Project Oberon compiler update is dated 6 March 2020.[7]
Oberon is designed with a motto attributed toAlbert 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 asC++ andAda. In contrast to these, Oberon emphasizes the use of thelibrary concept to extend the language. Enumeration and subrange types, which were present in Modula-2, were omitted, and set types are limited to sets of integers. All imported items must be qualified by the name of the module where they are declared. Low-level facilities are highlighted by only allowing them to be used in a module which includes the identifierSYSTEM in its import list. Stricttype checking, even across modules, andindex checking atruntime,null pointer checking, and the safe type extension concept largely allow programming 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 code quality comparable to commercial compilers.[8]
Features characterizing the Oberon language include:[9]
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 lacks a dispatch mechanism as a language feature but has it as a programming technique or design pattern. This gives great flexibility in OOP. In the Oberon operating system, two programming techniques are used together for the dispatch call: Method suite and Message handler.
In this technique, a table ofprocedurevariables is defined and aglobal 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 := ifEND Init;PROCEDURE Draw* (f : Figure);BEGIN f.if.draw(f)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);BEGINNEW(r); Figures.Init(r, if)END New;PROCEDURE Draw* (f : Figure);VAR r : Rectangle;BEGIN r := f(Rectangle);(* f AS Rectangle *)(* ... *)END Draw;(* Other procedures here *)BEGIN(* Module initialisation *)NEW(if); if.draw := Draw; if.clear := Clear; if.mark := Mark; if.move := MoveEND Rectangles.
Dynamic dispatch is only done via procedures in Figures module that is the generic module.
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* :INTEGEREND; Handler* =PROCEDURE (f : Figure;VAR msg : Message); FigureDesc* =RECORD(* Abstract *) handle : Handler;END;PROCEDURE Handle* (f : Figure;VAR msg : Message);BEGIN f.handle(f, msg)END Handle;PROCEDURE Init* (f : Figure; handle : Handler);BEGIN f.handle := handleEND 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 := f(Rectangle);IF msgIS Figures.DrawMsgTHEN Draw(r)ELSIF msgIS Figures.MarkMsgTHEN Mark(r)ELSIF msgIS Figures.MoveMsgTHEN Move(r, msg(Figures.MoveMsg).dx, msg(Figures.MoveMsg).dy)ELSE(* ignore *)ENDEND Handle;PROCEDURE New* (VAR r : Rectangle);BEGINNEW(r); Figures.Init(r, 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.
No-cost implementations of Oberon (the language) and Oberon (the operating system) can be found on the Internet (several are from ETHZ itself).
A few changes were made to the first released specification. For example,object-oriented programming (OOP) features were added, theFOR loop was reinstated. The result wasOberon-2. One release, namedNative Oberon which includes an operating system, and can directly boot onIBM PC compatible class hardware. A.NET implementation of Oberon with some added minor .NET-related extensions was also developed at ETHZ. In 1993, an ETHZuniversity spin-off company brought a dialect of Oberon-2 to the market namedOberon-L. In 1997, it was renamedComponent Pascal.
Oberon-2 compilers developed by ETH include versions forMicrosoft Windows,Linux,Solaris, andclassic Mac OS. Implementations from other sources exist for some other operating systems, includingAtari TOS andAmigaOS.
There is an Oberon-2Lex scanner andYaccparser by Stephen J Bevan of Manchester University, UK, based on the one in theMössenböck and Wirth reference. It is at version 1.4.
Other compilers include Oxford Oberon-2,[10] which also understands Oberon-07, and Vishap Oberon.[11] The latter is based on Josef Templ's Oberon toC languagesource-to-source compiler (transpiler) named Ofront,[12] which in turn is based on the OP2 Compiler developed by Regis Crelier at ETHZ.
Oberon-07, defined by Niklaus Wirth in 2007 and revised in 2008, 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 andFLT) must be used; theWITH,LOOP andEXIT statements were omitted;WHILE statements were 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 usingCOPY.[13]
Oberon-07 compilers have been developed for use with many different computer systems. Wirth's compiler targets areduced instruction set computer (RISC) processor of his own design that was used to implement the 2013 version of theProject Oberon operating system on a Xilinxfield-programmable gate array (FPGA) Spartan-3 board. Ports of the RISC processor to FPGA Spartan-6, Spartan-7, Artix-7 and a RISC emulator for Windows (compilable on Linux andmacOS, and binaries available for Windows) also exist.OBNC compiles via C and can be used on any Portable Operating System Interface (POSIX) compatible operating system. The commercialAstrobe implementation targets STM ARM Cortex-M0, M3, M4, M7 and Raspberry Pi RP2040 and RP2350 microcontrollers. ThePatchouli compiler produces 64-bit Windows binaries.Oberon-07M produces 32-bit Windows binaries and implements revision 2008 of the language.Akron's produces binaries for both Windows and Linux.OberonJS translates Oberon toJavaScript. There isonline IDE for Oberon.oberonc is an implementation for theJava virtual machine.
Active Oberon is yet another variant of Oberon, which adds objects (with object-centered access protection and local activity control), system-guarded assertions, preemptive priority scheduling and a changed syntax for methods (namedtype-bound procedures in Oberon vocabulary). Objects may be active, which means that they may be threads or processes. Further, Active Oberon has a way to implement operators (including overloading), an advanced syntax for using arrays (seeOberonX language extensionsArchived 4 March 2016 at theWayback Machine and Proceedings[14] of the 7th Joint Modular Languages Conference 2006 Oxford, UK), and knows aboutnamespaces.[15] The operating systemA2 (formerlyActive Object System (AOS),[16] thenBluebottle), especially thekernel, synchronizes and coordinates different active objects.
ETHZ has releasedActive Oberon which supports active objects, and the operating systems based thereon (Active Object System (AOS), Bluebottle, A2), and environment (JDK, HTTP, FTP, etc.) for the language. As with many prior designs from ETHZ, versions of both are available for download on the Internet. As of 2003, supportedcentral processing units (CPUs) include single and dual corex86, andStrongARM.
Development continued on languages in this family. A further extension of Oberon-2 was originally named Oberon/L but later renamed toComponent Pascal (CP). CP was developed for Windows andclassic Mac OS by Oberon microsystems, a commercial spin-off company from ETHZ, and for .NET byQueensland University of Technology. Further, the languagesLagoona[17][18][19] andObliq carry Oberon methods into specialized areas.
Later .NET development efforts at ETHZ focused on a new language namedZonnon. This includes the features of Oberon and restores some from Pascal (enumerated types, built-in IO) but has some syntactic differences. Other features include support for active objects, operator overloading, and exception handling.
Oberon-V (originally named Seneca, afterSeneca the Younger) is a descendant of Oberon designed for numerical applications onsupercomputers, especially vector orpipelined architectures. It includes array constructors and anALL statement.[20]
{{cite magazine}}: CS1 maint: numeric names: authors list (link)