Limbo (programming language)

from Wikipedia, the free encyclopedia

Limbo is a high-level programming language that is used in the Inferno operating system to program application programs. Well-known developers from the Unix world participated in the design of the language, such as B. Rob Pike and Dennis Ritchie , who developed the successful C programming language .

Modules

Limbo is translated into bytecode that can be run on any machine, regardless of processor type. Limbo programs are modules that other Limbo modules can load into Limbo and use their functionality. Modules are loaded by the Inferno operating system as required and removed again later.

Data types

Limbo is a strictly typed language, which at first glance resembles the C programming language . The creators of Limbo claim that it offers the capabilities of Java and C ++, but is much easier to learn and master. It supports a few, well-defined data types, such as unsigned 8-bit characters and 32 bit integer with sign . It supports parallel processing. Communication channels also exist as data types.

Limbo and the Inferno operating system

The Inferno operating system uses file names for almost everything: process information, network connections, pipes , etc. File names are references to files, resources and devices that can be accessed with the Styx protocol. It does not matter whether these are accessible locally or only via the network. Limbo uses these filenames to communicate with the outside world. A Limbo module can generate a data structure that communicates via Styx. The methods and functions of a module are implemented by it in Styx. A programmer does not need to know this, however. He only needs to know the abstract methods of a module without knowing exactly how these are implemented on the lower Styx protocol.

Reference counter and automatic garbage collection

Pointers are replaced by references that dynamically allocate and deallocate the referenced structures. Both reference counters and automatic garbage collection are used for this purpose. The reference counter guarantees that the data structure is released after the last reference has been given. This is important if the structure contains other resources such as open files that are closed at the latest when they are released.

If you only use the automatic garbage collection, the release can be delayed, possibly not even before the end of the program. The time of release cannot be predicted. Reference counters, on the other hand, do not reliably release cyclic data structures such as ring lists, trees with backward references, etc. Structures can remain that are never released because they refer to one another, but which can no longer be accessed.

Limbo uses a simple method to normally exclude cyclical data structures: If a reference to a data structure appears in the definition before the actual structure is known, the structure may only be dereferenced as a whole, but not parts of it. This means that no cyclic data structures can be generated. Reference counters then ensure that the structure is released the last time the reference occurs and thus at a precisely predictable point in time.

The keyword cyclicremoves the restriction and allows the definition of all data structures. Automatic garbage collection is used to release these structures.

Examples

Hello world program

implement Command;

include "sys.m";
    sys: Sys;

include "draw.m";

include "sh.m";

init(nil: ref Draw->Context, nil: list of string)
{
    sys = load Sys Sys->PATH;
    sys->print("Hallo Welt!\n");
}

Web links