An Object Model for Multiparadigm

Similar documents
Type safe Linkage for Variables and Functions

Checking C Declarations at Link Time 1 2

What is Type-Safe Code Reuse?

Publications related to Chez Scheme

Comp 311 Principles of Programming Languages Lecture 21 Semantics of OO Languages. Corky Cartwright Mathias Ricken October 20, 2010

Lecture Notes on Garbage Collection

/99/$ IEEE

CSE 504: Compiler Design. Runtime Environments

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Teaching Encapsulation and Modularity in Object-Oriented Languages with Access Graphs

Concepts of Programming Languages

Conceptual Modeling of Dynamic Interactive Systems Using the Equivalent Transformation Framework

Programmiersprachen (Programming Languages)

Programming Languages Third Edition. Chapter 7 Basic Semantics

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

An Object-Oriented Approach to Software Development for Parallel Processing Systems

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Toward an Execution Model for Component Software

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Programming Languages, Summary CSC419; Odelia Schwartz

Lecture 23: Object Lifetime and Garbage Collection

2. Reachability in garbage collection is just an approximation of garbage.

Multimedia structuring using trees

Java-centered Translator-based Multi-paradigm Software Development Environment

Grade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline

11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

Chapter 5 Object-Oriented Programming

Functional Programming Language Haskell

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Operational Semantics. One-Slide Summary. Lecture Outline

CPS 506 Comparative Programming Languages. Programming Language

On the BEAM Implementation

Structure of Programming Languages Lecture 10

The Essence of Compiling with Continuations

Automation of Semantic Web based Digital Library using Unified Modeling Language Minal Bhise 1 1

MODELING LANGUAGES AND ABSTRACT MODELS. Giovanni De Micheli Stanford University. Chapter 3 in book, please read it.

Experiences Report on the Implementation of EPTs for GNAT

Chapter 9 :: Data Abstraction and Object Orientation

Towards a formal model of object-oriented hyperslices

Intermediate Code, Object Representation, Type-Based Optimization

Incremental Flow Analysis. Andreas Krall and Thomas Berger. Institut fur Computersprachen. Technische Universitat Wien. Argentinierstrae 8

A Meta-Model for Composition Techniques in Object-Oriented Software Development

Outcome-Oriented Programming (5/12/2004)

6. Discuss how producer-consumer problem and Dining philosophers problem are solved using concurrency in ADA. [16]

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Programming Languages 2nd edition Tucker and Noonan"

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

The TTC 2011 Reengineering Challenge Using MOLA and Higher-Order Transformations

Extracting the Range of cps from Affine Typing

CSc 520. Course Outline (Subject to change) Course Outline (Subject to change)... Principles of Programming Languages. Christian Collberg

Run-time Environments

Run-time Environments

CSCI312 Principles of Programming Languages!

A Web-capable Persistent Programming Environment C. J. Harrison and O. M. Sallabi Department of Computation UMIST Manchester, M60 1QD, U.K.

A programming language requires two major definitions A simple one pass compiler

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Yacc Meets C+ + Stephen C. Johnson Ardent Computer Corporation

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Towards Formalization of ARD+ Conceptual Design and Refinement Method

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

What about Object-Oriented Languages?

Lecturer: William W.Y. Hsu. Programming Languages

New Programming Paradigms

An Introduction to Object-Oriented Programming

Natural Semantics [14] within the Centaur system [6], and the Typol formalism [8] which provides us with executable specications. The outcome of such

Access Control for Shared Resources

NOTE: Answer ANY FOUR of the following 6 sections:

KNOWLEDGE-BASED MULTIMEDIA ADAPTATION DECISION-TAKING

Technical aspects of VTL to SQL translation Prepared by Regional Statistical Office in Olsztyn, Poland

Concurrent Programming Constructs and First-Class Logic Engines

Subtyping (Dynamic Polymorphism)

Compiler Construction

Development of an Ontology-Based Portal for Digital Archive Services

Compiling Techniques

Compiler Construction Lecture 1: Introduction Summer Semester 2017 Thomas Noll Software Modeling and Verification Group RWTH Aachen University

Seminar in Programming Languages

Lecture Notes on Programming Languages

RAMSES: a Reflective Middleware for Software Evolution

CS 242. Fundamentals. Reading: See last slide

