Generative Programming - PowerPoint PPT Presentation

About This Presentation
Title:

Generative Programming

Description:

Generative Programming also includes the process of creating ... Merges, deletes or modifies existing modules. Kind of transformations. Compiler transformations ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 25
Provided by: giuseppe92
Category:

less

Transcript and Presenter's Notes

Title: Generative Programming


1
Generative Programming
2
Generic vs Generative
  • Generic Programming focuses on representing
    families of domain concepts
  • Generative Programming also includes the process
    of creating concrete instances of concepts

3
Overview
Translator
Generative Component
Finished Configuration
Specification in a configuration DSL
Implementation components
4
Why Generators?
  • Raise the intentionality of system descriptions
  • E.g. using domain specific notation
  • Produce an efficient implementation
  • Nontrivial mapping into implementation concepts
  • Avoid the library scaling problem
  • Library built as concrete component double in
    size for each new added feature

5
Transformation Model
System Requirements
System Requirements
System Requirements
Manually implement
Manually implement
Manually implement
High Level System Specification
Implement with tools
Source in DSL
Source in DSL
Source Code (C, Java)
Source Code (C, Java)
Source Code (C, Java)
compile
compile
compile
System Implementation
System Implementation
System Implementation
6
Type of transformations
  • Vertical
  • Horizontal

7
Vertical Transformation
  • Refines higher-level structure into lower level,
    preserving structure
  • Typical of step-wise refinement and CASE or GUI
    builders

8
Horizontal Transformation
  • Modifies modular structure at the same level
  • Merges, deletes or modifies existing modules

9
Kind of transformations
  • Compiler transformations
  • Source to source transformations

10
Compiler Transformations
  • Refinements
  • Decomposition
  • Choice of representation
  • Choice of algorithm
  • Specialization
  • Concretization
  • Optimizations

11
Compiler Optimizations
  • Inlining
  • Constant folding
  • Data caching
  • Loop fusion
  • Adding matrixes ABC
  • Loop unrolling
  • When number of iterations is small
  • Code motion
  • Move invariant code outside of loop

12
Compiler Optimizations (2)
  • Common subexpression elimination
  • Dead-code elimination
  • Partial evaluation
  • Partially evaluate a function based on knowledge
    of some of its parameters to be constants in a
    special context
  • Finite differencing
  • x x 2 x x 2
  • y x 3 y y 6

13
  • y x 3
  • dy/dx 3
  • dx 2
  • yi1 yi 3 dx

14
Source to source Transformations
  • Editing transformations
  • Refactoring
  • Abstraction and generalization
  • Introducing new variant points
  • Simplification

15
Approaches
  • Aspect-Oriented Programming
  • Subject-Oriented Programming
  • Software Transformation Technologies
  • Intentional Programming
  • Domain Engineering
  • Generative Programming

16
Aspect Oriented Programming
  • To improve the modularity of designs and
    implementations by allowing a better
    encapsulation of cross-cutting concerns
  • synchronization, distribution, authentication,
    data traversal, memory allocation, tracing,
    caching, etc.
  • New kind of modularity called aspect
  • Aspects represent an orthogonal parameterization
    concept compared to what's available in current
    languages

17
Subject Oriented Programming
  • Related to AOP
  • Focuses on capturing different subjective
    perspectives on a single object model
  • It allows composing applications out of
    "subjects" (partial object models) by means of
    declarative composition rules

18
Software Transformations
  • aid software development activities by providing
    mechanized support for manipulating program
    representations
  • Examples
  • extracting views
  • Refinement
  • Refactoring
  • optimizations of program representations

19
Intentional Programming
  • an extendible programming environment based on
    transformation technology and direct manipulation
    of active program representations
  • New programming notations and transformations can
    be distributed and used as plug-ins
  • The system replaces parsing technology with the
    direct entry and editing of resolved ASTs

20
Domain Engineering
  • Domain engineering comprises the development of a
    common model and concrete components, generators,
    and reuse infrastructures for a family of
    software systems

21
Goals of Generative Programming
  • Each language implements its own libraries types
    are hard to match
  • Problem
  • int add(int i, int j) return ij
  • add(1, x)
  • int inc(int x) return add(1, x)
  • class Complex double r, i
  • Complex add(Complex x, Complex y)
  • return Complex(x.r y.r, x.i y.i)

22
  • Complex inc(Complex x)
  • return add(Complex(1, 0), x)
  • Compiler cant optimize, since it does not know
    the Complex type
  • Class used to represent concepts in domain, but
    semantics of domain is not conveyed to compiler

23
Partial Evaluation
  • Matrix A, B, C, D
  • D A.add(B.add(C))
  • Requires allocation of temporary intermediate
    matrix and two loops
  • Compiler is not capable, DSL for algebra could
    incorporate, e.g. write
  • Matrix.add(A, B, C)

24
C
  • Using template metaprogramming one can produce
    specialized code
  • BLITZ matrix library faster than Fortran
Write a Comment
User Comments (0)
About PowerShow.com