Date post: | 30-Jun-2015 |
Category: |
Software |
Upload: | markus-voelter |
View: | 350 times |
Download: | 0 times |
0Introduction
more in GPLs more in DSLDomain Size large and complex smaller and well-defined
Designed by guru or committee a few engineers and domain experts
Language Size large small
Turing-completeness
almost always often not
User Community large, anonymous and widespread
small, accessible and local
In-language abstraction
sophisticated limited
Lifespan years to decades months to years (driven by context)
Evolution slow, often standardized fast-paced
Incompatible Changes
almost impossible feasible
C
LEGO Robot Control
Components
State Machines
Sensor Access
General Purpose
Domain Specific
1Case Study:
mbeddr
An extensible set of integrated languagesfor embedded software engineering.
„ “Specific Languages
Open Source @ eclipse.orgEclipse Public License 1.0http://mbeddr.com
itemis France: Smart Meter
First significant mbeddr projectca. 100,000 LoCabout to be finishedgreat modularity due to componentsuses physical units extensivelygreat test coverage due to special extensions
ACCEnTControl.Lab
20+ Projects in various stages
by various “Big Name” companies.
Branching into other domains
insurance, financial, tax
Open SourceApache 2.0http://jetbrains.com/mps
[Language Workbench]
+ Refactorings, Find Usages, Syntax Coloring, Debugging, ...
Parsing Projectional Editing
[Projectional Editing]
Regular Code/Text Mathematical
Tables Graphical
Syntactic Flexibility[Projectional Editing]
L2 L1
Separate Files In One File
Type SystemTransformationConstraints
Type SystemTransformationConstraintsSyntaxIDE
Language Composition[Projectional Editing]
2Expressivity
Shorter Programs
More Accessible Semantics
For a limitedDomain!
Domain Knowledge
encapsulated in language
Smaller Domain
More Specialized Language
Shorter Programs
Ѱ
The do-what-I-want
language
Ѱ
Single Program vs. Class/Domain
No Variability!
Domain Hierarchy
more specialized domainsmore specialized languages
Reification
Dn
Dn+1
==
Reification
==Language Definition
Transformation/Generation
C Extensions
Requirements
Linguistic Abstraction
In-LanguageAbstractionLibrariesClassesFrameworks
Linguistic Abstraction
In-LanguageAbstractionUser-DefinableSimpler Language
AnalyzableBetter IDE Support
FunctionsComponents
Linguistic Abstraction
In-LanguageAbstractionUser-DefinableSimpler Language
AnalyzableBetter IDE Support
Special Treatment!
Linguistic Abstraction
In-LanguageAbstraction
Std Lib
Block Library
Unique State Names
Unreachable States
Dead End States
Guard Decidability
Exhaustive Search, Proof!
Reachability
Component VerificationSM Model Checking
3Notation
UI for the language!Important for acceptance by users!
TextualProseSymbolic/MathTabularGraphical
Reuse existing syntax of domain, if any!
Tools let you freely combine all kinds.
Reuse existing syntax of domain, if any!
State Machine TablesMath
Component WiringProseTraces
4Type System
Static Semantics
Execution Semantics
Static Semantics
Execution Semantics
Static Semantics
ConstraintsType Systems
Unique State Names
Unreachable States
Dead End States
…
Extended C
Example
Unique State Names
Unreachable States
Dead End States
…
Easier to do on a declarative Level!
Extended C
Example
Unique State Names
Unreachable States
Dead End States
…
Easier to do on a declarative Level!
Thinking of all constraints is a coverage problem! Exten
ded C
Example
Assign fixed types
Derive TypesCalculate Common Types
Check Type Consistency
What does a type system do?
Intent +Check
Derive
More code
Better error messages
Better Performance
More convenient
More complex checkers
Harder to understand for users
Classical C TypesClosures
5Execution
Def: Semantics… via mapping to lower level
OB: Observable Behaviour (Test Cases)
Def: Semantics… via mapping to lower level
LD
LD-1
TransformationInterpretation
Dn
Dn+1
Transformation
LD
LD-1
Transformation
Known Semantics!
Transformation
LD
LD-1
TransformationCorrect!?
Transformation
Transformation
LD
LD-1
Transformation
Tests (D)
Tests (D-1)
Run tests on both levels; all pass.Coverage Problem!
mbeddr Tests
Multi-Stage
L3
L2
L1
L0
Modularization
Multi-Stage: Reuse
L3
L2
L1
L0
Reusing Later Stages
Optimizations!
L5
Multi-Stage: Reuse
L3
L2
L1
L0
L5
Extended C
Example
C Text
C (MPS tree)
State Machine
Components
Robot Control
Multi-Stage: Reuse
L3
L2
L1
L0
L5
Extended C
Example
C Text
C (MPS tree)
State Machine
Components
Robot Control
SyntacticCorrectness, Headers
C Type System
ConsistencyModel Checking
Efficient Mappings
Multi-Stage: Reuse
L3
L2
L1
L0
L1b
L0b
Reusing Early Stages
Portability
Multi-Stage: Reuse
L3
L2
L1
L0
L1b
L0b Extended C
Example
JavaC#
Mock Components
Multi-Stage: Preprocess
Adding an optional, modular
emergencystop feature
Composite Blocks Transformation
Platform
No Platform
A program at D0 thatacts on the structureof an input program at D>0
Interpretation
Transformation Interpretation
+ Code Inspection
+ Debugging
+ Performance & Optimization
+ Platform Con- formance
EssentiallyEverything :-)
Transformation Interpretation
+ Code Inspection
+ Debugging
+ Performance & Optimization
+ Platform Con- formance
+ Turnaround Time
+ Runtime Change
Business Rulesin Requirements
Def: Semantics… via mapping to lower level
LD
LD-1
TransformationInterpretation
Multiple Mappings… at the same time
LD
Lx Ly Lz
Similar Semantics?
T
T T Tall green!
Multiple Mappings… at the same time
LD
Lx Ly Lz
Similar Semantics?
T
T T Tall green!
Multiple Mappings… alternatively, selectably
LD
Lx Ly Lz
Extend LD to include explicit data that determines transformation
LD
Lx Ly Lz
External Data: - Switches- Annotation Model
Multiple Mappings… alternatively, selectably
Build ConfigComp Static Wiring
6Separationof Concerns
Several Concerns… in one domain
Several Concerns… in one domain
integrated intoone fragment
separated intoseveral fragments
Components +Instances
Viewpoints
independent
dependent
Viewpoints: Why?
Sufficiency
Different Stakeholders
Different Steps in Process – VCS unit!
SeparateRequirements
Viewpoints
sufficient?
contains allthe data for running a meaningfultransformation
independent
Viewpoints: Why?
1:n Relationships
Viewpoints
Well-defined Dependencies
No Cycles!
Avoid Synchronization!(unless you use a projectional editor)
Sync in Comp + Interfaces
7Completeness
Can you generate 100% of the code from the DSL program?
More generally: all of D-1
Incomplete: What to do?
FD
FD-1OB(FD) !=
Incomplete: What to do?
FD
FD-1
+ FD-1,
man
OB(FD) ==
Manually written code!
Manually written code?
Call “black box” code (foreign functions)
State MachineEvent Functions
Manually written code?
Call “black box” code (foreign functions)
Embed LD-1 code in LD program
All of mbeddr
Manually written code?
Call “black box” code (foreign functions)
Embed LD-1 code in LD program
Use composition mechanisms of LD-1 (inheritance, patterns, aspects, …)
Manually written code?
Call “black box” code (foreign functions)
Embed LD-1 code in LD program
Use composition mechanisms of LD-1 (inheritance, patterns, aspects, …)
Use protected regions (if you really have to…)
Manually written code?
Call “black box” code (foreign functions)
Embed LD-1 code in LD program
Use composition mechanisms of LD-1 (inheritance, patterns, aspects, …)
Use protected regions (if you really have to…) DON’T!
Roundtripping
LD
LD-1
L’D-
1
L’D
………
Roundtripping – Don’t!
LD
LD-1
L’D-
1
L’D
………
Semantic Recovery!
8Fundamental
Paradigms
Structure
Modularization, VisibilityNamespaces,public/privateimporting
Structure
Modularization, Visibility
divide & conquerreusestakeholder integration
Namespaces,public/privateimporting
mbeddr Chunks
Structure
Partitioning (Files)
VCS UnitUnit of sharingUnit of IP
!= logical modulesmay influence language design
MPS models
Structure
Spec vs. Implementationplug in different Implsdifferent stakeholders
Interfaces +Components
Structure
SpecializationLiskov substitution Pleaving holes (“abstract”)
Structure
SpecializationLiskov substitution Pleaving holes (“abstract”)
variants (in space)evolution (over time)
ComponentsPolymorphism
Behavior
Not all DSLs specify behavior
Some just declare behavior
This section is not for those!
Behavior
Imperativesequence of statementschanges program state
write understand
debug
analyze performance
simple simple - simple (step)
hard good
C
Behavior
Functionalfunctions call other functions.no state. No aliasing.
write understand
debug
analyze performance
simple - simple simple (tree)
good good -
ACCENT Blocks
Behavior
Functionalpure expressions are a subset of functional(operators hard-wired)
guardspreconditionsderived attributes
Business Rules –Debugging
Behavior
Declarativeonly facts and goals. no control flow.eval engine, solver (several)
write understand
debug
analyze performance
simple simple - hard depends often bad
Behavior
Declarativeconcurrencyconstraint programmingsolvinglogic programming
Typing Rules
Behavior
Data Flow
chained blocks consume continuous data that flows from block to block
write understand debug
analyze performance
simple - simple/hard hard simple can be good
Behavior
Data Flow
continuous, calc on changequantized, calc on new datatime triggered, calc every x
Behavior
Data Flow
Embedded ProgrammingEnterprise ETL & CEP
ACCENT Blocks
Behavior
State Based
states, transitions, guards, reactions
write understand debug
analyze performance
simple - simple/hard s/h simple +
can be good
event driven, timed
State Machines
Behavior
Combinationsdata flow uses functional, imperative or declarative lang inside block
Behavior
Combinationsstate machines use expressions in guards and often an imperative lang in actions
9Modularity
BehaviorLanguage Modularity, Composition and Reuse (LMR&C)
increase efficiency of DSL development
ReferencingReuseExtensionReuse
4 ways of composition:
BehaviorLanguage Modularity, Composition and Reuse (LMR&C)
increase efficiency of DSL development
distinguished regardingdependencies and fragmentstructure
4 ways of composition:
BehaviorDependencies:
do we have to know about the reuse when designing the languages?
homogeneous vs. heterogeneous(„mixing languages“)
Fragment Structure:
BehaviorDependencies &Fragment Structure:
BehaviorDependencies &Fragment Structure:
ReferencingReferencing
Referencing
Dependent
No containment
Referencing
Used in Viewpoints
Referencing
Extension
Containment
Dependent
Extension
more specialized domainsmore specialized languages
ExtensionExtension
Dn
Dn+1
==
Extension
Dn
Dn+1
==
Extension
Dn
==
Good for bottom-up (inductive) domains, and for use by technical DSLs (people)
Extension
BehaviorDrawbacks
tightly bound to basepotentially hard to analyze the combined program
Extension
Embedding
EmbeddingEmbedding
Containment
Independent
Embedding
Units in State Machines