Object-oriented programming languages

5


Additional keywords and phrases: programming languages, orthogonality, reliability, complexity, types, delegation, multiple paradigms, prototypes, reflection


slide: Object-oriented programming languages

subsections:


The notion of object -- Simula


slide: The heritage of Simula


object-oriented


structurally

operationally

behaviorally


slide: Perspectives of object orientation


Objects -- language characteristics

  • object creation facility
  • message-passing capability
  • class capability
  • inheritance features

Classification

  • hybrid -- C, Lisp, Pascal, Prolog
  • frame-based -- knowledge-based reasoning
  • distributed, concurrent, actor -- parallel computing
  • alternative object models -- prototypes, delegation

slide: A classification of languages


Object extensions

Commercial products -- languages


slide: Object-oriented languages


class and struct">

Object structure -- efficient mapping

C++


  struct A { ... }  ==  class   A { public: ...  } 
  class   A { ... }  ==  struct A { private: ... } 
  

slide: The equivalence between


Script languages

Java embedding



slide: Script languages


  
  <script language=Javascript> 
javascript
function object_display(msg) { // object method return msg + ' (' + this.variable++ + ')'; } function object() { // object constructor this.variable=0; this.display = object_display; return this; } var a = new object(); // create object document.write(a.display("a message")); document.write(a.display("another message")); </script>

subsections:


Criteria for comparison


slide: Criteria for comparison


Language characteristics


slide: Language characteristics

subsections:


Object-oriented language design

  • object: state + operations
  • class: template for object creation
  • inheritance: super/base and subclasses


  object-oriented = 
        objects + classes + inheritance 
  

data abstraction -- state accessible by operations

strong typing -- compile time checking


slide: Object-based versus object-oriented


Orthogonal approach


slide: Orthogonal dimensions


Open systems

  • reactive -- flexible (dynamic) choice of actions
  • modular -- (static) scalability

Dimensions of modularity

  • encapsulation boundary -- interface to client
  • distribution boundary -- visibility from within objects
  • concurrency boundary -- threads per object, synchronization

slide: Dimensions of modularity


Object-based concurrency


slide: Objects and concurrency


sC++



  active class S { 
  public: 
     m () { ... } 
  private: 
     @S () {  // pseudo-constructor
           select { 
              01 -> m(); // external call 
              instructions ...
           || 
              accept m;  // accept internal method
              instructions ... 
           ||
              waituntil (date); // time-out
              instructions ... 
           ||
              default           // default
              instructions ... 
           } 
      } 
  };
  

slide: Synchronization conditions in sC++

subsections:


Prototypes -- exemplars


slide: Prototypes


State

  • slots -- parents
  • variables and methods

Creation

  • shallow cloning
  • deep cloning

Delegation

  • implicit delegation
  • explicit delegation

slide: Prototypes -- state, creation, delegation


Improving performance


slide: Improving performance


Self -- prototypes

Dynamic compilation -- type information


slide: Dynamic compilation -- Self


The class concept


slide: The concept of class



slide: Meta architectures


Postulates -- class-based languages


slide: Class-based languages -- postulates


Class">

Reflective definition of Class


   name         Class
   supers      (Object)
   iv     (name supers iv methods)
   methods      (new ...)
  

slide: A reflective definition of


The object paradigm

1



slide: Section 5.1: The object paradigm


Comparing Smalltalk, Eiffel, C++ and Java

2



slide: Section 5.2: Comparing Smalltalk, Eiffel, C++ and Java


Design dimensions of object-oriented languages

3



slide: Section 5.3: Design dimensions of object-oriented languages


Prototypes -- delegation versus inheritance

4



slide: Section 5.4: Prototypes -- delegation versus inheritance


Meta-level architectures

5



slide: Section 5.5: Meta-level architectures

  1. What are the basic characteristics of object-oriented languages?
  2. How would you classify object-oriented languages? Name a few representatives of each category.
  3. What do you consider to be the major characteristic of the object model supported by C++? Explain.
  4. Why would you need friends?
  5. How would you characterize the difference between object-based and object-oriented?
  6. Along what orthogonal dimensions would you design an object-oriented language? Explain.
  7. Give a characterisation of active objects. In what situations may active objects be advantageous?
  8. How would you characterize prototype-based languages?
  9. What are the differences between inheritance and delegation? Does C++ support delegation? Explain. And Java?
  10. How would you characterize the concept of a class?
  11. Can you sketch the meta architecture of Smalltalk?
  12. How would you phrase the postulates underlying class-based languages? Can you give a reflective version of these postulates?

A concise treatment of programming languages is given in  [BG94]. For a collection of papers on object-oriented concepts, see  [KL89]. Further, you may want to consult  [Wegner87], which contains the original presentation of the discussion concerning the distinction between {\em object-based} and {\em object-oriented}. Concurrency is studied in  [AWY93]. For Java, read the original white paper,  [Java]. An interesting extension of C++ is described in  [Petitpierre98]. At the corresponding web site, ltiwww.epfl.ch/sCxx , there is much additional material. Finally, for an account of the design and evolution of C++, read  [Stroustrup97]. For more information on C++, visit www.accu.org , and for Java, www.javasoft.com .