The successes and failures of a language as a language extension. Kasper B. Graversen presented at ECOOP’03 workshop 15.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Design by Contract.
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
Object-Oriented PHP (1)
1 Collaboration-Based Role-Oriented Programming Kasper B. Graversen.
Collaboration based Role-Oriented Programming Kasper B. Graversen.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 24: Dynamic Binding COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
Inheritance and Polymorphism CS351 – Programming Paradigms.
3/15/05H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
A First Program Using C#
Comparison of OO Programming Languages © Jason Voegele, 2003.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Introduction to Object-oriented programming and software development Lecture 1.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
Introduction By: Dr. Javad Razjouyan. Programming Languages.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Language processors (Chapter 2) 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture.
CSSE501 Object-Oriented Development. Chapter 12: Implications of Substitution  In this chapter we will investigate some of the implications of the principle.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Object Oriented Programming in PHP. Topics Quick OOP Review Classes Magic Methods Static Methods Inheritance Exceptions Interfaces Operators Type Hinting.
Introduction to COM and ActiveX Controls. What is an object? In the Fayad sense of the word.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Object Oriented Software Development
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Learners Support Publications Object Oriented Programming.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Silberschatz, Galvin and Gagne  Operating System Concepts UNIT II Operating System Services.
Starting Out with C++ Early Objects ~~ 7 th Edition by Tony Gaddis, Judy Walters, Godfrey Muganda Modified for CMPS 1044 Midwestern State University 6-1.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 20 – C++ Subclasses and Inheritance.
3/1/01H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
Adding Concurrency to a Programming Language Peter A. Buhr and Glen Ditchfield USENIX C++ Technical Conference, Portland, Oregon, U. S. A., August 1992.
Programming paradigms
Compiler, Interpreter, and Bootstrapping
Threads Cannot Be Implemented As a Library
Review: Two Programming Paradigms
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Interfaces and Inheritance
Java Programming Language
Polymorphism and access control
More Object-Oriented Programming
Polymorphism Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan.
CISC/CMPE320 - Prof. McLeod
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Abstract Classes and Interfaces
VIRTUAL FUNCTIONS RITIKA SHARMA.
Object-Oriented PHP (1)
1.3.7 High- and low-level languages and their translators
Design of the Parrot Virtual Machine The OO-ish bits
Presentation transcript:

The successes and failures of a language as a language extension. Kasper B. Graversen presented at ECOOP’03 workshop 15

The presentation The role concept Our approach What problems did we face What did we find advantageous about language extensions API is just as important... Conclusions

The role concept 1/2 Motivation for roles  Bridging the gab between the problem domain and the implementation domain  In the real world no object can be understood outside its context(s) Roles models a perspective of an object  In the real world nothing is static

The role concept 2/2 Technical goals  Roles are subtypes of their intrinsic  Applicable run-time and at the instance level.  An object may play several roles simultaneously—even roles of the same time (comparable to Eiffel's repeated inheritance).  Statically type safe.  Has constituents, which augment existing methods.

The presentation The role concept Our approach What problems did we face What did we find advantageous about language extensions API is just as important... Conclusions

Approach Host language: Java We made a pre-compiler emitting Java source code. Our work mainly consisted of thinking in code-transformations and loopholes to get the desired end-result.

Implementation 1/3 Delegation (w. late binding of self.)  Every call is made on an introduced pointer (self), which is passed around with each method call. Roles became “part-object” which delegated messages (for the methods they inherited but did not overwrite). Constituent methods forced us to re- define the delegation concept to “latest possible binding of self”.

:B Implementation 2/3 class B { void bar(){} } Role R for B { } r =new R( new B() ); r.bar(); :R r : rolemanager

:A foo Implementation 3/3 (re-defining delegation) class A { void foo } Role R for A { constituent c before foo { baz(); } void baz() {} } A a = new A(); new R( a ); a.foo(); :R c baz : rolemanager Message receiver (= self) is a, but a does not have a baz() hence, during constituent execution self must be the constituent a (simplified version)

The presentation The role concept Our approach What problems did we face What did we find advantageous about language extensions API is just as important... Conclusions

Main obstacles 1/6 No access to method dispatching  We had to maintain and pass around a self-pointer (in all methods and method calls)  Problematic when going “outside”, then “inside” chameleon code in the same call, as we then have two self references Chameleon-Java Java

Main obstacles 2/6 Typing  Impossible to assign types to classes (using interfaces is non-trivial and fields+ protected methods cannot be part of the type).  Problematic to attach a role to a sub- type of its intrinsic A foo() B foo() bar() R pip() bar(); :B :R foo 1.self = :R 2.R: delegates to intrinsic’s foo 3.B: calls self.bar() 4.self has no bar! (but we know one exists!)

Restricted access to properties – we could only get access by using Java’s inheritance. Inheritted unwanted:  fields (memory inefficient)  methods, since constituents could be attached the intrisics’ methods, they had to be executed if they were not overwritten in the role. We could not express dual inheritance, due to lack of multiple inheritance in Java. Main obstacles 3/6

No field access detection  We had to create accessor-methods and transform the code to using these  Field access became virtual Shadowing fields would result in faulty programs  Java programs could not use Chameleon-compiled code unless using accessor-methods which were not present in the Chameleon source code. Main obstacles 4/6

Hard to debug programs which the Java compiler failed compiling  The programmer had to know the steps of, and the code transformations.  And then in his head, reverse the transformations in order to find the problem spot in the Chameleon code. Main obstacles 5/6

Programming languages not only delimits expressional power, they delimit/direct our thoughts.  There were concepts in the first article we read on the subject (Kristensen and Østerbye 94), we could not comprehend.  We invented things, the authors of the above article had not thought of (but which would be very important for their implementations). Main obstacles 6/6

The presentation The role concept Our approach What problems did we face What did we find advantageous about language extensions API is just as important... Conclusions

Advantages It gave us a rocket start  In 2 days from start, we had rudimentary roles (with faulty delegation it turned out later :-).  It was relatively easy to think in terms of Java code-transformations rather than assembler instructions.  Enabled us to use/play with small programs to gain an understanding of the concept.

Advantages Extending the role concept was rather straight forward  Symbiosis between implementation and conceptual extensions.  We believe we would not have come as far with a lower-level implementation of our role concept. Existing Java programs could be used in our Chameleon programs, and vice-versa.

The presentation The role concept Our approach What problems did we face What did we find advantageous about language extensions API is just as important... Conclusions

API is just as important Ideas for new languages/extensions must be tried in real world scenarios! This is hard if the language is shielded from the outside world  We need I/O (disc,database,network,keyboard,mouse) Graphical User Interface (elemental data structures) Language extensions can usually effortless use the host language API.

The presentation The role concept Our approach What problems did we face What did we find advantageous about language extensions API is just as important... Conclusions

Conclusions Extending Java was nice since  We got a quick start  We had a huge API available  Existing programs could use Chameleon classes.  We found it a manageable task to extend the role concept in many directions.

Conclusions Extending Java was NOT nice since  Many severe problems arise when really grinding into the issues of the language.  Most things which seemed to be reusable from the host language turns out to be obstacles.  A userfriendly language extension requires a parser, type checker, ‘code mutator’ and a ‘host language emitter’ (almost?) as huge a task as building a compiler from scratch.

The end...