SlideShare a Scribd company logo
1 of 71
A Featherweight
              Approach
              to FOOL
Atsushi
 Igarashi
Kyoto Univ.
What I Have Been Working On
Type theory and its applications:
  Static program analysis based on type inference
  Behavioral types for concurrent programs
  Multi-stage programming
    Type systems based on modal logic
  Object-oriented programming
What is FOOL?
“Foundations of Object-Oriented Languages”
  Semantics
  Type Theory
  Verification techniques
For the development of
  Correct systems
  Correct compilers
What I Mean By
    a “Featherweight Approach”
Usual scientific approach to a complex problem:
  Discarding irrelevant details
  To concentrate on central issues
With a stronger emphasis on simplicity
  Even “lighter” than lightweight
My Featherweight Approach to
           FOOL
                 1. Build a tiny
                    model of OOPLs
My Featherweight Approach to
            FOOL




                            ...
2. Extend the model with
   cool mechanisms




  3. Study their theories to

                            ...
     show they are reasonable and ...
My Featherweight Approach to
               FOOL




... hope someone
implements them :-)
                      ?
Longman Dictionary of Contemporary English says...

                       2
 lightweight adj 1 weighing less than average:
 special lightweight fabric
Longman Dictionary of Contemporary English says...

                       2
 lightweight adj 1 weighing less than average:
 special lightweight fabric 2 showing a lack of
 serious thought: She's written nothing but light-
 weight novels.




                                            Uh-oh...
Aim of This Talk
Convince that featherweight approaches
  have been useful for FOOL
     esp. language extensions
  (are not lightweight in the second sense)
Share some lessons I learned over the years
Table of Contents
A brief review of FOOL study in mid 80s & 90s
Featherweight Java (FJ)
  A tiny model of (Java-like) class-based
  OOPLs
Applications of FJ
  Generics
  Inner Classes
  Variance
A Few Final Words
A Brief History of
   FOOL Study
  in '80s & '90s
Caveats
(Un)intentionally oversimplified
Focusing only on Smalltalk-style languages
  Class-based
  Single-dispatch
Early FOOL Study
Main questions:
  What are objects?
  What are inheritance, subtyping, and their
  relationship?
  What is a static type system for objects?
Approach: “Landin reductionism”

Slogan: “Express everything in the λ-calculus!”
  Object as a recursive record of functions
  Message send as field projection
  Class as a function from “self” to a method suite
    Parameterization to express late binding
  Inheritance as record extension
    {x=3} ++ {y=2}             {x=3; y=2}
Early Type Theory for Objects
Object type ≒ (recursive) record types
'84: Record and function subtyping [Cardelli]
  '85: Bounded quantification [Cardelli&Wegner]

      '89: F-bounded quantification [Canning et al.]
        '91: Subtyping recursive types     [Amadio&Cardelli]


                 Lots of cool ideas,
                 but somewhat overwhelming...
FOOL Study in '90s
      Simpler approaches to typed objects
'92: Existential encoding [Pierce&Turner92]
  '93〜 Calculi of primitive objects
    '96:      [Abadi&Cardelli][Fisher,Honsel&Mitchell]

             A slight departure from Landin
            reductionism
               Base calculi are still very primitive
Be
  twe
     en
        T   he
              ory
                    an
                       d   P ra
                               cti
                                  ce
aka. declaration-based
                   Theory        Practice
Subtyping      Structural      Nominal ()
Classes        First-class () Second-class
  Result from (intentional?) confusion between
     classes and types
     inheritance and subtyping
  A consequence of Ladin reductionism
     Classes have to be given types
Summarizing FOOL Study
        until Mid '90s
Encoding objects and classes into very
primitive calculi
  Successful especially for untyped objects
Lots of interesting and substantial type theory
Still gaps from mainstream languages
Table of Contents
A brief review of FOOL study in mid 80s & 90s
Featherweight Java (FJ)
Applications of FJ
A Few Final Words
Boom of Java!
Triggered two lines of research:
  “Is Java really safe?”
    A FOOL-ish question, obviously!
  “It's a chance to add my cool idea to this
  new popular language!”
    Generics, Multi-methods, Virtual Types,
    Mixins...
Research on Type Safety of Java
  “Java is not Type Safe” [Saraswat97]
  “Java is Type Safe – Probably” [Drossopoulou&Eisenbach97]
  “Javalight is Type Safe – Definitely” [Nipkow&von Oheimb98]
and many other interesting papers...
Research on Type Safety of Java
“Java is not type safe” [Saraswat97]
  Pointing out a class loader bug
“Java is Type Safe – Probably” [Drossopoulou&Eisenbach97]
  Formal model of a significant subset of Java
  Type safety proofs
“Javalight is Type Safe – Definitely” [Nipkow&von Oheimb98]
  Model and proofs mechanized on Isabelle/HOL
