1 / 25

The BETA programming language

The BETA programming language. «A language that doesn’t affect the way you think about programming, is not worth knowing.» ―Alan Perils, Epigrams in Programming. What is BETA?. BETA is a modern object-oriented language in the Simula school of object orientation.

lequoia
Download Presentation

The BETA programming language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The BETA programming language «A language that doesn’t affect the way you think about programming, is not worth knowing.» ―Alan Perils, Epigrams in Programming

  2. What is BETA? • BETA is a modern object-oriented language in the Simula school of object orientation. • BETA has powerful abstraction mechanisms for supporting identification of objects, classification and composition. • BETA is a strongly typed language like Simula, Eiffel and C++.

  3. History • The BETA project was initiated in 1976 as part of what was then called The Joint Language Project by people from: • The Regional Computing Center • Aarhus University • Norwegian Computing Center, Oslo • The BETA language was developed by Bent Bruun Kristensen, Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard.

  4. The Mjølner system • The Mjølner System is a programming environment supporting object-oriented programming in BETA. • The Mjølner System includes an implementation of BETA and a large number of libraries and application frameworks. • The Mjølner system is free of any licence fee and available for Windows, Linux, UNIX, Solaris and Macintosh platforms.

  5. Abstraction in BETA The BETA pattern: towards the ultimate abstraction mechanism. • Concepts represented as patterns • Phenomena represented as objects • The world is not object-oriented, object orientation is a perspective on the world. • A perspective is the means used by people to organize knowledge within some domain

  6. Phenomena and concepts • A phenomenon is a thing that has definite, individual existence in reality or in the mind; anything real in itself. • A concept is a generalized idea of a collection of phenomena, based on knowledge of common properties of instances in the collection.

  7. The pattern • BETA replaces classes, procedures, functions and types by a single abstraction mechanism called the pattern. • Objects are instances of patterns. • As there is only one language mechanism for classes and procedures the notation of a subpattern applies equally well to classes and procedures (virtual classes and procedures).

  8. Block-structured languages • BETA and Simula are block-structured languages in that classes and procedures can be arbitrary nested. I.e. in BETA and Simula an object may have class attributes in addition to references and procedures. • This enables part/whole composition where classes can be encapsulated by higher level class constructs.

  9. Objects and Patterns An object representing a bank account may be described by following attributes: (# balance: ... ; Deposit: ... ; Withdraw: ... ; #) The syntactic construct (#... #) is called an object descriptor, which describes the structure of an object.

  10. Singularly defined objects myAccount: @ (# balance: ... ; Deposit: ... ; Withdraw: ... ; #); The symbol @ shows that myAccount is the name of an object. The myAccount object is called a singular object, since the object descriptor (# ... #) is only used for describing a single object.

  11. Pattern: a named object descriptor The objects representing the actual bank accounts may then be described as instances of this pattern. The pattern representing the concept of a bank account may be described as follows: Account: (# balance: ... ; Deposit: ... ; Withdraw: ... ; #); Account is the name of the pattern.

  12. Object-descriptor The syntactic element for describing an object is called an object-descriptor, and has the form: (# Decl1; Decl2; ...; Decln enter In do Imp exit Out #) • Decl1; Decl2; ... ;Decln is a list of attribute declarations that describes the attribute-part of the object. • The enter-, do- and exit-parts are together called the action-part of the object.

  13. Pattern-defined objects The Account pattern may, for instance, be used to describe three bank accounts (objects): account1: @Account; account2: @Account; account3: @Account; When making descriptions in BETA there is a large number of patterns available for describing objects. The integer pattern is one example: balance: @integer

  14. Description of actions Account: (# balance: @integer; Deposit: (# amount: @integer enter amount do balance+amount->balance exit balance #); Withdraw: (# amount: @integer enter amount do balance-amount->balance exit balance #);

  15. account1, account2, account3: @Account; K1,K2,K3: @integer; do {L1} 100->&account1.Deposit; 200->&account2.Deposit; 300->&account3.Deposit; {L2} 150->&account1.Deposit->K1; 90->&account3.Withdraw->K3; 90->&account2.Deposit->K2; 80->&account3.Withdraw->K3; {L3} #) The symbol & means new, and the expression account1.Deposit means that a new instance of the pattern account1.Deposit is created and executed. Text enclosed by the brackets {…} is a comment.

  16. 3 kinds of objects: system, component and item • A system object may me executed concurrently with other system objects • A component object (coroutine) may alternate execution with other components (quasi-parallel?) • An item object is a dependent action sequence contained in a system, component or item

  17. Static references A static reference constantly denotes the same object within the lifetime of the encapsulating object. Point: (# x,y: @integer #) P1,P2: @Point A singular static/part-object is declared in the following way: Y: @(# ... #)

  18. Dynamic items A1 may refer to an Account-item, a sub-item of Account or NONE. A1: ˆAccount A dynamic Account item may be generated by execution of a “new” imperative: &Account &Account[]->A1[] The difference between &P and &P[] is very important: the expression &P means ‘generate a new instance of P and execute it’; the expression &P[] means ‘generate a new instance of P without executing it and return a reference to the new object.’

  19. Classification hierarchies Subpatterns: Person: (# Name: @string, Age: @integer #); Student: Person (# Studentid: @string#) Phdstudent: Student (# Thesistitle: @string#)

  20. Declaration of virtual patterns V:< A V is declared as a virtual pattern with qualifying pattern A V may be bound to any subpattern of A The virtual pattern attributes of a pattern P may be bound in subpatterns of P. A binding of a virtual pattern may have the form of a final binding: V::A1

  21. Example: prefixed procedure OpenRecord: (# ID: ˆText; R: ˆRecord enter ID[] do ID[] -> theDataBase.Open -> R[]; INNER; R.Close #); OpenWritableRecord: OpenRecord (# do R.Lock; INNER; R.Free #); Foo: OpenWritableRecord (# do someData[] -> R.put #) Execution of Foo implies thus that the following sequence of actions is executed: ID[] -> theDataBase.Open -> R[]; R.lock; someData[] -> R.put; R.Free; R.Close

  22. Example: classes with virtual procedures Record: (# Key: ˆKeyType; Display:< {virtual procedure} (# do Key.Display; INNER; #) #); Person: Record (# Name: ˆText; Sex: ˆSexType; Display::< {extended procedure} (# do Name.Display; Sex.Display; INNER #) #); P: ˆPerson Execution of P.Display will imply execution of Key.Display, Name.Display, Sex.Display, and possibly more since P is known to denote at least Person-objects.

  23. Example: Classes as attributes Grammar: (# Symbol: Object (# isTerminal: proc (# ...#); isNonTerminal: proc (# ... #); #); ... #); AdaGram: @ Grammar; S1,S2: @ AdaGram.Symbol; PascalGram: @ Grammar; X1,X2: @ PascalGram.Symbol Each Grammar objects has an associated Symbol class as an attribute. Similarly it is possible to declare instances of class PascalGram.Symbol, in the example X1 and X2. S1, S2 and X1, X2 are not instances of the same class. Also a Symbol class has no existence without a grammar object.

  24. Summary • In BETA class and procedure are unified into one abstraction mechanism: the pattern. • In BETA a virtual procedure cannot be redefined in a subclass, but it may be further defined by an extended definition. The extended procedure is a “subprocedure” (in the same way as for subclass) of the procedure defined in the superclass. This implies that the actions of a virtual procedure definition are automatically combined with the actions of the extended procedure in a subclass.

  25. Links? • The BETA Home Page: http://www.daimi.au.dk/~beta/ • Mjølner Informatics A/S: http://www.mjolner.dk/

More Related