SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
The Pizza Compiler




                               The Pizza Compiler
                        extending Java in a functional way


                                          Sander Mak

                     Centre for Software Technology, Universiteit Utrecht


                                     October 19, 2006




                         Center for Software Technology                     Sander Mak
The Pizza Compiler > Introduction


 Outline


        Introduction
    1



        Features
    2



        Rough edges
    3



        Related work
    4



        Conclusion
    5




                                Center for Software Technology   Sander Mak
The Pizza Compiler > Introduction


 About the Pizza project



           Main Pizza contributors: Martin Odersky and Philip Wadler
           Project started 1996 (Java 1.1 era)
           Last version: 2002
    So, why study an abandoned research project?
           The ideas are still very interesting (they don’t age as fast as our
       1

           computers...)!
           Better insight into design of Java 1.5
       2


           See how FP and OO can integrate
       3




                                Center for Software Technology              Sander Mak
The Pizza Compiler > Introduction


 Characteristics
                                               Pizza language
                                                   Language adds three novel features:
                                                                 Parametric Polymorphism (generics)
                                                           1

                                                                 First class functions
                                                           2

                                                                 Algebraic datatypes
                                                           3


                                                       Pizza is a strict superset of Java
                                                       Language defined by translation into
                                                       Java
                                               Pizza compiler
                                                       Compiler outputs bytecode directly
                                                       But, can output Java sources
                                                       (pre-processor)
                                                       No dependency chasing
                                                       Of course: written in Pizza!
                                Center for Software Technology                                 Sander Mak
