180 likes | 498 Views
Apposition. Programming Language Symbiosis is an Absolute Prerequisite for True Multiparadigm Programming. Definitions. Multiparadigm Programming (MPP) Language
E N D
Apposition Programming Language Symbiosis is an Absolute Prerequisite for True Multiparadigm Programming Tom Tourwé
Definitions • Multiparadigm Programming (MPP) Language “A programming language/environment that allows a developer to use the best suited programming paradigm for a specific task or problem” • Programming Language Symbiosis “Transparant use of features from one particular programming language in another language” Tom Tourwé
The Need for MPP • Software engineering requirements • Use most suited paradigm/programming language for a given problem • Component-oriented programming • Should allow components written in different programming languages to collaborate • Misc: CORBA, Webservices, etc.. • Programming language independent • Communication overhead • Not transparant Tom Tourwé
Example: Graphics Framework • Different kinds of figures that share common state/behaviour • Figure, Rectangle, Ellipse, etc. • Constraints between/invariants of different figures in a drawing • Alignment, dependencies, etc.. • Operations on figures • group, reshape, move, etc. OO Paradigm Logic Paradigm Functional Paradigm Tom Tourwé
Requirements • Transparency between paradigms • Shared program elements: primitive types, lists, objects, etc .. • Use of functions, procedures, methods, predicates, etc .. • Extensibility • Straightforward incorporation of new paradigms • Integration of paradigms • Whole should be more than the sum of its parts • No restrictions on use of particular paradigm Tom Tourwé
“Industrial” MPP Languages • C++ • Integrates imperative & object-oriented paradigm • Not extensible • Integrates a limited number of paradigms only • Weak integration • Only paradigms that can easily be combined • .Net • No integration, only “interoperation” • Extensible (CLR) • In theory: many different languages/paradigms • In practice: class-based OO languages • Restrictions on use of paradigms • Based on “common” subset of features • No multiple inheritance, covariant overriding, etc. Tom Tourwé
“Research” MPP Prototypes • R++ • Extension of C++ with logic rules • Constraints, invariants, etc … • Functional Logic Programming • Extensions of logic languages with functional features • List manipulation, higher-order functions, etc … • Prolog++ • Extension of logic programming with object-oriented features Tom Tourwé
Objective • Provide a unified framework for building & experimenting with MP programming languages • Use 1 powerful “macro kernel” language that • offers a limited number of basic butpowerful features • serves as an underlying basis for the MPP language • is easily extensible with new paradigms • allows integration of different paradigms • (Transformational approach to MPP) Tom Tourwé
Example: Scheme • Simple but powerful, (mostly) functional language • Closures • Macros & Quasiquoting • syntax extensions • Expansion/code generation • First-class continuations • Explicitly manage control flow • Existing Scheme extensions • Logic programming (Schelog) • Class/Object-based OO • .. Tom Tourwé
(define-macro class (lambda (super . definitions) `(letrec (..)))) (define-macro var (lambda (name . value) `(define ,name ,@value))) (define-macro method (lambda (selector arguments . body) `(set! ..))) (define Figure (letrec ((<<SUPER>> Root) (<<METHODS>> ‘())) (define area ‘()) .. (set! <<METHODS>> (cons (cons ‘displayOn: (lambda (aGC) (send self subclassResponsibility)) <<METHODS>>)) (define (self msg . args) (apply (cdr (assoc msg <<METHODS>>)) args)) self)) (define Figure (class Root (var area) .. (method displayOn (aGC) (send self subclassResponsibility)) ..)) Tom Tourwé
Example • Integration of OO and functional paradigms (define Drawing (class Figure .. (function group (aSelectionOfFigures) (send Drawing new: (cons (send CompositeFigure new: (map (lambda (aFigure) (send aFigure copy)) aSelectionOfFigures)) (filter (lambda (aFigure) (not (member? aFigure aSelectionOfFigures))) (send self getFigures))))) ..)) Tom Tourwé
Example • Integration of OO and logic paradigms (define Rectangle (class Figure (monitored-var width) (monitored-var height) (rule updateArea (width height) (when (and (> (send self getHeight) 0) (> (send self getWidth) 0)) (send self setArea: ((* (send self getHeight) (send self getWidth)))))) ..)) Tom Tourwé
Research questions • Feasability • Can a paradigm be integrated with others? How? • “Paradigm Leaks” • E.g. backtracking with side effects • Scalability • Integration of a new paradigm with all already existing paradigms • Performance & memory overhead • Trade-off Tom Tourwé
Questions Tom Tourwé
Example • Integration of OO and logic paradigms (define Figure (class Root (monitored-var deleted? #f) (method delete () (set! deleted? #t)) (rule deletionUpdate (deleted?) (when (and (member aDependent (send self myDependents)) (send aDependent deleted?)) (begin (send aDependent removeDependent: (self)) (send self removeDependent: (aDependent))))) ..)) Tom Tourwé