Jump to content

BETA (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mate Juhasz (talk | contribs) at 10:56, 8 February 2014 (Features: Basic explanation of patterns). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
BETA
ParadigmObject-oriented
Designed byBirger Møller-Pedersen, Kristen Nygaard
Websitehttp://daimi.au.dk/~beta
Influenced by
Simula

BETA is a pure object-oriented language originating within the "Scandinavian School" in object-orientation where the first object-oriented language Simula was developed. Among its notable features, it introduced nested classes, and unified classes with procedures into so called patterns.

Features

Technical overview

From a technical perspective, BETA provides several unique features. Classes and Procedures are unified to one concept, a Pattern. Also, classes are defined as properties/attributes of objects. This means that a class cannot be instantiated without an explicit object context. A consequence of this is that BETA supports nested classes. Classes can be virtually defined, much like virtual methods can be in most object-oriented programming languages. Virtual entities (such as methods and classes) are never overwritten; instead they are redefined or specialized.

BETA supports the object-oriented perspective on programming and has comprehensive facilities for procedural and functional programming. It has powerful abstraction mechanisms to support identification of objects, classification and composition. BETA is a statically typed language like Simula, Eiffel and C++, with most type checking done at compile-time. BETA aims to achieve an optimal balance between compile-time type checking and run-time type checking.

Patterns

A major and peculiar feature of the language is the concept of patterns. In another programming language, such as C++, one would have several classes and procedures. BETA expresses both of these concepts using patterns.

For example, a simple class in C++ would have the form

class point {
    int x, y;
};

In BETA, the same class could be represented by the pattern

point: (#
    x, y: @integer
#)

That is, a class called point will have two fields, x and y, of type integer. The symbols (# and #) introduce patterns. The colon is used to declare patterns and variables. The @ sign before the integer type in the field definitions specifies that these are integer fields, and not, by contrast, references, arrays or other patterns.

On the other hand, a procedure in C++ could have the form

int max(int x, int y)
{
    if(x >= y)
    {
        return x;
    }
    else
    {
        return y;
    }
}

In BETA, such a function could be written using a pattern

max: (#
    x, y, z: @integer
enter (x, y)
do
    (if x >= y // True then
        x -> z
    else
        y -> z
    if)
exit z
#)

Hello world!

This snippet prints the standard line "Hello world!":

(#
do ’Hello world!’->PutLine
#)