The Pizza Compiler > Introduction




                                    Let’s move on to the features...




                                    Ask questions if code is unclear




                                Center for Software Technology         Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Introducing Parameterized Types

          Collections API (List, Hashtable, etc.) relies on generic
          programming
          Up to Java 1.4 simulated by implementing them with the top of
          the type-hierarchy: Object

   class Hashtable { .. public Object get(Object key) { .. } }

          This leads to runtime type errors: programmer is responsible for
          types in a collection consistent
          Parameterized types solve this problem

   class Hashtable<K,V> { .. public V get(K key) { .. } }

          No runtime checks necessary anymore

                               Center for Software Technology           Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Introducing Parameterized Types

   Type parameters can have bounds:

   class Tree<A implements TreeNode> { .. }
   class Maximum<A implements Comparable<A>> { .. }

   Very similar to Haskell type-classes!
          Primitive types (int, char) are allowed as instantiation for
          type parameters
          Omitting a bound implies the bound Object

   Instantiating parameterized types:

   List<int> = new List<int>();
   Tree<TreeNodeImpl> = new Tree<TreeNodeImpl>();


                               Center for Software Technology            Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Two translation schemes


   Homogeneous (Type Erasure)
          Creates one Java implementation for each parameterized class
          Replace type variables by their respective bounds
          Parameterized array types are replaced with pizza.support.array
          type

   Heterogeneous
       Creates specialised instances for each instantiation of type
       parameter
          Even at runtime specialisations can be generated, using reflection



                               Center for Software Technology            Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Translation scheme - Homogeneous (Type erasure)

   Pizza source
   class TranslateMe<A, B extends String> {
      public A test(A a, B[] bs){
        B b = bs[0];
        return a; }
   }


   Translated Java source
   class TranslateMe {
      public Object test(Object s, pizza.support.array bs) {
        String b = (String)bs.at(0);
        return a;
      }
   }

       Problem: how can primitive types be used as an object?
                               Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Invariant/covariant subtyping

   Is List<String> a subtype of List<Object>?




                               Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Invariant/covariant subtyping

   Is List<String> a subtype of List<Object>?
   Consider:
   class Loophole {
     public static String loophole (Byte y) {
       LinkedList<String> xs = new LinkedList<String>();
       LinkedList<Object> ys = xs; // aliasing
       ys.add(y);
       return xs.iterator().next();
     }
   }




                               Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Invariant/covariant subtyping

   Is List<String> a subtype of List<Object>?
   Consider:
   class Loophole {
     public static String loophole (Byte y) {
       LinkedList<String> xs = new LinkedList<String>();
       LinkedList<Object> ys = xs; // aliasing
       ys.add(y);
       return xs.iterator().next();
     }
   }

   The aliasing of xs and ys will result in a compile time error, to
   guarantee soundness.
   Therefore, these types are not involved in a subtyping relation:
   parameterized types have invariant subtyping.

                               Center for Software Technology          Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Invariant/covariant subtyping

   But.. String[] is a subtype of Object[] (covariant)!
   Consider:
   class Loophole {
     public static String loophole (Byte y) {
       String[] xs = new String[1];
       Object[] ys = xs; // aliasing
       ys[0] = y;
       return xs[0];
     }
   }




                               Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Parametric Polymorphism


 Invariant/covariant subtyping

   But.. String[] is a subtype of Object[] (covariant)!
   Consider:
   class Loophole {
     public static String loophole (Byte y) {
       String[] xs = new String[1];
       Object[] ys = xs; // aliasing
       ys[0] = y;
       return xs[0];
     }
   }

   The assignment ys[0] = x will give a runtime error.
   This is possible because JVM tracks runtime types of arrays!


                               Center for Software Technology     Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Datatypes in Haskell

   data List a = Nil | Cons a (List a)

   We could emulate this using a parameterized class List<A>, but...

     sum Nil                              =0
     sum (Cons e es)                      = e + sum es

   Elegant pattern matching is still not possible.




                                Center for Software Technology         Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Datatypes in Haskell

   data List a = Nil | Cons a (List a)

   We could emulate this using a parameterized class List<A>, but...

     sum Nil                              =0
     sum (Cons e es)                      = e + sum es

   Elegant pattern matching is still not possible.
   Observation
    1 Objects and inheritance ease adding new constructors to types,

       given that #functions is relatively fixed
           Algebraic datatypes ease adding new functions over types using
       2

           matching, give that constructors are relatively fixed
   Can we combine this?
                                Center for Software Technology          Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Sum using ADT and pattern matching

   class List<A> {
     case Nil;
     case Cons(A head, List<A> tail);
   }




                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Sum using ADT and pattern matching

   class List<A> {
     case Nil;
     case Cons(A head, List<A> tail);
   }

   We can now define sum:

   public static int sum(List<int> l){
     switch (l) {
       case Nil :
         return 0;
       case Cons (int e, List<int> es) :
         return (e + sum(es));
   }



                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Sum using ADT and pattern matching

   class List<A> {
     case Nil;
     case Cons(A head, List<A> tail);
   }

   We can now define sum:

   public static int sum(List<int> l){
     switch (l) {
       case Nil :
         return 0;
       case Cons (int e, List<int> es) :
         return (e + sum(es));
   }

                  Unfortunately the compiler didn’t agree...
                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Sum using ADT and pattern matching
   Compiler error
   An exception has occurred in the compiler. (v1.0g)
   Please file a bug report at Sourceforge.net
      Thank you.
   Exception in thread quot;mainquot; java.lang.StackOverflowError




                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Sum using ADT and pattern matching
   Compiler error
   An exception has occurred in the compiler. (v1.0g)
   Please file a bug report at Sourceforge.net
      Thank you.
   Exception in thread quot;mainquot; java.lang.StackOverflowError

   After some experimentation:
   Fix
   public static Integer sum(List<Integer> l){
     switch (l) {
       case Nil :
         return new Integer(0);
       case Cons (Integer e, List<Integer> es):
         return new Integer(e.intValue() + sum(es).intValue());

   }

                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Pattern matching
           Wildcard pattern is allowed for unused variables
           Nested pattern matching is supported
           Overlapping patterns are detected, and not allowed
           Pizza compiler AST is an Algebraic datatype
           Enumeration types are within reach (as in Java 1.5):

   class Color {
       case Red;
       case Blue;

           String toString() {
               switch (this) {
               case Red: return “Red”;
               case Blue: return “Blue”;
               }
           }
   }

                                Center for Software Technology    Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Translation to Java

   class List {
      static final List Nil = new List(1);
      public final int Listtag;
      static List Cons(Object head, List tail) {
         return (List)new Cons(head, tail);
      }
      List(int Listtag) {
         super(); this.Listtag = Listtag;
      }
      static class Cons extends List {
         Object head; List tail;
         Cons(Object head, List tail) {
            super(2); this.head = head;
            this.tail = tail;
         }
      }
   }

                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > Algebraic Datatypes


 Translation to Java

   class List {
      static final List Nil = new List(1);
      public final int Listtag;
      static List Cons(Object head, List tail) {
         return (List)new Cons(head, tail);
      }
      List(int Listtag) {
         super(); this.Listtag = Listtag;
      }
      static class Cons extends List {
         Object head; List tail;
         Cons(Object head, List tail) {
            super(2); this.head = head;
            this.tail = tail;
     Constructing an instance of List<int> in Pizza
         }
      } List<int> nums = List.Cons(1,List.Cons(2,List.Nil));
   }

                                Center for Software Technology   Sander Mak
The Pizza Compiler > Features > First-class functions


 Why pass functions?
    Let’s examine a sorted set implementation
    Current practice

    class Set implements SortedSet {
      public Set(Comparator c){..}
      .. }
    interface Comparator {
      int compare(Object o1, Object o2); }

    Extra class definition and implementation necessary to provide ordering
    functionality...




                                 Center for Software Technology       Sander Mak
The Pizza Compiler > Features > First-class functions


 Why pass functions?
    Let’s examine a sorted set implementation
    Current practice

    class Set implements SortedSet {
      public Set(Comparator c){..}
      .. }
    interface Comparator {
      int compare(Object o1, Object o2); }

    Extra class definition and implementation necessary to provide ordering
    functionality...
    What if...
    class TreeSet {
      public TreeSet((Object,Object) -> int compare)
        { .. order = compare(o1,o2); .. } .. }

                                 Center for Software Technology       Sander Mak
The Pizza Compiler > Features > First-class functions


 Syntax
    Pizza adds function types and values to Java
    Function declaration (member or local)

    (Object,Object) -> int compare =
      fun (Object o1,Object o2) -> int {.. implementation ..};

    Implementation may reference o1, o2, and everything in enclosing class
    (not itself!)
    Function declaration top-level

    public int compare(Object o1, Object o2) {.. implementation ..};


    Top-level functions can be passed around by using their name without
    parentheses.
        Comparator example is solvable using anonymous class instances.
        But how powerful/scalable is this approach?
                                 Center for Software Technology       Sander Mak
The Pizza Compiler > Features > First-class functions


 Let’s make a Pizza foldr!

    public class Foldr {
      static <D,E> D foldr((E,D) -> D f, D unit, List<E> l){
        switch(l){
           case Nil: return unit;
           case Cons(E h, List<E> t): return f(h,foldr(f,unit,t));

           }
       }

    Type of foldr in Haskell
    foldr :: (a → b → b) → b → [a] → b




                                 Center for Software Technology   Sander Mak
The Pizza Compiler > Features > First-class functions


 Let’s make a Pizza foldr!

    public class Foldr {
      static <D,E> D foldr((E,D) -> D f, D unit, List<E> l){
        switch(l){
           case Nil: return unit;
           case Cons(E h, List<E> t): return f(h,foldr(f,unit,t));

            }
        }


        static Integer add(Integer i1, Integer i2){
          return new Integer(i1.intValue() + i2.intValue());
        }

        public static void main(String[] args){
          (List<Integer>) -> int sum =
             fun (List<Integer> l) -> int
              {(foldr(add,new Integer(0),l))};
        }
                                 Center for Software Technology   Sander Mak
    }
The Pizza Compiler > Features > First-class functions

    Does this first-class function feature transform Pizza/Java into
    Haskell?
    spacer
    Well... not really:
         No currying
         No referential transparency
         No lazy evaluation




                                 Center for Software Technology       Sander Mak
The Pizza Compiler > Features > First-class functions


 Translation to Java

                                                                      A class with First class
                                                                      functions results in 2
                                                                      translated classes
                                                                      Most important task: ensure
                                                                      scoped variables are available
                                                              spacer
                                                              spacer
         Translated Functions class
                                                              spacer
         contains a method for every
                                                              There are 3 cases to consider:
         first-class function body
                                                                      Local definition of a function
         FunctionsClosures extends                                1

         pizza.support.Closure and has                                Passing of functions
                                                                  2

         an apply method for each                                     Application of a function
                                                                  3
         signature

                                 Center for Software Technology                                   Sander Mak
The Pizza Compiler > Features > First-class functions


 Translation to Java



    Functions.pizza

    1 class Functions {
    2   public Functions(int a){
          (int) -> int incr = fun (int i)->int {return i+a;};
    3
    4     int result = this.f(incr);
        }
    5
    6   public int f((int) -> int incr){
    7     return incr(2);
        }
    8
    9}




                                 Center for Software Technology   Sander Mak
The Pizza Compiler > Features > First-class functions


 Translation to Java

    Functions.pizza

    1 class Functions {
    2   public Functions(int a){
          (int) -> int incr = fun (int i)->int {return i+a;};
    3
    4     int result = this.f(incr);
        }
    5
    6   public int f((int) -> int incr){
    7     return incr(2);
        }
    8
    9}


    Case 1: Local definition (line 3)

         pizza.support.Closure incr = new FunctionsClosures(this,
           0, new Object[]{new Integer(a)});


                                 Center for Software Technology   Sander Mak
The Pizza Compiler > Features > First-class functions


 Translation to Java
    Functions.pizza

    1 class Functions {
    2   public Functions(int a){
          (int) -> int incr = fun (int i)->int {return i+a;};
    3
    4     int result = this.f(incr);
        }
    5
    6   public int f((int) -> int incr){
    7     return incr(2);
        }
    8
    9}

    Case 1: Local definition (line 3)

             int closureFunctions0(int i, Object[] freevars) {
                int a = ((Number)freevars[0]).intValue();
                return i+a;
             }

                                 Center for Software Technology   Sander Mak
The Pizza Compiler > Features > First-class functions


 Translation to Java

    Functions.pizza

    1 class Functions {
    2   public Functions(int a){
          (int) -> int incr = fun (int i)->int {return i+a;};
    3
    4     int result = this.f(incr);
        }
    5
    6   public int f((int) -> int incr){
    7     return incr(2);
        }
    8
    9}


    Case 2: Passing functions (line 4)

           int result = this.f(incr);


                                 Center for Software Technology   Sander Mak
The Pizza Compiler > Features > First-class functions


 Translation to Java
    Functions.pizza

    1 class Functions {
    2   public Functions(int a){
          (int) -> int incr = fun (int i)->int {return i+a;};
    3
    4     int result = this.f(incr);
        }
    5
    6   public int f((int) -> int incr){
    7     return incr(2);
        }
    8
    9}

    Case 3: Applying functions (line 7)

           public int f(pizza.support.Closure incr) {
              return ((Number)incr.apply(new Integer(2))).intValue();

           }

                                 Center for Software Technology   Sander Mak
The Pizza Compiler > Rough edges


 Language mismatches and other problems


          There is a fixed maximum on the #arguments for first-class
          functions (definition of Closure)
          Access modifiers are not fine-grained enough for accurate
          translation
          Lots of typecasts are inserted to pass bytecode verification. Most
          are not necessary because of Pizza’s typesystem
          Generic array creation and generic instantiation are not possible
          due to type erasure
          ’Strict superset’-claim is false: cannot use (new) keyword fun as
          identifier



                               Center for Software Technology             Sander Mak
The Pizza Compiler > Related work


 Other approaches
   GJ: Generic Java spin-off from Pizza
                    Only the parameterized types from Pizza
                    Some differences: only reference type parameters,
                    compatibility with non-generic classes, generic array
                    creation
                    Ended up in Java 1.5!
         Scala language by Martin Odersky
                    Departs from notion of translation into the Java
                    language
                    Result: more freedom to implement new features
                    Runs on JVM
   C++ Templates superficially similar to parameterized types
                    More like macros: each instantiation results in a new
                    class
                    Templates are not type-checked (only their
                    instances)
                                Center for Software Technology       Sander Mak
The Pizza Compiler > Conclusion > Opinion


 Quality of error messages


   A measure of compiler quality can be the quality of its errors:
          Failure of bound-inference for generic types leads to good,
          understandable feedback
          Omitting a case in a switch leads to a vague error message about
          a missing return statement
          There is an (undocumented) fixed maximum on the number of
          arguments for a first class function. Violating this gives a long,
          vague error message
   I would say that Pizza is usable, but not in production environments.




                               Center for Software Technology             Sander Mak
The Pizza Compiler > Conclusion > Opinion


 Quality in general




          Papers on Pizza are very well written
          A very thorough description of the Pizza typesystem shows that
          the project is not mere hacking of cool features
          Implementation is not robust, not unusable either
   I would say that Pizza is a very good example of a research project
   that had significant impact (through Generic Java → Java 1.5)




                               Center for Software Technology            Sander Mak
The Pizza Compiler > Conclusion > The End




   I hope this overview encourages you to find new ways to enhance
   existing ideas! spacer
   spacer
   Odersky and Wadler:
   ’We are not short on innovations, but we need more ways to translate
   innovation in to practice’

   spacer

                   Try it yourself @ pizzacompiler.sourceforge.net




                              Center for Software Technology         Sander Mak

Más contenido relacionado

La actualidad más candente

Java 8 - A step closer to Parallelism
Java 8 - A step closer to ParallelismJava 8 - A step closer to Parallelism
Java 8 - A step closer to Parallelismjbugkorea
 
ParaSail
ParaSail  ParaSail
ParaSail AdaCore
 
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...Coen De Roover
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationCoen De Roover
 
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!melbats
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascriptMD Sayem Ahmed
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzJAX London
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 
A (too) Short Introduction to Scala
A (too) Short Introduction to ScalaA (too) Short Introduction to Scala
A (too) Short Introduction to ScalaRiccardo Cardin
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
More Little Wonders of C#/.NET
More Little Wonders of C#/.NETMore Little Wonders of C#/.NET
More Little Wonders of C#/.NETBlackRabbitCoder
 
Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Javahendersk
 
Java modular extension for operator overloading
Java modular extension for operator overloadingJava modular extension for operator overloading
Java modular extension for operator overloadingijpla
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Duckademy IT courses
 

La actualidad más candente (20)

Java 8 - A step closer to Parallelism
Java 8 - A step closer to ParallelismJava 8 - A step closer to Parallelism
Java 8 - A step closer to Parallelism
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
ParaSail
ParaSail  ParaSail
ParaSail
 
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
A Logic Meta-Programming Foundation for Example-Driven Pattern Detection in O...
 
Of Lambdas and LINQ
Of Lambdas and LINQOf Lambdas and LINQ
Of Lambdas and LINQ
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X Transformation
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
EclipseCon France 2016 - Sirius 4.0: Let me Sirius that for you!
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
A (too) Short Introduction to Scala
A (too) Short Introduction to ScalaA (too) Short Introduction to Scala
A (too) Short Introduction to Scala
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
More Little Wonders of C#/.NET
More Little Wonders of C#/.NETMore Little Wonders of C#/.NET
More Little Wonders of C#/.NET
 
Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Java
 
Java modular extension for operator overloading
Java modular extension for operator overloadingJava modular extension for operator overloading
Java modular extension for operator overloading
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 

Destacado

Generics of JAVA
Generics of JAVAGenerics of JAVA
Generics of JAVAJai Marathe
 
On Parameterised Types and Java Generics
On Parameterised Types and Java GenericsOn Parameterised Types and Java Generics
On Parameterised Types and Java GenericsYann-Gaël Guéhéneuc
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeScott Wlaschin
 
Integrating Social Media With Traditional Media
Integrating Social Media With Traditional MediaIntegrating Social Media With Traditional Media
Integrating Social Media With Traditional Mediaparkernow
 
Climate Coaching - 15 september 2011
Climate Coaching - 15 september 2011Climate Coaching - 15 september 2011
Climate Coaching - 15 september 2011Klimatkommunerna
 
以共融的觀點探討銀髮族節能生活型態之概念設計計畫
以共融的觀點探討銀髮族節能生活型態之概念設計計畫以共融的觀點探討銀髮族節能生活型態之概念設計計畫
以共融的觀點探討銀髮族節能生活型態之概念設計計畫開放式概念發表平臺
 
Green Venue Zone
Green Venue ZoneGreen Venue Zone
Green Venue ZoneCarol Moxam
 
Luke Hohmann on "How Innovation Happens"
Luke Hohmann on "How Innovation Happens"Luke Hohmann on "How Innovation Happens"
Luke Hohmann on "How Innovation Happens"Enthiosys Inc
 
Crescent/Stonco LED Brochure
Crescent/Stonco LED BrochureCrescent/Stonco LED Brochure
Crescent/Stonco LED BrochureColleen2782
 
CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010Joel Gascoigne
 
Trust Evaluation through User Reputation and Provenance Analysis
Trust Evaluation through User Reputation and Provenance AnalysisTrust Evaluation through User Reputation and Provenance Analysis
Trust Evaluation through User Reputation and Provenance AnalysisDavide Ceolin
 
Element Design Final Presentation3
Element Design Final Presentation3Element Design Final Presentation3
Element Design Final Presentation3guestdf2bf9
 
Community Investment Zone - Development Team Presentation
Community Investment Zone - Development Team PresentationCommunity Investment Zone - Development Team Presentation
Community Investment Zone - Development Team Presentationbiferguson
 
Progetto 5 comuni del Pasubio - scuola Vallarsa
Progetto 5  comuni del Pasubio - scuola VallarsaProgetto 5  comuni del Pasubio - scuola Vallarsa
Progetto 5 comuni del Pasubio - scuola Vallarsaguestf9daa3a
 
05 building a_necto_social_network_ready
05 building a_necto_social_network_ready05 building a_necto_social_network_ready
05 building a_necto_social_network_readywww.panorama.com
 
Altitude #Users meeting in Spain ASES2015
Altitude #Users meeting in Spain ASES2015Altitude #Users meeting in Spain ASES2015
Altitude #Users meeting in Spain ASES2015Raquel1704
 

Destacado (20)

Generics of JAVA
Generics of JAVAGenerics of JAVA
Generics of JAVA
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
 
Use the @types, Luke
Use the @types, LukeUse the @types, Luke
Use the @types, Luke
 
On Parameterised Types and Java Generics
On Parameterised Types and Java GenericsOn Parameterised Types and Java Generics
On Parameterised Types and Java Generics
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-Toe
 
Integrating Social Media With Traditional Media
Integrating Social Media With Traditional MediaIntegrating Social Media With Traditional Media
Integrating Social Media With Traditional Media
 
Climate Coaching - 15 september 2011
Climate Coaching - 15 september 2011Climate Coaching - 15 september 2011
Climate Coaching - 15 september 2011
 
以共融的觀點探討銀髮族節能生活型態之概念設計計畫
以共融的觀點探討銀髮族節能生活型態之概念設計計畫以共融的觀點探討銀髮族節能生活型態之概念設計計畫
以共融的觀點探討銀髮族節能生活型態之概念設計計畫
 
Green Venue Zone
Green Venue ZoneGreen Venue Zone
Green Venue Zone
 
Luke Hohmann on "How Innovation Happens"
Luke Hohmann on "How Innovation Happens"Luke Hohmann on "How Innovation Happens"
Luke Hohmann on "How Innovation Happens"
 
Crescent/Stonco LED Brochure
Crescent/Stonco LED BrochureCrescent/Stonco LED Brochure
Crescent/Stonco LED Brochure
 
CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010CodeIgniter for Startups, cicon2010
CodeIgniter for Startups, cicon2010
 
Trust Evaluation through User Reputation and Provenance Analysis
Trust Evaluation through User Reputation and Provenance AnalysisTrust Evaluation through User Reputation and Provenance Analysis
Trust Evaluation through User Reputation and Provenance Analysis
 
TECTONIC DESIGN
TECTONIC DESIGNTECTONIC DESIGN
TECTONIC DESIGN
 
Element Design Final Presentation3
Element Design Final Presentation3Element Design Final Presentation3
Element Design Final Presentation3
 
Community Investment Zone - Development Team Presentation
Community Investment Zone - Development Team PresentationCommunity Investment Zone - Development Team Presentation
Community Investment Zone - Development Team Presentation
 
Progetto 5 comuni del Pasubio - scuola Vallarsa
Progetto 5  comuni del Pasubio - scuola VallarsaProgetto 5  comuni del Pasubio - scuola Vallarsa
Progetto 5 comuni del Pasubio - scuola Vallarsa
 
Unenclosable
UnenclosableUnenclosable
Unenclosable
 
05 building a_necto_social_network_ready
05 building a_necto_social_network_ready05 building a_necto_social_network_ready
05 building a_necto_social_network_ready
 
Altitude #Users meeting in Spain ASES2015
Altitude #Users meeting in Spain ASES2015Altitude #Users meeting in Spain ASES2015
Altitude #Users meeting in Spain ASES2015
 

Similar a Pizza compiler

How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...Codemotion
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
Functional programming-advantages
Functional programming-advantagesFunctional programming-advantages
Functional programming-advantagesSergei Winitzki
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?Federico Tomassetti
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhHarmeet Singh(Taara)
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
Generic Programming seminar
Generic Programming seminarGeneric Programming seminar
Generic Programming seminarGautam Roy
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guideAdy Liu
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for DesignersR. Sosa
 
Scripting in InduSoft Web Studio
Scripting in InduSoft Web StudioScripting in InduSoft Web Studio
Scripting in InduSoft Web StudioAVEVA
 
Lambda/Streams Hands-On Lab
Lambda/Streams Hands-On LabLambda/Streams Hands-On Lab
Lambda/Streams Hands-On LabMaurice Naftalin
 
Designing Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio ProjectsDesigning Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio ProjectsAVEVA
 
Whoops! where did my architecture go?
Whoops! where did my architecture go?Whoops! where did my architecture go?
Whoops! where did my architecture go?Oliver Gierke
 

Similar a Pizza compiler (20)

How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
Functional programming-advantages
Functional programming-advantagesFunctional programming-advantages
Functional programming-advantages
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Intro dotnet
Intro dotnetIntro dotnet
Intro dotnet
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
dev_int_96
dev_int_96dev_int_96
dev_int_96
 
Generic Programming seminar
Generic Programming seminarGeneric Programming seminar
Generic Programming seminar
 
A First Date With Scala
A First Date With ScalaA First Date With Scala
A First Date With Scala
 
Ice mini guide
Ice mini guideIce mini guide
Ice mini guide
 
Java Programming for Designers
Java Programming for DesignersJava Programming for Designers
Java Programming for Designers
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
Scripting in InduSoft Web Studio
Scripting in InduSoft Web StudioScripting in InduSoft Web Studio
Scripting in InduSoft Web Studio
 
Lambda/Streams Hands-On Lab
Lambda/Streams Hands-On LabLambda/Streams Hands-On Lab
Lambda/Streams Hands-On Lab
 
Designing Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio ProjectsDesigning Optimized Symbols for InduSoft Web Studio Projects
Designing Optimized Symbols for InduSoft Web Studio Projects
 
Whoops! where did my architecture go?
Whoops! where did my architecture go?Whoops! where did my architecture go?
Whoops! where did my architecture go?
 

Más de Sander Mak (@Sander_Mak)

TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painSander Mak (@Sander_Mak)
 
The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)Sander Mak (@Sander_Mak)
 
Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Sander Mak (@Sander_Mak)
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Sander Mak (@Sander_Mak)
 

Más de Sander Mak (@Sander_Mak) (20)

Scalable Application Development @ Picnic
Scalable Application Development @ PicnicScalable Application Development @ Picnic
Scalable Application Development @ Picnic
 
Coding Your Way to Java 13
Coding Your Way to Java 13Coding Your Way to Java 13
Coding Your Way to Java 13
 
Coding Your Way to Java 12
Coding Your Way to Java 12Coding Your Way to Java 12
Coding Your Way to Java 12
 
Java Modularity: the Year After
Java Modularity: the Year AfterJava Modularity: the Year After
Java Modularity: the Year After
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
 
Modules or microservices?
Modules or microservices?Modules or microservices?
Modules or microservices?
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Java 9 Modularity in Action
Java 9 Modularity in ActionJava 9 Modularity in Action
Java 9 Modularity in Action
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Provisioning the IoT
Provisioning the IoTProvisioning the IoT
Provisioning the IoT
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)The Ultimate Dependency Manager Shootout (QCon NY 2014)
The Ultimate Dependency Manager Shootout (QCon NY 2014)
 
Modular JavaScript
Modular JavaScriptModular JavaScript
Modular JavaScript
 
Modularity in the Cloud
Modularity in the CloudModularity in the Cloud
Modularity in the Cloud
 
Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?Cross-Build Injection attacks: how safe is your Java build?
Cross-Build Injection attacks: how safe is your Java build?
 
Scala & Lift (JEEConf 2012)
Scala & Lift (JEEConf 2012)Scala & Lift (JEEConf 2012)
Scala & Lift (JEEConf 2012)
 
Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)Hibernate Performance Tuning (JEEConf 2012)
Hibernate Performance Tuning (JEEConf 2012)
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)
Akka (BeJUG)
 