Kent Academic Repository

Data Abstraction. Hwansoo Han

22c:111 Programming Language Concepts. Fall Syntax III

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005

David K. Mellinger; G. E. Garnett; Bernard Mont-Reynaud. Computer Music Journal, Vol. 13, No. 2. (Summer, 1989), pp

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

An Efficient Design and Implementation of a Heterogeneous Deductive Object-Oriented Database System

HOLY ANGEL UNIVERSITY COLLEGE OF INFORMATION AND COMMUNICATIONS TECHNOLOGY COMPILER THEORY COURSE SYLLABUS

A Component Framework for HPC Applications

Operational Semantics of Cool

Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl

A conceptual framework for building good DSLs. Markus Voelter independent/itemis

Combined Object-Lambda Architectures

A Short Summary of Javali

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Topic 1: Introduction

Naming in OOLs and Storage Layout Comp 412

CMPT Data and Program Organization

Creating Ontology Chart Using Economy Domain Ontologies

HANDBOOK OF LOGIC IN ARTIFICIAL INTELLIGENCE AND LOGIC PROGRAMMING

Transcription:

1 of 7 03/02/2007 15:37 http://www.dmst.aueb.gr/dds/pubs/conf/1994-oopsla-multipar/html/mlom.html This is an HTML rendering of a working paper draft that led to a publication. The publication should always be cited in preference to this draft using the following reference: Diomidis Spinellis, Sophia Drossopoulou, and Susan Eisenbach. An object model for multiparadigm programming. In Dennis Kafura, Greg Lavender, and Siva Challa, editors, OOPSLA '94 Workshop on Multi-Language Object Models, October 1994. http://actor.cs.vt.edu/~siva/wshop.html. The document's metadata is available in BibTeX format. This material is presented to ensure timely dissemination of scholarly and technical work. Copyright and all rights therein are retained by authors or by other copyright holders. All persons copying this information are expected to adhere to the terms and constraints invoked by each author's copyright. In most cases, these works may not be reposted without the explicit permission of the copyright holder. Diomidis Spinellis Publications An Object Model for Multiparadigm Programming 1 Introduction Diomidis Spinellis, Sophia Drossopoulou, and Susan Eisenbach Department of Computing Imperial College of Science, Technology and Medicine 180 Queen's Gate, London SW7 2BZ e-mail: {dds,scd,se}@doc.ic.ac.uk July, 1994 We became interested in multi-language object models while researching problems related to multiparadigm programming [SDE94a,SDE94b]. It is widely accepted that different types of tasks can be best implemented in different paradigms. As an example the logic programming paradigm is particularly well suited for implementing expert systems, while many operations on lists can be elegantly described in the functional programming paradigm. Multiparadigm programming can allow each part of a system to be implemented in the most suitable paradigm. Some of the problems in achieving this ideal are: accommodation of different syntactic notations, accommodation of diverse execution models, support for different implementation strategies, ability to use existing tools, and arbitrary paradigm mixing and matching. Some of these problems can be overcome by designing around an object-based multiparadigm programming environment. In an object based multiparadigm programming environment every paradigm forms a class, and every module written in that paradigm is an object member of that paradigm's class. Paradigms form the class hierarchy with the target machine architecture being the root of it. Inheritance is used to bridge the semantic gaps between different paradigms. In the following paragraphs we will present these aspects in greater detail and discuss a possible design abstraction for multi-language module inter-operation.

2 of 7 03/02/2007 15:37 2 Paradigms as Object Classes 2.1 Objects An object can be used as the abstraction mechanism for code written in a given paradigm. Such objects need to have at least three instance variables (Figure 1): 2. 3. Source code. The source code contained in an object is the module provided by the application programmer. Compiled code. The compiled code is an internal representation of that specification (generated by the class compilation method) that is used by the class execution method in order to implement the specification. Module state. The module state contains local data, dependent on the paradigm and its execution method, that is needed for executing the code of that object. Figure 1: Programming paradigm classes and objects Every object has at least one method:

