TweetFollow Us on Twitter

March 93 - An Introduction to BETA: A New Object-oriented Language

An Introduction to BETA: A New Object-oriented Language

Steve Mann

New object-oriented products are announced every day. Most of them are based on a familiar language such as C++, SmallTalk, or LISP / CLOS. New object-oriented languages are another matter. When was the last time you saw an announcement for a commercial-grade object-oriented language product? BETA is such a product.

Development on BETA started in 1976 as a joint venture between several universities in Norway, Denmark, and Finland. This is the same computer science community (often called the Scandinavian School of object-orientation) that in the early 1960s developed Simula, the first object-oriented language. Throughout its formative years, the BETA research has been supported by grants from many companies, including Apollo, Apple, and Hewlett Packard. After more than 15 years of research and development, Mjolner Informatics has released the first commercial BETA product.

AN OVERVIEW OF BETA

BETA is a completely new language with a design heavily influenced by its object-oriented predecessors, especially Simula. It is strongly typed like C++, with most type checking being done at compile time. The language design is based on a powerful abstraction mechanism called a pattern. The syntax for a pattern is:
<Pattern Name> :
    (#  <Attribute 1> ;
        <Attribute 2> ;
            .
        <Attribute N> ;

    Enter <Input list>
    Do <Imperatives>
    Exit <Output list>
    #);

Attributes can be many things-the most common are object declarations and methods specific to the pattern being defined. The Enter statement lists the values passed to the Do section, Exit lists the values output from the Do section. The Do section contains imperative (executable) statements that perform actions. All the syntactic elements of a pattern are optional.

There are several types of patterns, including classes, procedures, functions, coroutines, processes, and exceptions. There are also three types of pattern derivatives:

  • subpatterns (like subclasses but more powerful),
  • virtual patterns (like C++ virtual procedures), and
  • pattern variables (variables that can be assigned any legal pattern value).

You can create any of these three derivatives from any of BETA's pattern types, making BETA a very orthogonal language. For instance, using subpatterns, you can create a hierarchy of procedures, functions, coroutines, processes, or exceptions, where all the subpatterns inherit attributes from their superpatterns. You can also define virtual classes, virtual procedures, virtual functions, and so on . Table 1 lists all the possible combinations of pattern derivatives and types.

Other important BETA features include:

  • class-less objects for one-of-a-kind object definitions;
  • direct and reference (pointer-based) attributes allowing the modeling of complex relationships;
  • block structures similar to Algol, allowing nested structures with local and global scopes for all patterns.

SAMPLE PROGRAMS

Here is a simple class pattern that defines a bank account object. It has three attributes-balance (a declaration using a predefined class pattern called integer), Deposit (a procedure pattern), and Withdraw (another procedure pattern).
Account :  (* a simple bank account class pattern *)   
    (#  balance : @ integer;        (* bank account balance *)

        Deposit :       (* add 'amount' to balance *) 
            (#  amount : @ integer          (* local declaration *)
            enter amount                    (* input list *)
            do balance + amount -> balance   (* action *)
            exit balance                        (* output list *)
            #); 
        Withdraw :      (* subtract 'amount' from balance *)
            (#  amount : @ integer  
            enter amount    
            do balance - amount -> balance
            exit amount     
            #); 
    #); 

Note that:

  • Asterick/parens ('(*' and '*)') are used to enclose comments.
  • A colon (':') indicates a declaration.
  • An @ sign indicates the name of an object type.
  • Integer is a predefined BETA basic pattern (the other basic patterns are real, boolean, and char, plus there is a predefined text pattern that works much like strings).
  • Imperative statements always read left to right.

According to BETA terminology, both Deposit and Withdraw are procedure (not function) patterns. BETA procedures and functions both can have input and output lists. A BETA function computes a return value using only the input values, causing no side effects (a procedure may cause side effects).

The preceding sample is simply a class definition pattern with attributes (balance) and methods (Deposit and Withdraw). In order to create a complete BETA program, we need more, such as some declarations to create real account objects, and some imperatives to perform actions on those accounts:

(# (* a pattern with no name *)
    Account : (*  a pattern declaration within the unnamed pattern *)
        (#  acct_balance : @ integer;
            Deposit :                
                (#  amount : @ integer  
                enter amount
                do acct_balance + amount -> acct_balance
                exit balance    
                #); 
            Withdraw :      
                (#  amount : @ integer  
                enter amount    
                do acct_balance - amount -> acct_balance
                exit amount     
                #); 
            Balance :
                (#
                exit acct_balance
                #)
        #); 
    A : @ Account;              
    cash_on_hand, balance : @ integer;  

do  100 -> &A.Deposit;               
    250 -> &A.Deposit;               
    75  -> &A.Withdraw -> cash_on_hand;   (* $75 on hand *)
    &A.Balance -> balance;                (* $275 balance *)
#)

In BETA the symbol '&' means new; the expression &account.Deposit means "create a new instance of the pattern account.Deposit and execute it". This is basically the same as invoking a procedure. Note that the finished program, the primary object definition (Account), and the methods that operate on that account (Deposit, Withdraw, and Balance) are all patterns. This use of a single syntactic element to define everything and execute operations gives BETA much of its power and flexibility.

REFERENCE ATTRIBUTES

BETA allows you to define both static and dynamic reference attributes. The previous sample programs all have examples of static object references such as
A : @ Account;             
cash_on_hand, balance : @ integer;

Static objects are also called part objects (or part references) in BETA because the declared objects are a permanent part of the objects containing their declarations.

BETA also lets you define object references that denote different objects at different points in time (much like pointers). An example of a dynamic reference is

A : ^Account ;

The initial value of a dynamic reference is NONE (trying to reference an object attribute using a NONE pointer causes a runtime error). If we define an account using

A1 : Account ;

we can assign A1 to A using the statement

A1[] -> A[] ;

It is also possible to create objects dynamically by invoking their pattern as an executable statement. For instance, the statement

&Account[]

creates a new instance of an Account and returns a reference to that account. If we declare a reference object using

A1 : ^Account;

the following statement is valid:

&Account[] -> A1[];

The difference between &Account and &Account[] is important. The first means "generate an instance of Account and execute it"; the second means "generate a new instance of Account without executing it and return a reference to it".

OTHER BETA SYNTACTIC ELEMENTS

When presenting a new language, there is always a certain amount of rote presentation to cover the basic syntax needed to create programs in that language. This section covers some of the more recognizable parts of BETA, including predefined basic patterns and attributes, arrays, assignment statements (evaluations), and control statements.

Basic Patterns

BETA has four predefined basic patterns : integer, real, boolean, and char. The default values and standard operators for BETA's basic patterns are shown in Table 2. In addition, BETA has a standard set of relational operators. Chars are ordered from 0 to 255, and false is less than true.

One unusual restriction that BETA has is that it is not possible to declare dynamic references to instances of these four basic patterns. Apparently this restriction is primarily for efficiency reasons.

Repetitions

BETA arrays (called repetitions) are defined using one of these two forms:
<Name>: [size] @<Type> ;       (* static repetition *)
<Name>: [size] ^<Type> ;        (* dynamic repetition *)

Array indices range from one to <Name>.range (range is an intrinsic attribute of all array objects). You can dynamically resize arrays using the extend attribute, which adds elements to an array. You can reallocate an array, initializing all the elements to the default value for the array object type. You can also assign array slices (or parts of an array).

Here are some array examples:

A1, A2 : [10] @integer;    (* integer arrays A1[1]-A1[10],
                              A2[1]-A2[10] *)
1050 -> A1.[1];         (* assignment *)
10 -> A1.extend;        (* resize A2 to 20 elements *)
25 -> A2.new;           (* resize and reinitialize A2 *)
A1 [1:5] -> A2 [10];    (* slice assignment *)

There is also a special repetition pattern called text which is derived from a string pattern. It is a character array, subject to all normal array operations, with additional predefined patterns for string manipulation.

For Statement

The BETA for statement is straightforward. It has the following form:
(for <Index>: <Range> repeat <Imperative-list> for)

<Index> is an integer object declared locally within the scope of the for statement. It cannot be changed within the loop. The index always starts at one and increments by one. A pattern with a for loop might look like

(#     sum: @ integer;
    V : [100] @ integer     (* integer array *)
do  (for i : V.range repeat i -> V [i] for)
    0 -> sum;
    (for i : V.range repeat sum + v [i] -> sum for)
#)

It is possible to overcome the limitations of the for index structure (integer indices which always start at one and increment by one) using other patterns. That capability is not explored in this introductory article.

If Statement

The BETA if statement is an unusual combination of a traditional if statement and a case statement. Its form is
(if E0
    // E1 then I1
    // E2 then I2
        . . .
    //En then In
    else I
if)

E1 . . . En are evaluations and I1 . . . In are imperatives. The else clause is optional. Here's an example of a simple if statement:

(if x
    // 17 then . . .
    // 33 then . . .
    // y+3 then . . .
    else
if)

A boolean evaluation (albeit an awkward one) might be written

(if (x > 0) and (y < 0)
    // True then . . .
    // False then . . .
if)

Evaluations

BETA evaluation (assignment) statements are very flexible. You can define multiple assignment statements such as
   3 -> I -> J

You can also combine multiple assignments with pattern executions and enter and exit redirection like in this program:

   (#  Power :     (* compute X^n where n > 0 *)
        (#  X, Y : @ real; n : @ integer;
        enter (X, n) 
        do  1 -> Y;
            (for i : n repeat Y * X -> Y for)
        exit Y
        #)

        Reciproc :  (* compute (Q, 1/Q) *)
        (# Q, R : @ real;
        enter Q
        do  (if (Q // 0) then 0 -> R
            else (1 div Q) -> R
            if )
        exit (Q, R)
        #);
    A, B : @ real;
    do  (3.14, 2) -> &Power -> &Reciproc -> (A, B);
        (* A = 3.14 ^ 2, B = 1/A *)
    #)

THE MJOLNER BETA SYSTEM

So far I have described the more basic elements of the BETA language. There are many advanced capabilities, such as subpatterns and virtual patterns, exception handling, and concurrency, that really show off BETA's power as an object-oriented language and the depth of its design. I''ll cover these topics in a future article.

The Mjolner BETA System, created by several of the language's original designers, is currently the only commercial implementation of a BETA development environment. The Mjolner BETA System includes:

  • native code generation,
  • automatic garbage collection and storage management,
  • separate compilation of program fragments with automatic dependency analysis,
  • interfaces to C and assembly language modules (and Pascal on the Mac),
  • persistent objects, although not a full-blown object-oriented database (a complete OODB is expected by late 1993),
  • basic patterns for simple data types,
  • a set of container patterns for more complex data structures (including sets, has tables, stacks, queues, and lists),
  • stream patterns for text and file handling,
  • process management and concurrency control patterns, and
  • application frameworks for X Windows, Motif, and the Macintosh Toolbox.

As if that weren't enough, Mjolner also sells a variety of additional tools including a modifiable Hyper Structure Editor, a metaprogramming system, a BETA CASE Tool (Unix only), and a source-level debugger (Unix only). In the coming months we hope to present an overview of BETA's advanced features, a comprehensive review of Mjolner's BETA System and tools, and advanced programming examples. Let us know if there are specific topics you would like addressed. -

MADA is pleased to announce that as we were going to press with this issue, Mjolner selected MADA as their exclusive US and Canada distributor for the Macintosh version of BETA. We are also carrying the reset of the Mjolner BETA product line. See page 67 for more details.

In addition, a demo version of the Mjolner BETA System is available on MADA's "Five Years of Objects" CD-ROM.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fallout Shelter pulls in ten times its u...
When the Fallout TV series was announced I, like I assume many others, assumed it was going to be an utter pile of garbage. Well, as we now know that couldn't be further from the truth. It was a smash hit, and this success has of course given the... | Read more »
Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »

Price Scanner via MacPrices.net

Apple’s 24-inch M3 iMacs are on sale for $150...
Amazon is offering a $150 discount on Apple’s new M3-powered 24″ iMacs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 24″ M3 iMac/8-core GPU/8GB/256GB: $1149.99, $150 off... Read more
Verizon has Apple AirPods on sale this weeken...
Verizon has Apple AirPods on sale for up to 31% off MSRP on their online store this weekend. Their prices are the lowest price available for AirPods from any Apple retailer. Verizon service is not... Read more
Apple has 15-inch M2 MacBook Airs available s...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs available starting at $1019 and ranging up to $300 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at Apple.... Read more
May 2024 Apple Education discounts on MacBook...
If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take up to $300 off the purchase of a new MacBook... Read more
Clearance 16-inch M2 Pro MacBook Pros in stoc...
Apple has clearance 16″ M2 Pro MacBook Pros available in their Certified Refurbished store starting at $2049 and ranging up to $450 off original MSRP. Each model features a new outer case, shipping... Read more
Save $300 at Apple on 14-inch M3 MacBook Pros...
Apple has 14″ M3 MacBook Pros with 16GB of RAM, Certified Refurbished, available for $270-$300 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year warranty is... Read more
Apple continues to offer 14-inch M3 MacBook P...
Apple has 14″ M3 MacBook Pros, Certified Refurbished, available starting at only $1359 and ranging up to $270 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year... Read more
Apple AirPods Pro with USB-C return to all-ti...
Amazon has Apple’s AirPods Pro with USB-C in stock and on sale for $179.99 including free shipping. Their price is $70 (28%) off MSRP, and it’s currently the lowest price available for new AirPods... Read more
Apple Magic Keyboards for iPads are on sale f...
Amazon has Apple Magic Keyboards for iPads on sale today for up to $70 off MSRP, shipping included: – Magic Keyboard for 10th-generation Apple iPad: $199, save $50 – Magic Keyboard for 11″ iPad Pro/... Read more
Apple’s 13-inch M2 MacBook Airs return to rec...
Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices currently... Read more

Jobs Board

Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
*Apple* App Developer - Datrose (United Stat...
…year experiencein programming and have computer knowledge with SWIFT. Job Responsibilites: Apple App Developer is expected to support essential tasks for the RxASL Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.