Fork Join (BeJUG 2012)
Fork Join (BeJUG 2012)Fork Join (BeJUG 2012)
Fork Join (BeJUG 2012)
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 

Pizza compiler

  • 1. The Pizza Compiler The Pizza Compiler extending Java in a functional way Sander Mak Centre for Software Technology, Universiteit Utrecht October 19, 2006 Center for Software Technology Sander Mak
  • 2. The Pizza Compiler > Introduction Outline Introduction 1 Features 2 Rough edges 3 Related work 4 Conclusion 5 Center for Software Technology Sander Mak
  • 3. The Pizza Compiler > Introduction About the Pizza project Main Pizza contributors: Martin Odersky and Philip Wadler Project started 1996 (Java 1.1 era) Last version: 2002 So, why study an abandoned research project? The ideas are still very interesting (they don’t age as fast as our 1 computers...)! Better insight into design of Java 1.5 2 See how FP and OO can integrate 3 Center for Software Technology Sander Mak
  • 4. The Pizza Compiler > Introduction Characteristics Pizza language Language adds three novel features: Parametric Polymorphism (generics) 1 First class functions 2 Algebraic datatypes 3 Pizza is a strict superset of Java Language defined by translation into Java Pizza compiler Compiler outputs bytecode directly But, can output Java sources (pre-processor) No dependency chasing Of course: written in Pizza! Center for Software Technology Sander Mak
  • 5. The Pizza Compiler > Introduction Let’s move on to the features... Ask questions if code is unclear Center for Software Technology Sander Mak
  • 6. The Pizza Compiler > Features > Parametric Polymorphism Introducing Parameterized Types Collections API (List, Hashtable, etc.) relies on generic programming Up to Java 1.4 simulated by implementing them with the top of the type-hierarchy: Object class Hashtable { .. public Object get(Object key) { .. } } This leads to runtime type errors: programmer is responsible for types in a collection consistent Parameterized types solve this problem class Hashtable<K,V> { .. public V get(K key) { .. } } No runtime checks necessary anymore Center for Software Technology Sander Mak
  • 7. The Pizza Compiler > Features > Parametric Polymorphism Introducing Parameterized Types Type parameters can have bounds: class Tree<A implements TreeNode> { .. } class Maximum<A implements Comparable<A>> { .. } Very similar to Haskell type-classes! Primitive types (int, char) are allowed as instantiation for type parameters Omitting a bound implies the bound Object Instantiating parameterized types: List<int> = new List<int>(); Tree<TreeNodeImpl> = new Tree<TreeNodeImpl>(); Center for Software Technology Sander Mak
  • 8. The Pizza Compiler > Features > Parametric Polymorphism Two translation schemes Homogeneous (Type Erasure) Creates one Java implementation for each parameterized class Replace type variables by their respective bounds Parameterized array types are replaced with pizza.support.array type Heterogeneous Creates specialised instances for each instantiation of type parameter Even at runtime specialisations can be generated, using reflection Center for Software Technology Sander Mak
  • 9. The Pizza Compiler > Features > Parametric Polymorphism Translation scheme - Homogeneous (Type erasure) Pizza source class TranslateMe<A, B extends String> { public A test(A a, B[] bs){ B b = bs[0]; return a; } } Translated Java source class TranslateMe { public Object test(Object s, pizza.support.array bs) { String b = (String)bs.at(0); return a; } } Problem: how can primitive types be used as an object? Center for Software Technology Sander Mak
  • 10. The Pizza Compiler > Features > Parametric Polymorphism Invariant/covariant subtyping Is List<String> a subtype of List<Object>? Center for Software Technology Sander Mak
  • 11. The Pizza Compiler > Features > Parametric Polymorphism Invariant/covariant subtyping Is List<String> a subtype of List<Object>? Consider: class Loophole { public static String loophole (Byte y) { LinkedList<String> xs = new LinkedList<String>(); LinkedList<Object> ys = xs; // aliasing ys.add(y); return xs.iterator().next(); } } Center for Software Technology Sander Mak
  • 12. The Pizza Compiler > Features > Parametric Polymorphism Invariant/covariant subtyping Is List<String> a subtype of List<Object>? Consider: class Loophole { public static String loophole (Byte y) { LinkedList<String> xs = new LinkedList<String>(); LinkedList<Object> ys = xs; // aliasing ys.add(y); return xs.iterator().next(); } } The aliasing of xs and ys will result in a compile time error, to guarantee soundness. Therefore, these types are not involved in a subtyping relation: parameterized types have invariant subtyping. Center for Software Technology Sander Mak
  • 13. The Pizza Compiler > Features > Parametric Polymorphism Invariant/covariant subtyping But.. String[] is a subtype of Object[] (covariant)! Consider: class Loophole { public static String loophole (Byte y) { String[] xs = new String[1]; Object[] ys = xs; // aliasing ys[0] = y; return xs[0]; } } Center for Software Technology Sander Mak
  • 14. The Pizza Compiler > Features > Parametric Polymorphism Invariant/covariant subtyping But.. String[] is a subtype of Object[] (covariant)! Consider: class Loophole { public static String loophole (Byte y) { String[] xs = new String[1]; Object[] ys = xs; // aliasing ys[0] = y; return xs[0]; } } The assignment ys[0] = x will give a runtime error. This is possible because JVM tracks runtime types of arrays! Center for Software Technology Sander Mak
  • 15. The Pizza Compiler > Features > Algebraic Datatypes Datatypes in Haskell data List a = Nil | Cons a (List a) We could emulate this using a parameterized class List<A>, but... sum Nil =0 sum (Cons e es) = e + sum es Elegant pattern matching is still not possible. Center for Software Technology Sander Mak
  • 16. The Pizza Compiler > Features > Algebraic Datatypes Datatypes in Haskell data List a = Nil | Cons a (List a) We could emulate this using a parameterized class List<A>, but... sum Nil =0 sum (Cons e es) = e + sum es Elegant pattern matching is still not possible. Observation 1 Objects and inheritance ease adding new constructors to types, given that #functions is relatively fixed Algebraic datatypes ease adding new functions over types using 2 matching, give that constructors are relatively fixed Can we combine this? Center for Software Technology Sander Mak
  • 17. The Pizza Compiler > Features > Algebraic Datatypes Sum using ADT and pattern matching class List<A> { case Nil; case Cons(A head, List<A> tail); } Center for Software Technology Sander Mak
  • 18. The Pizza Compiler > Features > Algebraic Datatypes Sum using ADT and pattern matching class List<A> { case Nil; case Cons(A head, List<A> tail); } We can now define sum: public static int sum(List<int> l){ switch (l) { case Nil : return 0; case Cons (int e, List<int> es) : return (e + sum(es)); } Center for Software Technology Sander Mak
  • 19. The Pizza Compiler > Features > Algebraic Datatypes Sum using ADT and pattern matching class List<A> { case Nil; case Cons(A head, List<A> tail); } We can now define sum: public static int sum(List<int> l){ switch (l) { case Nil : return 0; case Cons (int e, List<int> es) : return (e + sum(es)); } Unfortunately the compiler didn’t agree... Center for Software Technology Sander Mak
  • 20. The Pizza Compiler > Features > Algebraic Datatypes Sum using ADT and pattern matching Compiler error An exception has occurred in the compiler. (v1.0g) Please file a bug report at Sourceforge.net Thank you. Exception in thread quot;mainquot; java.lang.StackOverflowError Center for Software Technology Sander Mak
  • 21. The Pizza Compiler > Features > Algebraic Datatypes Sum using ADT and pattern matching Compiler error An exception has occurred in the compiler. (v1.0g) Please file a bug report at Sourceforge.net Thank you. Exception in thread quot;mainquot; java.lang.StackOverflowError After some experimentation: Fix public static Integer sum(List<Integer> l){ switch (l) { case Nil : return new Integer(0); case Cons (Integer e, List<Integer> es): return new Integer(e.intValue() + sum(es).intValue()); } Center for Software Technology Sander Mak
  • 22. The Pizza Compiler > Features > Algebraic Datatypes Pattern matching Wildcard pattern is allowed for unused variables Nested pattern matching is supported Overlapping patterns are detected, and not allowed Pizza compiler AST is an Algebraic datatype Enumeration types are within reach (as in Java 1.5): class Color { case Red; case Blue; String toString() { switch (this) { case Red: return “Red”; case Blue: return “Blue”; } } } Center for Software Technology Sander Mak
  • 23. The Pizza Compiler > Features > Algebraic Datatypes Translation to Java class List { static final List Nil = new List(1); public final int Listtag; static List Cons(Object head, List tail) { return (List)new Cons(head, tail); } List(int Listtag) { super(); this.Listtag = Listtag; } static class Cons extends List { Object head; List tail; Cons(Object head, List tail) { super(2); this.head = head; this.tail = tail; } } } Center for Software Technology Sander Mak
  • 24. The Pizza Compiler > Features > Algebraic Datatypes Translation to Java class List { static final List Nil = new List(1); public final int Listtag; static List Cons(Object head, List tail) { return (List)new Cons(head, tail); } List(int Listtag) { super(); this.Listtag = Listtag; } static class Cons extends List { Object head; List tail; Cons(Object head, List tail) { super(2); this.head = head; this.tail = tail; Constructing an instance of List<int> in Pizza } } List<int> nums = List.Cons(1,List.Cons(2,List.Nil)); } Center for Software Technology Sander Mak
  • 25. The Pizza Compiler > Features > First-class functions Why pass functions? Let’s examine a sorted set implementation Current practice class Set implements SortedSet { public Set(Comparator c){..} .. } interface Comparator { int compare(Object o1, Object o2); } Extra class definition and implementation necessary to provide ordering functionality... Center for Software Technology Sander Mak
  • 26. The Pizza Compiler > Features > First-class functions Why pass functions? Let’s examine a sorted set implementation Current practice class Set implements SortedSet { public Set(Comparator c){..} .. } interface Comparator { int compare(Object o1, Object o2); } Extra class definition and implementation necessary to provide ordering functionality... What if... class TreeSet { public TreeSet((Object,Object) -> int compare) { .. order = compare(o1,o2); .. } .. } Center for Software Technology Sander Mak
  • 27. The Pizza Compiler > Features > First-class functions Syntax Pizza adds function types and values to Java Function declaration (member or local) (Object,Object) -> int compare = fun (Object o1,Object o2) -> int {.. implementation ..}; Implementation may reference o1, o2, and everything in enclosing class (not itself!) Function declaration top-level public int compare(Object o1, Object o2) {.. implementation ..}; Top-level functions can be passed around by using their name without parentheses. Comparator example is solvable using anonymous class instances. But how powerful/scalable is this approach? Center for Software Technology Sander Mak
  • 28. The Pizza Compiler > Features > First-class functions Let’s make a Pizza foldr! public class Foldr { static <D,E> D foldr((E,D) -> D f, D unit, List<E> l){ switch(l){ case Nil: return unit; case Cons(E h, List<E> t): return f(h,foldr(f,unit,t)); } } Type of foldr in Haskell foldr :: (a → b → b) → b → [a] → b Center for Software Technology Sander Mak
  • 29. The Pizza Compiler > Features > First-class functions Let’s make a Pizza foldr! public class Foldr { static <D,E> D foldr((E,D) -> D f, D unit, List<E> l){ switch(l){ case Nil: return unit; case Cons(E h, List<E> t): return f(h,foldr(f,unit,t)); } } static Integer add(Integer i1, Integer i2){ return new Integer(i1.intValue() + i2.intValue()); } public static void main(String[] args){ (List<Integer>) -> int sum = fun (List<Integer> l) -> int {(foldr(add,new Integer(0),l))}; } Center for Software Technology Sander Mak }
  • 30. The Pizza Compiler > Features > First-class functions Does this first-class function feature transform Pizza/Java into Haskell? spacer Well... not really: No currying No referential transparency No lazy evaluation Center for Software Technology Sander Mak
  • 31. The Pizza Compiler > Features > First-class functions Translation to Java A class with First class functions results in 2 translated classes Most important task: ensure scoped variables are available spacer spacer Translated Functions class spacer contains a method for every There are 3 cases to consider: first-class function body Local definition of a function FunctionsClosures extends 1 pizza.support.Closure and has Passing of functions 2 an apply method for each Application of a function 3 signature Center for Software Technology Sander Mak
  • 32. The Pizza Compiler > Features > First-class functions Translation to Java Functions.pizza 1 class Functions { 2 public Functions(int a){ (int) -> int incr = fun (int i)->int {return i+a;}; 3 4 int result = this.f(incr); } 5 6 public int f((int) -> int incr){ 7 return incr(2); } 8 9} Center for Software Technology Sander Mak
  • 33. The Pizza Compiler > Features > First-class functions Translation to Java Functions.pizza 1 class Functions { 2 public Functions(int a){ (int) -> int incr = fun (int i)->int {return i+a;}; 3 4 int result = this.f(incr); } 5 6 public int f((int) -> int incr){ 7 return incr(2); } 8 9} Case 1: Local definition (line 3) pizza.support.Closure incr = new FunctionsClosures(this, 0, new Object[]{new Integer(a)}); Center for Software Technology Sander Mak
  • 34. The Pizza Compiler > Features > First-class functions Translation to Java Functions.pizza 1 class Functions { 2 public Functions(int a){ (int) -> int incr = fun (int i)->int {return i+a;}; 3 4 int result = this.f(incr); } 5 6 public int f((int) -> int incr){ 7 return incr(2); } 8 9} Case 1: Local definition (line 3) int closureFunctions0(int i, Object[] freevars) { int a = ((Number)freevars[0]).intValue(); return i+a; } Center for Software Technology Sander Mak
  • 35. The Pizza Compiler > Features > First-class functions Translation to Java Functions.pizza 1 class Functions { 2 public Functions(int a){ (int) -> int incr = fun (int i)->int {return i+a;}; 3 4 int result = this.f(incr); } 5 6 public int f((int) -> int incr){ 7 return incr(2); } 8 9} Case 2: Passing functions (line 4) int result = this.f(incr); Center for Software Technology Sander Mak
  • 36. The Pizza Compiler > Features > First-class functions Translation to Java Functions.pizza 1 class Functions { 2 public Functions(int a){ (int) -> int incr = fun (int i)->int {return i+a;}; 3 4 int result = this.f(incr); } 5 6 public int f((int) -> int incr){ 7 return incr(2); } 8 9} Case 3: Applying functions (line 7) public int f(pizza.support.Closure incr) { return ((Number)incr.apply(new Integer(2))).intValue(); } Center for Software Technology Sander Mak
  • 37. The Pizza Compiler > Rough edges Language mismatches and other problems There is a fixed maximum on the #arguments for first-class functions (definition of Closure) Access modifiers are not fine-grained enough for accurate translation Lots of typecasts are inserted to pass bytecode verification. Most are not necessary because of Pizza’s typesystem Generic array creation and generic instantiation are not possible due to type erasure ’Strict superset’-claim is false: cannot use (new) keyword fun as identifier Center for Software Technology Sander Mak
  • 38. The Pizza Compiler > Related work Other approaches GJ: Generic Java spin-off from Pizza Only the parameterized types from Pizza Some differences: only reference type parameters, compatibility with non-generic classes, generic array creation Ended up in Java 1.5! Scala language by Martin Odersky Departs from notion of translation into the Java language Result: more freedom to implement new features Runs on JVM C++ Templates superficially similar to parameterized types More like macros: each instantiation results in a new class Templates are not type-checked (only their instances) Center for Software Technology Sander Mak
  • 39. The Pizza Compiler > Conclusion > Opinion Quality of error messages A measure of compiler quality can be the quality of its errors: Failure of bound-inference for generic types leads to good, understandable feedback Omitting a case in a switch leads to a vague error message about a missing return statement There is an (undocumented) fixed maximum on the number of arguments for a first class function. Violating this gives a long, vague error message I would say that Pizza is usable, but not in production environments. Center for Software Technology Sander Mak
  • 40. The Pizza Compiler > Conclusion > Opinion Quality in general Papers on Pizza are very well written A very thorough description of the Pizza typesystem shows that the project is not mere hacking of cool features Implementation is not robust, not unusable either I would say that Pizza is a very good example of a research project that had significant impact (through Generic Java → Java 1.5) Center for Software Technology Sander Mak
  • 41. The Pizza Compiler > Conclusion > The End I hope this overview encourages you to find new ways to enhance existing ideas! spacer spacer Odersky and Wadler: ’We are not short on innovations, but we need more ways to translate innovation in to practice’ spacer Try it yourself @ pizzacompiler.sourceforge.net Center for Software Technology Sander Mak