Language Extensions Reseach
Few papers really discuss foundational issues
Some notable exceptions:
  “Classes and Mixins” [Flatt, Krishnamurthi & Felleisen'98]
    ClassicJava: A subset of imprerative Java
    MixedJava: ClassicJava with mixins
  “Ownership Types for Flexible Alias Protection”
  [Clarke, Potter & Noble'98]
“Featherweight Java:
A Minimal Core Calculus for Java and GJ”
    by I., B.C. Pierce, & P. Wadler [OOPSLA'99, TOPLAS'01]

 A sublanguage of Java with a formal type system
 and (operational) semantics
  Minimal set of features
    (Second-class) classes with (single) inheritance
    Recursion through this
   Dynamic typecast
   No assignments
 The choice of features depended upon the main
 motivation, namely...
Main Motivation
Study of foundational issues of generics for
Java (in particular, GJ [Bracha et al. 98])
  Type safety
  Correctness of “erasure” compilation to
  JVML

Not to prove type safety of as large a subset of
Java as possible
Main Technical Results
Def. of Featherweight Java (FJ)
Type safety theorem of FJ
Def. of Featherweight GJ (FGJ)
  An extension of FJ with generics
  “Direct” operational semantics
Type safety of Featherweight GJ
Def. of compilation from FGJ to FJ
Theorem of compilation correctness
FJ: Some Points of Interest
Classes are second-class citizens
Nominal subtyping               Inherited from
  Reminiscent of “Amber rule”      earlier work
Dynamic casts
  Needed to model erasure compilation
Minimal set of language features
  Lack of assignments
Classes are Second-Class
Classes are not part of expressions to “run”
P (programs) ::= (L1 ,...,Ln ,,e)
 P (programs) ::= (L1 ,...,Ln e)           L (classes) ::= ...
                                            L (classes) ::= ...
e (expr.) ::= xx| |e.m(e1,...,en) | |new
 e (expr.) ::=      e.m(e ,...,e ) new     C(e1,...,en) | |...
                                           C(e ,...,e ) ...
                         1    n                 1     n
  Reduction: e  e' (under a fixed set of classes)
    c.f. Term rewriting systems
Classes do not really compose
  No need for fancy operations on records
No type expressions for classes
  Expression typing: x1:C1,...,xn:Cn┣ e : C
  Class typing: L ok
Nominal Subtyping
Subtyping relation C <:D is extracted from
extends clauses of the given classes
Subtyping is “confirmed” to be safe only after
typechecking
  esp. after checking correct method overriding
  c.f. Subtyping for recursive types (Amber rule)
Declaration-based Subtyping
Subtyping relation C <:D is extracted from
extends clauses of the given classes
Subtyping is “confirmed” <:be safe only <: T(Y)
                      X to Y ┣ S(X) after
typechecking
                        ┣ X.S(X) <: Y.T(Y)
   esp. after checking correct method overriding
   c.f. Subtyping for recursive types (Amber rule)
Obj.{clone: ()→Obj, …}
  <:
Num.{clone: ()→Num, ...}
Dynamic Casts
Hard to express in typed lambda-calculus
  Casts bypass typechecking
  Casts do run-time checking, which compares
  class names according to extends
Required (only) to model erasure compilation
  Obvious candidates of further simplification
Minimal Set of Features
  This is the whole syntax of FJ!
P (programs) ::= (L1,...,Ln, e)
L (classes) ::=
   class C extends C { C f;... C f; K M … M }
K (constructors) ::= ...
M (methods) ::= C m(C x,...,C x){ return e; }
e (expressions) ::=
     x | this | e.f | e.m(~e) | new C(~e) | (C)e
Quantitative Evaluation
Quantitative Evaluation :-)

FJ: 1 page, in 9pt, two columns,
0.0 pounds

                           rd
                     JLS 3 ed.: 650 pages,
                     2.2 pounds
Re: Lack of Assignments
We felt formalizing assignments wouldn't give us
deeper insights (matching the price to pay)
  Some reasonable responses we got:
    “State change is the essence of OO!”
    “Do you know ML type inference?”
      In fact, GJ type inference turned out to be
      flawed later ;-( [Jefferey]
  One (and, perhaps, only) justification (excuse?):
    Interesting results even without them
Pleasant Surprise!
FJ has become a popular tool to study (type
systems of) language extensions
  Especially, class-based language abstractions
Some reasons for wide adoption:
  The name was catchy, perhaps (thanks, Phil!)
      Initially called “the J-calculus,” IIRC
  It doesn't have your favorite mechanism
      You cannot help adding something!
Applications of FJ
Existing Advanced   New Advanced
Class Mechanisms    Class Mechanisms
                                            Self Type
                      Use-site
                       Use-site              Self Type
  Generics
  Generics            Variance
                                           Constructors
                                           Constructors
                      Variance              [OOPSLA'09]
                                             [OOPSLA'09]

                     Lightweight Family Gradua Typing
                      Lightweight Family Gradua Typing
                       Polymorphism       [OOPSLA'11]
                                           [OOPSLA'11]
                        Polymorphism
                      [APLAS'05; JFP'08]
     Inner
      Inner            [APLAS'05; JFP'08]

    Classes
    Classes                      Variant Path Types
                                  Variant Path Types
                                         [OOPSLA'07]
                                          [OOPSLA'07]

                      Union types
                      Union types
                     [SAC'06; JOT'07]
                      [SAC'06; JOT'07]
Applications of FJ
Existing Advanced   New Advanced
Class Mechanisms    Class Mechanisms
                                            Self Type
                      Use-site
                       Use-site              Self Type
  Generics
  Generics            Variance
                                           Constructors
                                           Constructors
                      Variance              [OOPSLA'09]
                                             [OOPSLA'09]

                     Lightweight Family Gradua Typing
                      Lightweight Family Gradua Typing
                       Polymorphism       [OOPSLA'11]
                                           [OOPSLA'11]
                        Polymorphism
                      [APLAS'05; JFP'08]
     Inner
      Inner            [APLAS'05; JFP'08]

    Classes
    Classes                      Variant Path Types
                                  Variant Path Types
                                         [OOPSLA'07]
                                          [OOPSLA'07]

                      Union types
                      Union types
                     [SAC'06; JOT'07]
                      [SAC'06; JOT'07]
Formal Semantics for Inner Classes
        I. & B.C. Pierce. “On Inner Classes” [ECOOP'00]

Applying FJ to inner classes of Java 1.2 to answer
  How do inheritance and nesting interact when
      An inner class can access members of an
      enclosing class
      A top-level subclass can extend an inner class
      nested in an unrelated class
  ?
Interesting
Nightmarish Aspect of This Work
Inner Classes Specification didn't help figuring
out corner cases
It was “software physics”:
  Observe the behavior of software (in this case,
  javac)
    without reading the source code
  Formalize it!
       Indeed, this work led us to
 (re)discovering (known) compiler bugs
Applications of FJ
Existing Advanced   New Advanced
Class Mechanisms    Class Mechanisms
                                           Self Type
                      Use-site
                       Use-site             Self Type
  Generics
  Generics            Variance
                                          Constructors
                                          Constructors
                      Variance               [OOPSLA'09]
                                              [OOPSLA'09]

                     Lightweight Family Gradua Typing
                      Lightweight Family Gradua Typing
                       Polymorphism       [OOPSLA'11]
                                           [OOPSLA'11]
                        Polymorphism
                       [APLAS'05; JFP'08]
     Inner
      Inner             [APLAS'05; JFP'08]

    Classes
    Classes                       Variant Path Types
                                   Variant Path Types
                                        [OOPSLA'07]
                                         [OOPSLA'07]

                     Union types
                     Union types
                    [SAC'06; JOT'07]
                     [SAC'06; JOT'07]
Type System for Use-Site Variance
I. & M. Viroli. “On Variance-Based Subtyping for Parametric Types”
                             [ECOOP'02]

   Slogan: “More Subtyping for Generics”
     Generalization of structural virtual types
   Formalization on top of Featherweight GJ
   First type safety proof of a variance system
     Existential types as a background theory
   Basis of Java Wildcards
Two Subtyping Schemes for
           Generics
Inheritance-based subtyping:
  Q: When C<T> <: D<T> for given type T?
  A: class C<X> extends D<X> {...}
Variance-based subtyping:
  Q: When C<S> <: C<T>?
    Subtyping between two types from the
    same generic class
List<Integer> <: List<Number>?

A few different Answers:
  Unsafe subtyping (Eiffel around '90 [Cook90]):
  “Yes, as long as your program doesn't add a
  Number to List<Number>.”
    “Otherwise, your program may crash :-p ”
    Java array types inherit this
  Definition-site variance (POOL-I   [America90])

  Use-site variance
Definition-Site Variance
“Yes, provided that List doesn't have public
methods to put elements”
  Type parameter declaration with a variance property
  Trade-off between methods and subtyping
 class List<+X> {
 class List<+X> {          class List<-X> {
                           class List<-X> {
   // List<Int>
   // List<Int>              // List<Num>
                             // List<Num>
   //
   //   <: List<Num>
        <: List<Num>         //
                             //   <: List<Int>
                                  <: List<Int>
   // no meth. to put
   // no meth. to put        // no meth. to get
                             // no meth. to get
 }
 }                         }
                           }
When you need RWLists ...




                   RWList<Num>




class RWList<X>
 X head();         RWList<Int>
 void add(X x);
 int length();
When you need RWLists ...

                          ROList<Num>



 intf ROList<+X>   RWList<Num>
  X head();
  int length();
                          ROList<Int>
class RWList<X>
 X head();         RWList<Int>
 void add(X x);
 int length();
When you need RWLists ...
   intf LenList                LenList
     int length();
                      WOList<Num>   ROList<Num>
intf WOList<-X>
 void add(X x);
 int length();
    intf ROList<+X>          RWList<Num>
     X head();
     int length();
                      WOList<Int>   ROList<Int>
  class RWList<X>
   X head();                 RWList<Int>
   void add(X x);
   int length();
When you need RWLists ...
   intf LenList                  LenList
     int length();
                       WOList<Num>     ROList<Num>
   Careful advanced planning would be needed
intf WOList<-X>
 void add(X x);
 int length(); under nominal subtyping
     Especially
     Because supertypes cannot be added later
     intf ROList<+X>           RWList<Num>
      X head();
   (POOL-I is based on structural subtyping)
      int length();
                       WOList<Int>      ROList<Int>
  class RWList<X>
   X head();                  RWList<Int>
   void add(X x);
   int length();
Our Answer:
 Use-Site Variance                    List<*>

Different interfaces from a single generic class by
annotating actual type arguments
  add() missing in     List<-Num>          List<+Num>
  List<+T> and List<*>
  head() missing
  in List<-T>                        List<Num>
  and List<*>
   class List<X>             List<-Int>    List<+Int>
    X head();
    void add(X x);
                                     List<Int>
    int length();
Use-site Variance as Existential Types
A variable of List<+Num> can store
  List<Int>, List<Float>, and so on
  namely, List of some kind of numbers
In type theory, such a type is expressed as an
existential type ∃X<:Num.List<X>
  Similarly, List<-Num> = ∃X:>Num.List<X>

 Typing rules for use-site variance follow
   from this intuitive correspondence!
It's a Natural Idea (to me :-)!
Virtual types as an alternative to generics       [Thorup 97]

Safe virtual types [Torgersen 98]
Structural virtual types [Thorup&Torgersen 99]
  Essentially, use-site variance only with
  List<T> and List<+T>
Modeling virtual types as existentials      [I.&Pierce 99]
From Use-Site Variance to Wildcards
  “Adding Wildcards to the Java Programming Language”
                   [Torgersen at al. 04]
 Cosmetic changes ...
 List<*>                  List<?>
 List<+Number>            List<? extends Number>
 List<-Number>            List<? super Number>
     Emphasizing the existential nature
       which we tried to hide under the hood :-)
 ... and some other improvements to make them
 useful
 Adaption of library to take adv. of wildcards
Some Criticisms on Wildcards
“Use-site variance places a great burden on the
user of generic types” [Emir et al. 06]
   In fact, OCaml, Scala and C# later adopt
   definition-site variance
Decidability of subtyping of use-site variance is
still open! [Kennedy&Pierce07]
And even...
“We simply cannot afford
     another wildcards”
               – Joshua Bloch
“I feel sorry for students when I have
  to teach what I cannot understand”
                    – Anonymous (Japanese Prof.)
What's Unusual about
        Use-Site Variance
Subtyping with more of structural flavor
                Types        Type comparison
 Java 1.x    Atomic       Atomic
 GJ          Structural   Mostly atomic
 Wildcards   Structural   Structural

Separation of static and run-time types
  There is no instance of List<+Num>
“Post hoc” supertypes
Was It Really a Bad Idea?
I'm not qualified to judge :-)
   Maybe only history will tell us
Still, post-hoc supertypes are often very useful
  C<S> and C<T> always have a common
  supertype C<? extends U> (for S, T <: U)
     Otherwise, it might even be Object
Further research is needed, anyway
  “Taming the Wildcards” [Altidor, Huang, Smaragdakis11]
Table of Contents
A brief review of FOOL study in mid 80s & 90s
Featherweight Java (FJ)
Applications of FJ
  Formalizing Advanced Class Mechanisms
  Designing Advanced Class Mechanisms
Final Words
Final Words
You can throw away most
as long as something interesting is left
should
      You can throw away most
as long as something interesting is left
 to distill




   Serious thought
   needed, though!
Type systems should help people
Type systems should help people
  write programs in good styles
Igarashi's Conjecture
If a new, cool programming
style emerges, there will be a
type system to enforce it.
Working for building FOOL might not
   look very attractive at first...
… but, the Fun of Your OO Life is
     Dependent on FOOL!
… but, the Fun of Your OO Life is
     Dependent on FOOL!




Really!
To my collaborators:
    João Filipe Belo Shigeru Chiba Michael Greenberg
        Robert Hirschfeld Lintaro Ina Masashi Iwaki
           Futoshi Iwama Yukiyoshi Kameyama
  Naoki Kobayashi Kensuke Kojima Hidehiko Masuhara
         Hideshi Nagira Benjamin C. Pierce
     Chieri Saito Takafumi Sakurai Masahiko Sato
             Naokata Shikuma Manabu Toyama
       Takeshi Tsukada   Mirko Viroli Philip Wadler
                 Yosihiro Yuse   Salikh Zakirov

   … my family and ALL users of FJ!

More Related Content

What's hot

Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...
Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...
Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...Facultad de Informática UCM
 
Package-based Description Logics – Preliminary Results
Package-based Description Logics – Preliminary ResultsPackage-based Description Logics – Preliminary Results
Package-based Description Logics – Preliminary ResultsJie Bao
 
Cs599 Fall2005 Lecture 01
Cs599 Fall2005 Lecture 01Cs599 Fall2005 Lecture 01
Cs599 Fall2005 Lecture 01Dr. Cupid Lucid
 
Lean Logic for Lean Times: Varieties of Natural Logic
Lean Logic for Lean Times: Varieties of Natural LogicLean Logic for Lean Times: Varieties of Natural Logic
Lean Logic for Lean Times: Varieties of Natural LogicValeria de Paiva
 
OOP programming
OOP programmingOOP programming
OOP programminganhdbh
 
Adapt OWL as a Modular Ontology Language
Adapt OWL as a Modular Ontology LanguageAdapt OWL as a Modular Ontology Language
Adapt OWL as a Modular Ontology LanguageJie Bao
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingmustafa sarac
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONLalitkumar_98
 
Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)Jie Bao
 
Ekaterina vylomova-what-do-neural models-know-about-language-p1
Ekaterina vylomova-what-do-neural models-know-about-language-p1Ekaterina vylomova-what-do-neural models-know-about-language-p1
Ekaterina vylomova-what-do-neural models-know-about-language-p1Katerina Vylomova
 
Python Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and PolymorphismPython Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and PolymorphismRanel Padon
 
Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014Cognitum
 

What's hot (20)

Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Talking to your IDE
Talking to your IDETalking to your IDE
Talking to your IDE
 
Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...
Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...
Languages, Ontologies and Automatic Grammar Generation - Prof. Pedro Rangel H...
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
 
Package-based Description Logics – Preliminary Results
Package-based Description Logics – Preliminary ResultsPackage-based Description Logics – Preliminary Results
Package-based Description Logics – Preliminary Results
 
Cs599 Fall2005 Lecture 01
Cs599 Fall2005 Lecture 01Cs599 Fall2005 Lecture 01
Cs599 Fall2005 Lecture 01
 
Lean Logic for Lean Times: Varieties of Natural Logic
Lean Logic for Lean Times: Varieties of Natural LogicLean Logic for Lean Times: Varieties of Natural Logic
Lean Logic for Lean Times: Varieties of Natural Logic
 
OOP programming
OOP programmingOOP programming
OOP programming
 
OOP by hrishikesh dhola
OOP by hrishikesh dholaOOP by hrishikesh dhola
OOP by hrishikesh dhola
 
Adapt OWL as a Modular Ontology Language
Adapt OWL as a Modular Ontology LanguageAdapt OWL as a Modular Ontology Language
Adapt OWL as a Modular Ontology Language
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Java Notes
Java NotesJava Notes
Java Notes
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHON
 
Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)Representing and Reasoning with Modular Ontologies (2007)
Representing and Reasoning with Modular Ontologies (2007)
 
Oop java
Oop javaOop java
Oop java
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
Ekaterina vylomova-what-do-neural models-know-about-language-p1
Ekaterina vylomova-what-do-neural models-know-about-language-p1Ekaterina vylomova-what-do-neural models-know-about-language-p1
Ekaterina vylomova-what-do-neural models-know-about-language-p1
 
Python Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and PolymorphismPython Programming - VIII. Inheritance and Polymorphism
Python Programming - VIII. Inheritance and Polymorphism
 
Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014Introduction to Ontology Engineering with Fluent Editor 2014
Introduction to Ontology Engineering with Fluent Editor 2014
 

Viewers also liked

Expressiveness, Simplicity and Users
Expressiveness, Simplicity and UsersExpressiveness, Simplicity and Users
Expressiveness, Simplicity and Usersgreenwop
 
Unifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service ClientsUnifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service Clientsgreenwop
 
Esg design resume
Esg design resumeEsg design resume
Esg design resumeelainegroth
 
The Rise of Dynamic Languages
The Rise of Dynamic LanguagesThe Rise of Dynamic Languages
The Rise of Dynamic Languagesgreenwop
 

Viewers also liked (6)

Expressiveness, Simplicity and Users
Expressiveness, Simplicity and UsersExpressiveness, Simplicity and Users
Expressiveness, Simplicity and Users
 
2011 Mark Lierman Scholarship Awardee presentation
2011 Mark Lierman Scholarship Awardee presentation2011 Mark Lierman Scholarship Awardee presentation
2011 Mark Lierman Scholarship Awardee presentation
 
Unifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service ClientsUnifying Remote Data, Remote Procedure, and Service Clients
Unifying Remote Data, Remote Procedure, and Service Clients
 
Esg design resume
Esg design resumeEsg design resume
Esg design resume
 
The Rise of Dynamic Languages
The Rise of Dynamic LanguagesThe Rise of Dynamic Languages
The Rise of Dynamic Languages
 
938 3873-5-pb
938 3873-5-pb938 3873-5-pb
938 3873-5-pb
 

Similar to A Featherweight Approach to FOOL

download
downloaddownload
downloadbutest
 
download
downloaddownload
downloadbutest
 
Fun with Constructive Modalities
Fun with Constructive ModalitiesFun with Constructive Modalities
Fun with Constructive ModalitiesValeria de Paiva
 
Deep Learning for Search
Deep Learning for SearchDeep Learning for Search
Deep Learning for SearchBhaskar Mitra
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Ralf Laemmel
 
Oop by edgar lagman jr
Oop by edgar lagman jr Oop by edgar lagman jr
Oop by edgar lagman jr Jun-jun Lagman
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...David Beazley (Dabeaz LLC)
 
Constructive Description Logics 2006
Constructive Description Logics 2006Constructive Description Logics 2006
Constructive Description Logics 2006Valeria de Paiva
 
Machine Learning for NLP
Machine Learning for NLPMachine Learning for NLP
Machine Learning for NLPbutest
 
DTS s03e04 Typing
DTS s03e04 TypingDTS s03e04 Typing
DTS s03e04 TypingTuenti
 
Meta-Classes in Python
Meta-Classes in PythonMeta-Classes in Python
Meta-Classes in PythonGuy Wiener
 
Modern Compiler Design
Modern Compiler DesignModern Compiler Design
Modern Compiler Designnextlib
 

Similar to A Featherweight Approach to FOOL (20)

download
downloaddownload
download
 
download
downloaddownload
download
 
Subtyping
Subtyping Subtyping
Subtyping
 
Programing Language
Programing LanguagePrograming Language
Programing Language
 
From DOT to Dotty
From DOT to DottyFrom DOT to Dotty
From DOT to Dotty
 
Fun with Constructive Modalities
Fun with Constructive ModalitiesFun with Constructive Modalities
Fun with Constructive Modalities
 
grammer genration
grammer genration grammer genration
grammer genration
 
Deep Learning for Search
Deep Learning for SearchDeep Learning for Search
Deep Learning for Search
 
BT02.pptx
BT02.pptxBT02.pptx
BT02.pptx
 
Using UML for Ontology construction: a case study in Agriculture
Using UML for Ontology construction: a case study in AgricultureUsing UML for Ontology construction: a case study in Agriculture
Using UML for Ontology construction: a case study in Agriculture
 
Using uml for ontology construction a case study in agriculture
Using uml for ontology construction a case study in agricultureUsing uml for ontology construction a case study in agriculture
Using uml for ontology construction a case study in agriculture
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)
 
Knowledge Extraction
Knowledge ExtractionKnowledge Extraction
Knowledge Extraction
 
Oop by edgar lagman jr
Oop by edgar lagman jr Oop by edgar lagman jr
Oop by edgar lagman jr
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
 
Constructive Description Logics 2006
Constructive Description Logics 2006Constructive Description Logics 2006
Constructive Description Logics 2006
 
Machine Learning for NLP
Machine Learning for NLPMachine Learning for NLP
Machine Learning for NLP
 
DTS s03e04 Typing
DTS s03e04 TypingDTS s03e04 Typing
DTS s03e04 Typing
 
Meta-Classes in Python
Meta-Classes in PythonMeta-Classes in Python
Meta-Classes in Python
 
Modern Compiler Design
Modern Compiler DesignModern Compiler Design
Modern Compiler Design
 

More from greenwop

Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programsgreenwop
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Datagreenwop
 
Turning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful RacketTurning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful Racketgreenwop
 
Normal Considered Harmful
Normal Considered HarmfulNormal Considered Harmful
Normal Considered Harmfulgreenwop
 
Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?greenwop
 
High Performance JavaScript
High Performance JavaScriptHigh Performance JavaScript
High Performance JavaScriptgreenwop
 

More from greenwop (6)

Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programs
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
Turning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful RacketTurning a Tower of Babel into a Beautiful Racket
Turning a Tower of Babel into a Beautiful Racket
 
Normal Considered Harmful
Normal Considered HarmfulNormal Considered Harmful
Normal Considered Harmful
 
Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?Programming Language Memory Models: What do Shared Variables Mean?
Programming Language Memory Models: What do Shared Variables Mean?
 
High Performance JavaScript
High Performance JavaScriptHigh Performance JavaScript
High Performance JavaScript
 

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 

A Featherweight Approach to FOOL

  • 1. A Featherweight Approach to FOOL Atsushi Igarashi Kyoto Univ.
  • 2. What I Have Been Working On Type theory and its applications: Static program analysis based on type inference Behavioral types for concurrent programs Multi-stage programming Type systems based on modal logic Object-oriented programming
  • 3. What is FOOL? “Foundations of Object-Oriented Languages” Semantics Type Theory Verification techniques For the development of Correct systems Correct compilers
  • 4. What I Mean By a “Featherweight Approach” Usual scientific approach to a complex problem: Discarding irrelevant details To concentrate on central issues With a stronger emphasis on simplicity Even “lighter” than lightweight
  • 5. My Featherweight Approach to FOOL 1. Build a tiny model of OOPLs
  • 6. My Featherweight Approach to FOOL ... 2. Extend the model with cool mechanisms 3. Study their theories to ... show they are reasonable and ...
  • 7. My Featherweight Approach to FOOL ... hope someone implements them :-) ?
  • 8. Longman Dictionary of Contemporary English says... 2 lightweight adj 1 weighing less than average: special lightweight fabric
  • 9. Longman Dictionary of Contemporary English says... 2 lightweight adj 1 weighing less than average: special lightweight fabric 2 showing a lack of serious thought: She's written nothing but light- weight novels. Uh-oh...
  • 10. Aim of This Talk Convince that featherweight approaches have been useful for FOOL esp. language extensions (are not lightweight in the second sense) Share some lessons I learned over the years
  • 11. Table of Contents A brief review of FOOL study in mid 80s & 90s Featherweight Java (FJ) A tiny model of (Java-like) class-based OOPLs Applications of FJ Generics Inner Classes Variance A Few Final Words
  • 12. A Brief History of FOOL Study in '80s & '90s
  • 13. Caveats (Un)intentionally oversimplified Focusing only on Smalltalk-style languages Class-based Single-dispatch
  • 14. Early FOOL Study Main questions: What are objects? What are inheritance, subtyping, and their relationship? What is a static type system for objects?
  • 15. Approach: “Landin reductionism” Slogan: “Express everything in the λ-calculus!” Object as a recursive record of functions Message send as field projection Class as a function from “self” to a method suite Parameterization to express late binding Inheritance as record extension {x=3} ++ {y=2} {x=3; y=2}
  • 16. Early Type Theory for Objects Object type ≒ (recursive) record types '84: Record and function subtyping [Cardelli] '85: Bounded quantification [Cardelli&Wegner] '89: F-bounded quantification [Canning et al.] '91: Subtyping recursive types [Amadio&Cardelli] Lots of cool ideas, but somewhat overwhelming...
  • 17. FOOL Study in '90s Simpler approaches to typed objects '92: Existential encoding [Pierce&Turner92] '93〜 Calculi of primitive objects '96: [Abadi&Cardelli][Fisher,Honsel&Mitchell] A slight departure from Landin reductionism Base calculi are still very primitive
  • 18. Be twe en T he ory an d P ra cti ce
  • 19. aka. declaration-based Theory Practice Subtyping Structural Nominal () Classes First-class () Second-class  Result from (intentional?) confusion between classes and types inheritance and subtyping  A consequence of Ladin reductionism Classes have to be given types
  • 20. Summarizing FOOL Study until Mid '90s Encoding objects and classes into very primitive calculi Successful especially for untyped objects Lots of interesting and substantial type theory Still gaps from mainstream languages
  • 21. Table of Contents A brief review of FOOL study in mid 80s & 90s Featherweight Java (FJ) Applications of FJ A Few Final Words
  • 22. Boom of Java! Triggered two lines of research: “Is Java really safe?” A FOOL-ish question, obviously! “It's a chance to add my cool idea to this new popular language!” Generics, Multi-methods, Virtual Types, Mixins...
  • 23. Research on Type Safety of Java “Java is not Type Safe” [Saraswat97] “Java is Type Safe – Probably” [Drossopoulou&Eisenbach97] “Javalight is Type Safe – Definitely” [Nipkow&von Oheimb98] and many other interesting papers...
  • 24. Research on Type Safety of Java “Java is not type safe” [Saraswat97] Pointing out a class loader bug “Java is Type Safe – Probably” [Drossopoulou&Eisenbach97] Formal model of a significant subset of Java Type safety proofs “Javalight is Type Safe – Definitely” [Nipkow&von Oheimb98] Model and proofs mechanized on Isabelle/HOL
  • 25. Language Extensions Reseach Few papers really discuss foundational issues Some notable exceptions: “Classes and Mixins” [Flatt, Krishnamurthi & Felleisen'98] ClassicJava: A subset of imprerative Java MixedJava: ClassicJava with mixins “Ownership Types for Flexible Alias Protection” [Clarke, Potter & Noble'98]
  • 26. “Featherweight Java: A Minimal Core Calculus for Java and GJ” by I., B.C. Pierce, & P. Wadler [OOPSLA'99, TOPLAS'01] A sublanguage of Java with a formal type system and (operational) semantics Minimal set of features (Second-class) classes with (single) inheritance Recursion through this Dynamic typecast No assignments The choice of features depended upon the main motivation, namely...
  • 27. Main Motivation Study of foundational issues of generics for Java (in particular, GJ [Bracha et al. 98]) Type safety Correctness of “erasure” compilation to JVML Not to prove type safety of as large a subset of Java as possible
  • 28. Main Technical Results Def. of Featherweight Java (FJ) Type safety theorem of FJ Def. of Featherweight GJ (FGJ) An extension of FJ with generics “Direct” operational semantics Type safety of Featherweight GJ Def. of compilation from FGJ to FJ Theorem of compilation correctness
  • 29. FJ: Some Points of Interest Classes are second-class citizens Nominal subtyping Inherited from Reminiscent of “Amber rule” earlier work Dynamic casts Needed to model erasure compilation Minimal set of language features Lack of assignments
  • 30. Classes are Second-Class Classes are not part of expressions to “run” P (programs) ::= (L1 ,...,Ln ,,e) P (programs) ::= (L1 ,...,Ln e) L (classes) ::= ... L (classes) ::= ... e (expr.) ::= xx| |e.m(e1,...,en) | |new e (expr.) ::= e.m(e ,...,e ) new C(e1,...,en) | |... C(e ,...,e ) ... 1 n 1 n Reduction: e  e' (under a fixed set of classes) c.f. Term rewriting systems Classes do not really compose No need for fancy operations on records No type expressions for classes Expression typing: x1:C1,...,xn:Cn┣ e : C Class typing: L ok
  • 31. Nominal Subtyping Subtyping relation C <:D is extracted from extends clauses of the given classes Subtyping is “confirmed” to be safe only after typechecking esp. after checking correct method overriding c.f. Subtyping for recursive types (Amber rule)
  • 32. Declaration-based Subtyping Subtyping relation C <:D is extracted from extends clauses of the given classes Subtyping is “confirmed” <:be safe only <: T(Y) X to Y ┣ S(X) after typechecking ┣ X.S(X) <: Y.T(Y) esp. after checking correct method overriding c.f. Subtyping for recursive types (Amber rule) Obj.{clone: ()→Obj, …} <: Num.{clone: ()→Num, ...}
  • 33. Dynamic Casts Hard to express in typed lambda-calculus Casts bypass typechecking Casts do run-time checking, which compares class names according to extends Required (only) to model erasure compilation Obvious candidates of further simplification
  • 34. Minimal Set of Features This is the whole syntax of FJ! P (programs) ::= (L1,...,Ln, e) L (classes) ::= class C extends C { C f;... C f; K M … M } K (constructors) ::= ... M (methods) ::= C m(C x,...,C x){ return e; } e (expressions) ::= x | this | e.f | e.m(~e) | new C(~e) | (C)e
  • 36. Quantitative Evaluation :-) FJ: 1 page, in 9pt, two columns, 0.0 pounds rd JLS 3 ed.: 650 pages, 2.2 pounds
  • 37. Re: Lack of Assignments We felt formalizing assignments wouldn't give us deeper insights (matching the price to pay) Some reasonable responses we got: “State change is the essence of OO!” “Do you know ML type inference?” In fact, GJ type inference turned out to be flawed later ;-( [Jefferey] One (and, perhaps, only) justification (excuse?): Interesting results even without them
  • 38. Pleasant Surprise! FJ has become a popular tool to study (type systems of) language extensions Especially, class-based language abstractions Some reasons for wide adoption: The name was catchy, perhaps (thanks, Phil!) Initially called “the J-calculus,” IIRC It doesn't have your favorite mechanism You cannot help adding something!
  • 39. Applications of FJ Existing Advanced New Advanced Class Mechanisms Class Mechanisms Self Type Use-site Use-site Self Type Generics Generics Variance Constructors Constructors Variance [OOPSLA'09] [OOPSLA'09] Lightweight Family Gradua Typing Lightweight Family Gradua Typing Polymorphism [OOPSLA'11] [OOPSLA'11] Polymorphism [APLAS'05; JFP'08] Inner Inner [APLAS'05; JFP'08] Classes Classes Variant Path Types Variant Path Types [OOPSLA'07] [OOPSLA'07] Union types Union types [SAC'06; JOT'07] [SAC'06; JOT'07]
  • 40. Applications of FJ Existing Advanced New Advanced Class Mechanisms Class Mechanisms Self Type Use-site Use-site Self Type Generics Generics Variance Constructors Constructors Variance [OOPSLA'09] [OOPSLA'09] Lightweight Family Gradua Typing Lightweight Family Gradua Typing Polymorphism [OOPSLA'11] [OOPSLA'11] Polymorphism [APLAS'05; JFP'08] Inner Inner [APLAS'05; JFP'08] Classes Classes Variant Path Types Variant Path Types [OOPSLA'07] [OOPSLA'07] Union types Union types [SAC'06; JOT'07] [SAC'06; JOT'07]
  • 41. Formal Semantics for Inner Classes I. & B.C. Pierce. “On Inner Classes” [ECOOP'00] Applying FJ to inner classes of Java 1.2 to answer How do inheritance and nesting interact when An inner class can access members of an enclosing class A top-level subclass can extend an inner class nested in an unrelated class ?
  • 42. Interesting Nightmarish Aspect of This Work Inner Classes Specification didn't help figuring out corner cases It was “software physics”: Observe the behavior of software (in this case, javac) without reading the source code Formalize it! Indeed, this work led us to (re)discovering (known) compiler bugs
  • 43. Applications of FJ Existing Advanced New Advanced Class Mechanisms Class Mechanisms Self Type Use-site Use-site Self Type Generics Generics Variance Constructors Constructors Variance [OOPSLA'09] [OOPSLA'09] Lightweight Family Gradua Typing Lightweight Family Gradua Typing Polymorphism [OOPSLA'11] [OOPSLA'11] Polymorphism [APLAS'05; JFP'08] Inner Inner [APLAS'05; JFP'08] Classes Classes Variant Path Types Variant Path Types [OOPSLA'07] [OOPSLA'07] Union types Union types [SAC'06; JOT'07] [SAC'06; JOT'07]
  • 44. Type System for Use-Site Variance I. & M. Viroli. “On Variance-Based Subtyping for Parametric Types” [ECOOP'02] Slogan: “More Subtyping for Generics” Generalization of structural virtual types Formalization on top of Featherweight GJ First type safety proof of a variance system Existential types as a background theory Basis of Java Wildcards
  • 45. Two Subtyping Schemes for Generics Inheritance-based subtyping: Q: When C<T> <: D<T> for given type T? A: class C<X> extends D<X> {...} Variance-based subtyping: Q: When C<S> <: C<T>? Subtyping between two types from the same generic class
  • 46. List<Integer> <: List<Number>? A few different Answers: Unsafe subtyping (Eiffel around '90 [Cook90]): “Yes, as long as your program doesn't add a Number to List<Number>.” “Otherwise, your program may crash :-p ” Java array types inherit this Definition-site variance (POOL-I [America90]) Use-site variance
  • 47. Definition-Site Variance “Yes, provided that List doesn't have public methods to put elements” Type parameter declaration with a variance property Trade-off between methods and subtyping class List<+X> { class List<+X> { class List<-X> { class List<-X> { // List<Int> // List<Int> // List<Num> // List<Num> // // <: List<Num> <: List<Num> // // <: List<Int> <: List<Int> // no meth. to put // no meth. to put // no meth. to get // no meth. to get } } } }
  • 48. When you need RWLists ... RWList<Num> class RWList<X> X head(); RWList<Int> void add(X x); int length();
  • 49. When you need RWLists ... ROList<Num> intf ROList<+X> RWList<Num> X head(); int length(); ROList<Int> class RWList<X> X head(); RWList<Int> void add(X x); int length();
  • 50. When you need RWLists ... intf LenList LenList int length(); WOList<Num> ROList<Num> intf WOList<-X> void add(X x); int length(); intf ROList<+X> RWList<Num> X head(); int length(); WOList<Int> ROList<Int> class RWList<X> X head(); RWList<Int> void add(X x); int length();
  • 51. When you need RWLists ... intf LenList LenList int length(); WOList<Num> ROList<Num> Careful advanced planning would be needed intf WOList<-X> void add(X x); int length(); under nominal subtyping Especially Because supertypes cannot be added later intf ROList<+X> RWList<Num> X head(); (POOL-I is based on structural subtyping) int length(); WOList<Int> ROList<Int> class RWList<X> X head(); RWList<Int> void add(X x); int length();
  • 52. Our Answer: Use-Site Variance List<*> Different interfaces from a single generic class by annotating actual type arguments add() missing in List<-Num> List<+Num> List<+T> and List<*> head() missing in List<-T> List<Num> and List<*> class List<X> List<-Int> List<+Int> X head(); void add(X x); List<Int> int length();
  • 53. Use-site Variance as Existential Types A variable of List<+Num> can store List<Int>, List<Float>, and so on namely, List of some kind of numbers In type theory, such a type is expressed as an existential type ∃X<:Num.List<X> Similarly, List<-Num> = ∃X:>Num.List<X> Typing rules for use-site variance follow from this intuitive correspondence!
  • 54. It's a Natural Idea (to me :-)! Virtual types as an alternative to generics [Thorup 97] Safe virtual types [Torgersen 98] Structural virtual types [Thorup&Torgersen 99] Essentially, use-site variance only with List<T> and List<+T> Modeling virtual types as existentials [I.&Pierce 99]
  • 55. From Use-Site Variance to Wildcards “Adding Wildcards to the Java Programming Language” [Torgersen at al. 04] Cosmetic changes ... List<*> List<?> List<+Number> List<? extends Number> List<-Number> List<? super Number> Emphasizing the existential nature which we tried to hide under the hood :-) ... and some other improvements to make them useful Adaption of library to take adv. of wildcards
  • 56. Some Criticisms on Wildcards “Use-site variance places a great burden on the user of generic types” [Emir et al. 06] In fact, OCaml, Scala and C# later adopt definition-site variance Decidability of subtyping of use-site variance is still open! [Kennedy&Pierce07] And even...
  • 57. “We simply cannot afford another wildcards” – Joshua Bloch
  • 58. “I feel sorry for students when I have to teach what I cannot understand” – Anonymous (Japanese Prof.)
  • 59. What's Unusual about Use-Site Variance Subtyping with more of structural flavor Types Type comparison Java 1.x Atomic Atomic GJ Structural Mostly atomic Wildcards Structural Structural Separation of static and run-time types There is no instance of List<+Num> “Post hoc” supertypes
  • 60. Was It Really a Bad Idea? I'm not qualified to judge :-) Maybe only history will tell us Still, post-hoc supertypes are often very useful C<S> and C<T> always have a common supertype C<? extends U> (for S, T <: U) Otherwise, it might even be Object Further research is needed, anyway “Taming the Wildcards” [Altidor, Huang, Smaragdakis11]
  • 61. Table of Contents A brief review of FOOL study in mid 80s & 90s Featherweight Java (FJ) Applications of FJ Formalizing Advanced Class Mechanisms Designing Advanced Class Mechanisms Final Words
  • 63. You can throw away most as long as something interesting is left
  • 64. should You can throw away most as long as something interesting is left to distill Serious thought needed, though!
  • 65. Type systems should help people
  • 66. Type systems should help people write programs in good styles
  • 67. Igarashi's Conjecture If a new, cool programming style emerges, there will be a type system to enforce it.
  • 68. Working for building FOOL might not look very attractive at first...
  • 69. … but, the Fun of Your OO Life is Dependent on FOOL!
  • 70. … but, the Fun of Your OO Life is Dependent on FOOL! Really!
  • 71. To my collaborators: João Filipe Belo Shigeru Chiba Michael Greenberg Robert Hirschfeld Lintaro Ina Masashi Iwaki Futoshi Iwama Yukiyoshi Kameyama Naoki Kobayashi Kensuke Kojima Hidehiko Masuhara Hideshi Nagira Benjamin C. Pierce Chieri Saito Takafumi Sakurai Masahiko Sato Naokata Shikuma Manabu Toyama Takeshi Tsukada Mirko Viroli Philip Wadler Yosihiro Yuse Salikh Zakirov … my family and ALL users of FJ!