3 of 7 03/02/2007 15:37 Instance initialisation method. The instance initialisation method is called once for every object instance when the object is loaded and before program execution begins. It can be used to initialise the module state variable. As an example, given the imperative paradigm and its concrete realisation in the form of Modula-2 [Wir85] programs, an object written in the imperative paradigm corresponds to a Modula-2 module. The source code variable of that object contains the source code of the module, the object code variable contains the compiled source, and the module state variable contains the contents of the global variables. In addition, the instance initialisation method is the initialisation code found delimited between BEGIN and END in the module body. 2.2 Classes All classes contain at least one class variable (Figure 1): Class_state: contains global data needed by the execution method for all instances of that class. In addition paradigm classes contain at least three methods: 2. 3. Compilation method. The compilation method is responsible for transforming, at compile-time, the source code written in that paradigm into the appropriate representation for execution at run-time. Class initialisation method. The class initialisation method of a paradigm is called on system startup in order to initialise the class variables of that class. It also calls the instance initialisation method for all objects of that class. Execution method. The execution method of a class provides the run-time support needed in order to implement a given paradigm. The compilation and execution methods also contain the machinery needed to implement the import and export call gates described in section 3. Taking as a paradigm class example, the logic programming paradigm realised as Prolog compiled into Warren abstract machine instructions [War83], the class state variable contains the heap, stack and trail needed by the abstract machine. In addition, the compilation method is the compiler translating Prolog clauses into abstract instructions, the class initialisation method is the code initialising the abstract machine interpreter, while the execution method is the interpreter itself. 2.3 Inheritance Inheritance is used to bridge the semantic gap between code written in a given paradigm and its execution on a concrete architecture. We regard the programming paradigm of the target architecture as the root class. If it is a uniprocessor architecture it has exactly one object instance, otherwise it has as many instances, as the number of processors. The execution method is implemented by the processor hardware and the class_state is contained in the processor registers. The compiled code and module state variables are kept in the processor's instruction and data memory respectively. From the root class we build a hierarchy of paradigms based on their semantic and syntactic relationships. Each subclass inherits the methods of its parent class, and can thus use them to implement a more sophisticated paradigm. This is achieved because each paradigm class creates a higher level of linguistic

4 of 7 03/02/2007 15:37 abstraction, which its subclasses can use. As an example most paradigms have a notion of dynamic memory; a class can be created to provide this feature for these paradigms. Two subclasses can be derived from that class, one for programmer-controlled memory allocation and deallocation and another for automatic garbage collection. As another example a simulation paradigm and a communicating sequential processes paradigm can both be subclasses of a coroutine-based paradigm. Subclassing is not only used for the run-time class execution methods. Syntactic (i.e. compile-time) features of paradigms can be captured with it as well. Many constraint logic languages share the syntax of Prolog, thus it is natural to think of a constraint logic paradigm as a subclass of the logic paradigm providing its own solver method, and extension to the Prolog syntax for specifying constraints. 3 Paradigm Inter-operation Paradigm inter-operation can be designed around an abstraction we name a call gate. A call gate is an interfacing point between two paradigms, one of which is a direct subclass of the other. We define two types of call gates: the import gate and the export gate. In order for a paradigm to use a service provided by another paradigm (this can be a procedure, clause, function, rule, or a port, depending on the other paradigm) that service must pass thought its import gate. Conversely, on the other paradigm the same service must pass through its export gate. The call gates are design abstractions and not concrete implementation models. They can be implemented manually or automatically by the paradigm compiler, the runtime environment, the end user, or a mixture of the three. Each paradigm provides an import and export gate and documents the conventions used and expected. The input of the export gate and the output of the import gate follow the conventions of the paradigm, while the output of the export gate and the input of the import gate follow the conventions of the paradigms' superclass (Figure 2). The target architecture paradigm combines its import and its export gate using the linked code as the sink for its export gate and the source for its import gate. Call gates can make the paradigm inter-operation transparent to the application programmer and provide global scale inter-operation using only local information.

