ECOOP Tutorial

ECOOP Tutorial


Typing in object-oriented languages: Achieving expressiveness and safety


Kim B. Bruce, Frederick Latimer Wells Professor of Computer Science, Williams College, Williamstown, MA 01267, USA.


Static typing can assist in earlier error detection, provide assistance to the compiler in making optimization, and provide important information to programmer as to how different constructs are intended to be used. However, the simple static-typing disciplines for object-oriented languages like C++, Object Pascal, and Modula-3 are often so restrictive that programmers are forced to by-pass the type system with type casts. Other languages allow more freedom, but require run-time checking to pick up the type errors that their more permissive systems missed.

This tutorial begins with a survey of problems (illustrated by a series of sample programs) with existing type systems, and suggests ways of improving the expressibility of these systems while retaining static type safety. In particular we will discuss the motivations behind introducing ``MyType'', ``matching'', and ``bounded matching'' (a form of bounded polymorphism) into these type systems. We include a brief discussion on how the type system and semantics ensure type safety.

The tutorial will also include a discussion of how these constructs could be added to existing languages like Java in order to enhance their expressiveness with little or no impact on run-time performance.


  1. Types in OO languages
    1. Types as interfaces
    2. Should classes be types in OOL's?
    3. Static vs. dynamic typing
  2. Review of fundamental concepts of OOL's
    1. Subtypes
      1. Record types
      2. Function types
      3. Variable types
    2. Subclasses
  3. Limitations of simple type systems (e.g., Object Pascal, C++) via examples
    1. Clone methods
    2. Classes with object components
    3. Binary methods
    4. Loosening rules too much: the Eiffel case.
  4. Loosening restrictions on types of methods in subclasses
    1. Allow method types to be subtypes in subclasses
    2. Instance variables can't change
    3. Still not flexible enough
  5. MyType and Matching
    1. MyType solves Clone and binary method problems
    2. Requires more care in type-checking: matching
    3. Subclass is not subtype
    4. Subtyping for object types with MyType
  6. Constrained Genericity
    1. Subtyping does not provide useful constraint for polymorphism
    2. Matching works well (examples)
    3. Using constrained genericity to replace covariant typing
  7. Revealing what is under the hood: Type checking and Semantics
    1. Formalizing type rules
    2. Formalizing natural (operational) semantics
    3. Type safety
  8. Reducing complexity
    1. Throw out subtyping in favor of matching
    2. Introduce #-types to handle heterogeneous types
    3. Result is significantly simpler language
    4. Disadvantages
      1. Planning ahead
      2. Binary methods restricted to non-#-types.
  9. Modules & information hiding using matching
  10. Comparison with type systems of existing languages
    1. Object Pascal, C++, Modula-3
    2. Eiffel
    3. Ada 95
  11. Adding MyType and bounded matching to Java & other OOL's
    1. Design trade-offs
    2. Sample programs
  12. Summary and future outlook


Half day


Advanced to intermediate

Required experience:

Familiarity with and experience using class-based object-oriented programming languages. Experience with static typing systems.

Expected Audience:

Programmers who would like the flexibility of weakly or dynamically typed languages, but the error detection and efficiency of statically-typed languages. This should be of interest to language designers as well as others who would like to see the applications of type theory to language design.

Presenter's profile:

Kim Bruce is Wells Professor of Computer Science at Williams College in Massachusetts, USA. He received his B.A. from Pomona College and Ph.D. from the University of Wisconsin. He taught at Princeton University before coming to Williams, and has been a visiting professor or scientist at M.I.T., Stanford, Ecole Normale Superieure, the University of Pisa, and the Newton Institute for Mathematical Sciences at Cambridge University. He has worked on the semantics of object-oriented languages for the last 10 years, and provably-safe type systems for object-oriented languages for the last 5 years. He has served on the OOPSLA program committee, and has been co-organizer of workshops on the Foundations of Object-Oriented Languages in 1993, 1994, and 1996. He has presented papers at the ECOOP, OOPSLA, POPL, MFPS, and LICS conferences, and currently serves on the editorial boards for TAPOS and the forthcoming CRC Handbook of Computer Science and Engineering. My vita, some of my papers, and other information is available through my home page.


Some of the material in this tutorial will be based on my recently completed paper, "Typing in object-oriented languages: Achieving expressiveness and safety," which has been accepted for publication in Computer Surveys.