07.05.2010
1
Domain-Specific Languages
Language Workbenchesand
Markus VoelterIndependent/[email protected]
Software Engineering with
Peter [email protected]
07.05.2010
2
Programming Languages
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
Programming Languagesare not
enough.expressive
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
07.05.2010
3
Programming Languagesare not
enough.high-level
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
Programming Languagesare not
enough.abstract
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
07.05.2010
4
Programming Languagesare not
enough.domain-specific
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
Programming Languagesare notenough.
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
07.05.2010
5
Programming LanguagesFormats
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
HTML
XMLCSSyaml
json
Programming LanguagesFormats
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
HTML
XMLCSSyaml
json
JEEWPF
Rails
Django
JMS
lift
Frameworks
07.05.2010
6
Programming LanguagesFormats
C# C++
JavaPython
GroovyRuby
Erlang
CFortran
HTML
XMLCSSyaml
json
JEEWPF
Rails
Django
JMS
lift
Frameworksare not enough.
So?
07.05.2010
7
Modeling… Higher Level
… Domain Specific
Interpretation… Code Generation
Concepts & Notations
Solves theProblem!
DSL
07.05.2010
9
effective++
specialized, limited
used by experts
together with otherspecialized tools
tailor made
But:
07.05.2010
10
Modeling Tools
Programming Tools!=
Different Worlds
Modeling Tool
Modeling Tool!=
Different Worlds
07.05.2010
11
Different WorldsMix Models and Programs
Different WorldsAST Navigation & Query
Mix Models and Programs
07.05.2010
12
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
07.05.2010
13
pareCom
Domain SpecificNotations
andAbstractions
LibrariesFrameworks
(Fluent) APIs
Flexible! Limited!
07.05.2010
14
GraphicalTextual
FormsTables
TextualTrees
Limited!Flexible!
CustomizeGenerator
orInterpreter
Limited!Flexible!
ReflectionMeta ProgramsOpen Compilers
07.05.2010
15
Define customQueryorNavigate
Limited!Flexible!
AST APIsStatic Analysis
Transformor
Regex
CustomValidationorError Checks
Limited!Flexible!
IDE pluginsStatic AnalysisOpen Compilers
07.05.2010
16
DifferentRepresentations
andProjections
Limited!Flexible!
Text is TextCode FoldingTree ViewsVisualizations
Limited!Flexible?
Python-to-C-likeInternal DSLs
Mixingand
ComposingLanguages
Embed-As-StringSpecific: LINQ
07.05.2010
17
Mature!Brittle!
IDE Support
Scalable
Modeling Tools…!?
Usable
Mature!Brittle!
Testing
Debugging
?
Refactoring
07.05.2010
18
Mature!Brittle!
Branching
VersioningDiff, Merge
for some tools…
Gets theGets some
some people doubt that…
Job Done!Jobs done.everybody agrees…
07.05.2010
22
modeling ==programming
… at different levels of abstraction
… from different viewpoints
… integrated!
modeling ==programming
07.05.2010
23
… with different degrees of
… with suitable notations
… with suitable expressiveness
domain-specificity
modeling ==programming
precise and tool processableAnd always:
modeling ==programming
07.05.2010
25
LanguageWorkbench
(Martin Fowler)
Freely
define
integratethem
languages and
?
LanguageWorkbench
(Martin Fowler)
usepersistent
abstractrepresentation
07.05.2010
26
LanguageWorkbench
(Martin Fowler)
language ::=
schemaeditors
generators+
+
?
LanguageWorkbench
(Martin Fowler)
editingprojectional
07.05.2010
27
LanguageWorkbench
(Martin Fowler)
persist
incomplete
contradictoryinformation
or
LanguageWorkbench
(Martin Fowler)
powerful
editingtesting
refactoringdebugging
language definition
IDE definitionimplies
+groupware
07.05.2010
28
LanguageWorkbench
(Martin Fowler)
support for„classical“
programming„classical“
modelingand
+
07.05.2010
30
Syntaxprimarilytextual
sometimesbox&line style
When a graphicalnotation
is better, you can
visualize.
07.05.2010
32
Modeling as Programmig
… (Mostly) Textual Notations
… Concrete Syntax Storage
… (Fancy) ASCII Editors
… Read-Only Visualizations
Custom Syntax
GraphicalTextualSymbolic++
07.05.2010
33
IDESupport
TeamworkDebuggingCustom Editors
CompleteSymbolicIntegration
Goto DefFind RefsRefactoring
07.05.2010
34
InfrastructureIntegration
… diff/merge with existing tools
… existing text tools work well!
… storage is text
Language
CompositionGrammar composition with
traditional parsers is tough!
More advanced parserscurrently resarch
07.05.2010
35
UnicodeLimited to
how to handlenon-character symbols
TextGraphics !=
two worlds…
separate editors… per syntax/viewpoint… models can still be ref integrated
07.05.2010
39
Syntax ColoringCustom Keyword Coloring
Xtext: Generated Editor
Realtime ConstraintValidation
Xtext: Generated Editor
07.05.2010
41
Goto Definition Find ReferencesCross-File ReferencesModel as EMF
Xtext: Generated Editor
07.05.2010
44
Projectionaltree… to text-lookalike (editor)… to other trees … **+… to text
Programming as Modeling
… (Mostly) GraphicalNotations
… Abstract Syntax Storage
… Projecting Editors
… Different editableviews for model
07.05.2010
45
Programming as Modeling
… (Mostly) Graphical Any kind ofNotations
… Abstract Syntax Storage
… Projecting Editors
… Different editableviews for model
Language
There‘s no parsing.
Unique Language Element Identity.
Unlimted language composition.
Composition
07.05.2010
46
Textual
Graphical
Semi-Graphical
treated the same
can be mixed
like ASCII }box & line
mathematical
Flexible
Notations
Automatic
IDE Extensiontool support is inherent
for languages build withprojectional tools
language definition
IDE definitionimplies
07.05.2010
47
MultipleNotations
… for the same concepts
e.g. in different contextsor for different tasks
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
07.05.2010
48
InfrastructureIntegration
… diff/merge must be in tool
… existing text tools don‘t work
… storage is not text
ProprietaryTools
… no interop
… no standards
07.05.2010
50
Build new standalone DSLs
Build new standalone DSLsBuild DSLs that reuse parts
of other languages
07.05.2010
51
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++
07.05.2010
52
Java + Extension
Language Extension Example
Java
ReadWriteLock l = …
l.readLock().lock();
try {
//code
} finally {
l.readLock().unlock();
}
Java + Extension
Language Extension Example
Old
07.05.2010
53
Java
ReadWriteLock l = …
l.readLock().lock();
try {
//code
} finally {
l.readLock().unlock();
}
Java + Extension
ReadWriteLock l = …
lock (l) {
//code
}
Language Extension Example
Old New
07.05.2010
58
Structure Editor Typesystem Generator
Language Extension ExampleResult behaves like a native
base language construct
07.05.2010
59
Language Extension ExampleResult behaves like a native
base language construct
Language Extension ExampleTranslated to regular Java code
based 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; }
}
Top Related