5 of 7 03/02/2007 15:37 Figure 2: Paradigm inter-operation using call gates We must note at this point that the class hierarchy is not visible to the application programmer. The hierarchy is useful for the multiparadigm programming environment implementor, as it provides a structure for building the system, but is irrelevant to the application programmer, who only looks for the most suited paradigm to build his application. This is consistent with the recent trend in object-oriented programming of regarding inheritance as a producer's mechanism [Mey90], that has little to do with the end-user's use of the classes [Coo92]. Using to our approach a multiparadigm programming environment consists of a set of classes, one for each paradigm. The classes are ordered in a hierarchy whose root is the target architecture. Every class is self-contained and only needs to handle the calling conventions of its superclass and provide a mechanism for interfacing with its subclasses. Code in different paradigms is written in different source modules, which are then handled by the appropriate methods of the respective paradigm class. 4 Prototype Implementation In order to demonstrate the validity of our approach we have implemented three prototypes: The integrator is a multiparadigm application dealing with the numeric and symbolic evaluation of integrals. The symbolic evaluation is based on the backtracking resolution mechanism offered by the logic programming paradigm, and the numeric evaluation on the infinite streams implemented in the functional paradigm. Additionally, lexical analysis of the input expressions is described using regular expressions, and the expression grammar is described using a BNF syntax. Finally, expression simplification uses a term rewrite system and graphing of functions is done by directly interacting with Unix tools. Integrator is implemented in the blueprint multiparadigm programming environment, a prototype implementation of the six paradigms based on our object-oriented approach. Many different implementation techniques have been applied in order to demonstrate the wide applicability of our

6 of 7 03/02/2007 15:37 approach. Some of the paradigms are implemented as compilers (using existing implementations where possible); others are implemented as interpreters. Finally, the implementation of blueprint is based on a multiparadigm environment generator. This allows the description of paradigms as object classes using paradigm description files. Additionally, it provides a multiparadigm link editor and support for incorporating existing compilers into multiparadigm programming environments. 5 Proposed Workshop Topics Some topics that are interesting in the context of the work described above are the following: Object Size Granularity Least common denominator systems [Mee94] are efficient in their implementation at the cost of limited flexibility in the inter-operation between modules written in different languages. Systems that introduce some sort of translation services such as the ones described in section 3 can allow for more sophisticated transactions between modules at the cost of run-time efficiency. The efficiency penalty need not be great if a substantial part of the problem is solved within a module written in one language. Thus the object size granularity pays an important role in the efficiency and flexibility tradeoffs of such systems. Design methods, environments, and techniques that affect this granularity can be discussed. Type Systems and Dynamic Typing Although least common denominator approaches together with some sort of type checking link editors [Spi91] can solve many of the problems in this area dynamic typing introduces new problems that need be discussed. We propose the use of type gates similar in design to the call gates described in section 3. Heterogeneous Architectures Finally, in the area of architectures we believe that an architecture can be abstracted as an object by realising that the machine language of that architecture is part of our multi-language model, and that the machine's register and memory form that object's state. A suitable abstraction should be devised for the case of networked machines or connected processors running a multi-language implementation. References Coo92 William R. Cook. Interfaces and specifications for the Smalltalk-80 collection classes. ACM SIGPLAN Notices, 27(10):1-15, October 1992. Sevent Annual Conference on Object-Oriented Programming Systems, Languages and Applications, OOPSLA '92 Conference Proceedings, October 18-22, Vancouver, British Columbia, Canada. Mee94 Brian L. Meek. Programming languages: Towards greater commonality. ACM SIGPLAN Notices, 29(4):49-57, April 1994. Mey90 Bertrand Meyer. Lessons from the design of the Eiffel libraries. Communications of the ACM, 33(9):68-88, September 1990.

7 of 7 03/02/2007 15:37 SDE94a Diomidis Spinellis, Sophia Drossopoulou, and Susan Eisenbach. Language and architecture paradigms as object classes: A unified approach towards multiparadigm programming. In Jürg Gutknecht, editor, Programming Languages and System Architectures International Conference, pages 191-207, Zurich, Switzerland, March 1994. Springer-Verlag. Lecture Notes in Computer Science 782. SDE94b Diomidis Spinellis, Sophia Drossopoulou, and Susan Eisenbach. Object-oriented technology in multiparadigm language implementation. Journal of Object-Oriented Technology, 1994. Accepted to be published. Spi91 Diomidis Spinellis. Type-safe linkage for variables and functions. ACM SIGPLAN Notices, 26(8):74-79, August 199 War83 David H. D. Warren. An abstract Prolog instruction set. Technical Note 309, SRI International, Artificial Intelligence Center, Computer Science and Technology Division, 333 Ravenswood Ave., Menlo Park, CA, USA, October 1983. Wir85 Niklaus Wirth. Programming in Modula-2. Springer Verlag, third edition, 1985.