language workbenches - voelter engineeringworkbenches engineering in product line language ppl 2009...
TRANSCRIPT
03.11.2009
1
Workbenches
Engineering
inProduct Line
Language
PPL 2009 Keynote
Markus VoelterIndepenent/[email protected]://www.voelter.de
Workbenches
Engineering
inProduct Line
Language
Variability in PLE
Domain Specific Languages
Modeling and Programming
Modeling as Programming
Programming as Modeling
Expressing Configurabiliy in DSLs
Modular Languages
Summary
Variabilityin PLE
Variability… differences among
products in PL
03.11.2009
2
Removal… optionally take away
from overall whole
Variability Mechanisms
Injection… optionally add to
minimal core
Variability Mechanisms
Parametrization… define values for
predefined params
Variability Mechanisms
VariabilityConfiguration vs. Customization
Framworks
Routine
Configuration
Creative
Construction
Wizards
Property Files
Feature-Model
Based
Configuration
Graph-Like
Languages
Tabular
Configurations
Manual
Programming
Guidance,
Efficiency
Complexity,
Flexibility
Configuration
Parameters
Configuration… selecting options… setting param values
Engine
Aircraft
Wing
high shoulder low Jet Piston
mandatory optional
alternative(1 of m)
or (n of m)
Materials
woodmetal cloth plastic
mandatory
or (n of m)
Feature ModelsConfiguration
03.11.2009
3
Customization… „real languages“… instantiation… connections
LanguagesCustomization
PLE is also about…
ProcessOrganizationPeopleProduct Mgt.
ProcessPLE is also about…
OrganizationPeople
not today!Product Mgt.
03.11.2009
4
Domain SpecificLanguages
Domain SpecificLanguages
Focus of this talk!
programming
close to the hardwarestarted
abstractionscomputing
chips
abstractionscomputing
bits C
abstractionscomputing
03.11.2009
5
Java
abstractionscomputing?
SQL
abstractionscomputing?
?
03.11.2009
6
general purpose domain specific
effective++
specialized, limited
used by experts
together with otherspecialized tools
tailor made
execute?
map
03.11.2009
7
DSL Program
GPL Program
(aka Model)
map
automated!
map
GenerationTransformationCompilation
Interpretation
PlatformArchitecture
DSLAs you
understandand develop
yourPlatform
Architecture…
Develop a language to express it!
03.11.2009
8
Language resembles
architectural concepts…
Express the applications
with the language.
Architecture As LanguageAnother Story…
03.11.2009
9
Modelingand Programming
pareCom
Modeling Programming
Domain SpecificNotations
andAbstractions
LibrariesFrameworks
(Fluent) APIs
Flexible! Limited!
03.11.2009
10
GraphicalTextual
FormsTables
TextualTrees
Limited!Flexible!
CustomizeGenerator
orInterpreter
Limited!Flexible!
ReflectionMeta ProgramsOpen Compilers
Define customQueryorNavigate
Limited!Flexible!
AST APIsStatic Analysis
Transformor
Regex
CustomValidationorError Checks
Limited!Flexible!
IDE pluginsStatic AnalysisOpen Compilers
DifferentRepresentations
andProjections
Limited!Flexible!
Text is TextCode FoldingTree ViewsVisualizations
Limited!Flexible?
Python-to-C-likeInternal DSLs
Mixingand
ComposingLanguages
Embed-As-StringSpecific: LINQ
03.11.2009
11
Mature!Brittle!
IDE Support
Scalable
Modeling Tools…!?
Usable
Mature!Brittle!
Testing
Debugging
?
Refactoring
Mature!Brittle!
Branching
VersioningDiff, Merge
for some tools…
Gets theGets some
some people doubt that…
Job Done!Jobs done.everybody agrees…
Modeling Tools
Programming Tools!=
Different Worlds
03.11.2009
12
Modeling Tool
Modeling Tool!=
Different Worlds Different WorldsMix Models and Programs
Different WorldsAST Navigation & Query
Mix Models and Programs
Different WorldsAST Navigation & Query
Mix Models and Programs
Integration of 3GL code
Different WorldsAST Navigation & Query
Mix Models and Programs
Integration of 3GL codeCode Constraints
03.11.2009
13
Whythe difference?
History?
Modeling Programming Modeling Programming
… (Mostly) Textual Notations
… Concrete Syntax Storage
… (Fancy) ASCII Editors
… Read-Only Visualizations
Modeling
… (Mostly) GraphicalNotations
… Abstract Syntax Storage
… Projecting Editors
… Different editableviews for model
Programming
… (Mostly) Textual Notations
… Concrete Syntax Storage
… (Fancy) ASCII Editors
… Read-Only Visualizations
Whythe difference?
03.11.2009
14
It is time for … … a Different Perspective
Programmingthe way we do
Modeling?
Modelingthe way we do
Programming?
Modeling Programming
Programming Modeling
====
We don‘t want to
we want tomodel,
program!
03.11.2009
15
We don‘t want to
we want tomodel,
program!… at different levels of abstaction
… from different viewpoints
… integrated!
We don‘t want to
we want tomodel,
program!… with different degrees of
… with suitable notations
… with suitable expressiveness
domain-specificity
We don‘t want to
we want tomodel,
program!
precise and tool processableAnd always:
LanguageWorkbench
(Martin Fowler)
03.11.2009
16
LanguageWorkbench
(Martin Fowler)
Freely
define
integratethem
languages and ?
LanguageWorkbench
(Martin Fowler)
usepersistent
abstractrepresentation
LanguageWorkbench
(Martin Fowler)
language ::=
schemaeditors
generators+
+
?
LanguageWorkbench
(Martin Fowler)
editingprojectional
LanguageWorkbench
(Martin Fowler)
persist
incomplete
contradictoryinformation
or
LanguageWorkbench
(Martin Fowler)
powerful
editingtesting
refactoringdebugging
language definition
IDE definitionimplies
+groupware
03.11.2009
17
LanguageWorkbench
(Martin Fowler)
support for„classical“
programming„classical“
modelingand
+Syntax
primarilytextual
Syntaxprimarilytextual
with more symbolsthink: mathematics
Syntaxprimarilytextual
sometimesbox&line style
Syntaxprimarilytextual
sophisticatedvisualizations
03.11.2009
18
Modelingas Programming
Modeling as Programmig
… (Mostly) Textual Notations
… Concrete Syntax Storage
… (Fancy) ASCII Editors
… Read-Only Visualizations
Parser-basedtext… to tree… to text
Custom Syntax
GraphicalTextualSymbolic++
IDESupport
TeamworkDebuggingCustom Editors
03.11.2009
19
CompleteSymbolicIntegration
Goto DefFind RefsRefactoring
Integrates withCurrent DevInfrastructure
Version MgtDiff/MergeCmd Line Tools
UnicodeLimited to
how to handlenon-character symbols
TextGraphics !=
two worlds…
separate editors… per syntax/viewpoint… models can still be ref integrated
http://eclipse.org/modeling
03.11.2009
20
http://eclipse.org/xtext
Eclipse Xtext
Building Textual Editors
Eclipse Xtext
Building Textual Editors
Xtext: Specify Grammar
Xtext: Gen. Meta Model Xtext: Constraints
03.11.2009
21
Xtext: Generated Editor
Code Completion
Xtext: Generated Editor
Syntax ColoringCustom Keyword Coloring
Xtext: Generated Editor
Realtime ConstraintValidation
Xtext: Generated Editor
CustomizableOutlines
Xtext: Generated Editor
Code Folding
Xtext: Generated Editor
03.11.2009
22
Goto Definition Find ReferencesCross-File ReferencesModel as EMF
Xtext: Generated Editor Xtext: Generated Editor
DEMO I
Building DSLs with Eclipse Xtext
Programmingas Modeling
03.11.2009
23
Programming as Modeling
… (Mostly) GraphicalNotations
… Abstract Syntax Storage
… Projecting Editors
… Different editableviews for model
Programming as Modeling
… (Mostly) Graphical Any kind ofNotations
… Abstract Syntax Storage
… Projecting Editors
… Different editableviews for model
Projectionaltree… to text-lookalike (editor)… to other trees … **+… to text
Language
There‘s no parsing.
Unique Language Element Identity.
Unlimited language composition.
CompositionTextual
Graphical
Semi-Graphical
treated the same
can be mixed
like ASCII }box & line
mathematical
Flexible
Notations
03.11.2009
24
Automatic
IDE Extensiontool support is inherent
for languages built withprojectional tools
language definition
IDE definitionimplies
MultipleNotations
… for the same concepts
e.g. in different contextsor for different tasks
PartialProjections
… different views… for different roles/people… only a particular variant
Storage!= Schema
… independent of language schema!variability annotations
… store arbitrary meta datachange logconflicting information
… „aspects“, overlay
ProgramsLive
think: spreadsheet
a change to one part of programcan lead to (dependent) changesin other partsuseful e.g. for tests running in the workbench
Tree Editing
… try to make it feel like text
… takes some getting used tobut: for more flexible notations a more general editing paradigm is needed
… is different from editing text
03.11.2009
25
InfrastructureIntegration
… diff/merge must be in tool
… existing text tools don‘t work
… storage is not text
ProprietaryTools
… no out-of-the-box interop
… no standards
Jetbrains‘
ProgrammingMeta
System
Q3 2009released in
Apache 2.0licensed under
Build new standalone DSLs
03.11.2009
26
Build new standalone DSLsBuild DSLs that reuse parts
of other languages
Build new standalone DSLsBuild DSLs that reuse parts
of other languages
(MPS comes with BaseLanguage)
extend base language
Java++
Build new standalone DSLsBuild DSLs that reuse parts
of other languages
(MPS comes with BaseLanguage)
extend base languagebuild DSLs that reuse parts
of BaseLanguage
Java++
Language Extension Example
ReadWriteLock l = …
l.readLock().lock();
try {
//code
} finally {
l.readLock().unlock();
}
Old
Language Extension Example
ReadWriteLock l = …
l.readLock().lock();
try {
//code
} finally {
l.readLock().unlock();
}
OldReadWriteLock l = …
lock (l) {
//code
}
New
Language Extension Example
03.11.2009
27
Structure Editor Typesystem Generator Structure Editor Typesystem Generator
Structure Editor Typesystem Generator Structure Editor Typesystem Generator
Structure Editor Typesystem Generator Structure Editor Typesystem Generator
03.11.2009
28
Structure Editor Typesystem Generator Structure Editor Typesystem Generator
Structure Editor Typesystem Generator Language Extension Example
Result behaves like a nativebase language construct
Language Extension Example
Result behaves like a nativebase language construct
Language Extension Example
Translated to regular Java codebased on the generator
package jaxdemo.sandbox.sandbox;
import java.util.concurrent.locks.Lock;
public class DemoClass {
private Lock lock;
public DemoClass() {try {this.getLock().lock();SharedResouce.instance().doSomething();
} finally {this.getLock().unlock();
}}
private Lock getLock() { return this.lock; }
}
03.11.2009
29
DEMO II
Extending Java withJetBrains MPS
Example LanguagesUI Language
Example LanguagesHTML Templates
Example LanguagesPersistent Classes
03.11.2009
30
Dec 15, 2008Version 1.0 released in
currently at 1.5
CommercialProduct
Eval availableupon request
Statemachine Example
Nat
ive
Pro
ject
ion
Statemachine Example
Tab
ula
r P
roje
ctio
n
Statemachine Example
Text
ual
DSL
Pro
ject
ion
03.11.2009
31
Statemachine Example
Java
Pro
ject
ion
Statemachine Example
Ru
by
Pro
ject
ion
Statemachine Example
Ru
by
Pro
ject
ion
Statemachine Example
Two
pro
ject
ion
s si
de
/sid
e
Pension Workbench Example
Text Editing Domain
03.11.2009
32
Pension Workbench Example
Insurance Mathematics Domain
Pension Workbench Example
Pension Rules Domain w/ tests
Pension Workbench Example
All in one Document
Pension Workbench Example
Symbolically integrated
ExpressingConfigurability
03.11.2009
33
Configuration on model levelfewer variation pointsless complex„expanded“ via generator
ModelImplementation
ArtefactsTransformation
more abstract
less detailed
less abstract
more detailed
Configuration on model levelfewer variation pointsless complex„expanded“ via generator
Transformation
= Variation Point
Negative Variability:Conditionally taking
something away
Negative Variability:Conditionally taking
something away
Feature Models
03.11.2009
34
component DelayCalculator {
provides default: IDelayCalculator
requires screens[0..n]: IInfoScreen
provides mon: IMonitoring feature monitoring
}
component DelayCalculator {
provides default: IDelayCalculator
requires screens[0..n]: IInfoScreen
provides mon: IMonitoring feature monitoring
}
System
Failover Monitoring
Graceful
DegradationRedundancy
Data
Management
Centralized Distributed
namespace monitoringStuff feature monitoring {
component MonitoringConsole {
requires devices:[*]: IMonitor
}
instance monitor: MonitoringConsole
dynamic connect monitor.devices query {
type = IMonitor
}
}
Positive Variability:Conditionally adding
something to a minimal core
Positive Variability:Conditionally adding
something to a minimal core
Aspects
03.11.2009
35
namespace monitoring {
component MonitoringConsole …
instance monitor: …
dynamic connect monitor.devices …
aspect (*) component {
provides mon: IMonitoring
}
}
component DelayCalculator {
…
}
component AircraftModule {
…
}
component InfoScreen {
…
}
component DelayCalculator {
…
}
component AircraftModule {
…
}
component InfoScreen {
…
}component DelayCalculator {
…
provides mon: IMonitoring
}
component AircraftModule {
…
provides mon: IMonitoring
}
component InfoScreen {
…
provides mon: IMmonitoring
}
aspect (*) component {
provides mon: IMonitoring
}
Weaver is generic:
works with all (container)model elements
aspect (*) <type>all instances of type
aspect (tag=bla) <type>all instances with tag bla
aspect (name=S*) <type>all instances whose namestarts with S
namespace monitoring feature monitoring {
component MonitoringConsole …
instance monitor: …
dynamic connect monitor.devices …
aspect (*) component {
provides mon: IMonitoring
}
}
AO + Features
03.11.2009
36
DEMO III
Adding Variability and connectivity to a feature model to an Xtext DSL
A statemachine
Actually, several…! Variant for Pedestrians
03.11.2009
37
Variant for Cars
DEMO IV
Expressing Variabilitywith MPS
Facilities to express
are completely
of the target language!
Variability
independent
Facilities to express
are completely
of the target language!
Variability
independent
which leads to…
03.11.2009
38
ModularLanguages
ViewpointsBusiness
custompurpose-built
create/include
Viewpoints
CustomNotations
businessexpert integration
real
Business
ViewpointsTechnical
predefinedlibrary
configure
L
ab
c
d
e
f
gh
i
j
k
m
n
o
with many first class concepts!
Big Language?
03.11.2009
39
L
Small Language?
and poweful conceptswith a few, orthogonal
my L
a b c
d e f
g h i
j k l
Modular Language
composable conceptswith many optional,
Like frameworksand libraries,
Modular Language
Like frameworksand libraries,
but with syntaxand IDE support
Modular Language
Not a new idea…
03.11.2009
40
Growing A Language(Guy L Steele)
matricesAdding
embeddedto C in an
environment.
(Seemingly)
Simple Example
Currently:
1• Declare Data Structures in XML
2• Generate Headers
3• Implement manually in C
Currently:
Matrices
and generator
not supportedin XML format
03.11.2009
41
Currently:
Tool team
… a lot of work
would have todo the extension
… busy… one central tool
Currently:
No real
… type checks
compiler supportin the resulting C code
… operator overloading… generics (matrix<int>)… matrix syntax?
Better Solution
Better Solution
types
matrixgeneric
vectorand
Better Solution
matrixreal
literalsvector
and
03.11.2009
42
Better Solution
highlightssyntax
vectorsfor
and
matrices
Better Solution
operatoroverloading
Better Solution
operatoroverloading
staticoptimization… symmetrical matrices… identity matrix… diagonal matrices
Better Solution
mathnotation
Better Solution
used only bythose who
separatea
modulelanguage
really need it
03.11.2009
43
In addition: PLE Variability
variabilityannotating
expressionsto
arbitraryregions
In addition: PLE Variability
variabilityannotating
expressionsto
arbitraryregions
statically checked
In addition: PLE Variability
variabilityannotating
expressionsto
arbitraryregions
projectvariant
03.11.2009
44
03.11.2009
45
03.11.2009
46
03.11.2009
47
DEMO V
Language Modularitywith MPS
03.11.2009
48
Summary
Usefulness of DSLs
Usable tools
Variability in Models
Modular Languages
Usefulness of DSLs
Usable tools
Variability in Models
Modular Languages
Usefulness of DSLs
Usable tools
Variability in Models
Modular Languages
Usefulness of DSLs
Usable tools
Variability in Models
Modular Languages
03.11.2009
49
Usefulness of DSLs
Usable tools
Variability in Models
Modular Languages
THE
END
Markus VoelterIndepenent/[email protected]://www.voelter.de