programmierung programming und modellierung and · pdf filexml yaml css json jee wpf rails...

32
10.11.2009 1 Programmierung Modellierung und Zwei Welten? Markus Voelter Independent/itemis [email protected] Programming Modeling and Two Worlds? Markus Voelter Independent/itemis [email protected]

Upload: doanliem

Post on 09-Mar-2018

235 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

1

ProgrammierungModellierung

und

Zwei Welten?

Markus VoelterIndependent/itemis

[email protected]

ProgrammingModeling

and

Two Worlds?

Markus VoelterIndependent/itemis

[email protected]

Page 2: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

2

Programming Languages

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

Programming Languagesare not

enough.expressive

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

Programming Languagesare not

enough.high-level

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

Page 3: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

3

Programming Languagesare not

enough.abstract

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

Programming Languagesare not

enough.domain-specific

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

Programming Languagesare notenough.

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

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

Programming LanguagesFormats

C# C++

JavaPython

GroovyRuby

Erlang

CFortran

HTML

XMLCSSyaml

json

JEEWPF

Rails

Django

JMS

lift

Frameworksare not enough.

Page 4: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

4

So?

Modeling… Higher Level

… Domain Specific

Interpretation… Code Generation

Concepts & Notations

Solves theProblem!

DSLgeneral purpose

domain specific

effective++

specialized, limited

used by experts

together with otherspecialized tools

tailor made

Page 5: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

5

But:Modeling Tools

Programming Tools!=

Different Worlds

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?

Page 6: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

6

History?

Whythe difference?

It is time for … … a Different Perspective

Modeling Programming

Programming Modeling

====

modeling ==programming

Page 7: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

7

… at different levels of abstraction

… from different viewpoints

… integrated!

modeling ==programming

… with different degrees of

… with suitable notations

… with suitable expressiveness

domain-specificity

modeling ==programming

precise and tool processableAnd always:

modeling ==programming

LanguageWorkbench

(Martin Fowler)

LanguageWorkbench

(Martin Fowler)

Freely

define

integratethem

languages and

Page 8: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

8

?

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

LanguageWorkbench

(Martin Fowler)

support for„classical“

programming„classical“

modelingand

+

Page 9: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

9

Syntaxprimarilytextual

Syntaxprimarilytextual

with more symbolsthink: mathematics

Syntaxprimarilytextual

sometimesbox&line style

When a graphicalnotation

is better, you can

visualize.

Page 10: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

10

AvailableTooling

Eclipse

Xtext

Modeling as Programmig

… (Mostly) Textual Notations

… Concrete Syntax Storage

… (Fancy) ASCII Editors

… Read-Only Visualizations

Custom Syntax

GraphicalTextualSymbolic++

IDESupport

TeamworkDebuggingCustom Editors

CompleteSymbolicIntegration

Goto DefFind RefsRefactoring

InfrastructureIntegration

… diff/merge with existing tools

… existing text work well!

… storage not text

Page 11: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

11

Language

CompositionGrammar composition with

traditional parsers is tough!

More advanced parserscurrently resarch

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 http://eclipse.org/xtext

Page 12: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

12

Xtext: Specify Grammar Xtext: Generated Editor

Code Completion

Xtext: Generated Editor

Syntax ColoringCustom Keyword Coloring

Xtext: Generated Editor

Realtime ConstraintValidation

Xtext: Generated Editor

CustomizableOutlines

Xtext: Generated Editor

Page 13: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

13

Code Folding

Xtext: Generated Editor

Goto Definition Find ReferencesCross-File ReferencesModel as EMF

Xtext: Generated Editor

DEMO I

Building DSLs with Eclipse Xtext

AvailableTooling

Jetbrains‘

ProgrammingMeta

System

Page 14: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

14

Parser-basedtext… to tree… to text

Projectionaltree… to text-lookalike (editor)… to other trees … **+… to text

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

Language

There‘s no parsing.

Unique Language Element Identity.

Unlimted language composition.

CompositionTextual

Graphical

Semi-Graphical

treated the same

can be mixed

like ASCII }box & line

mathematical

Flexible

Notations

Page 15: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

15

Automatic

IDE Extensiontool support is inherent

for languages build withprojectional tools

language definition

IDE definitionimplies

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

InfrastructureIntegration

… diff/merge must be in tool

… existing text tools don‘t work

… storage is not text

ProprietaryTools

… no interop

… no standards

Page 16: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

16

Apache 2.0licensed under

Q2 2009released in

1.1 RC1currently

Build new standalone DSLs

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++

Java + Extension

Language Extension Example

Page 17: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

17

Java

ReadWriteLock l = …

l.readLock().lock();

try {

//code

} finally {

l.readLock().unlock();

}

Java + Extension

Language Extension Example

Old Java

ReadWriteLock l = …

l.readLock().lock();

try {

//code

} finally {

l.readLock().unlock();

}

Java + Extension

ReadWriteLock l = …

lock (l) {

//code

}

Language Extension Example

Old New

Structure Editor Typesystem Generator

Structure Editor Typesystem Generator Structure Editor Typesystem Generator

Page 18: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

18

Structure Editor Typesystem Generator Structure Editor Typesystem Generator

Structure Editor Typesystem Generator Structure Editor Typesystem Generator

Structure Editor Typesystem Generator Structure Editor Typesystem Generator

Page 19: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

19

Language Extension ExampleResult behaves like a native

base language construct

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; }

}

DEMO II

Building DSLs with JetBrains MPS

Page 20: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

20

A vision forProgramming

Programming Languages

are not

enough.MODULAR

Programming Languages

are not

enough.COMPOSABLE

Programming Languages

are not

enough.CONFIGURABLE

Programming Languages

are not

enough.ADAPTABLE

Programming Language Syntax

is not

enough.FLEXIBLE

Page 21: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

21

L

ab

c

d

e

f

gh

i

j

k

m

n

o

with many first class concepts!

Big Language?

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

Page 22: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

22

Not a new idea…

Growing A Language(Guy L Steele)

Page 23: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

23

Example Languages

Page 24: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

24

Page 25: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

25

Page 26: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

26

Page 27: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

27

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

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?

Page 28: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

28

Better Solution

Better Solution

types

matrixgeneric

vectorand

Better Solution

matrixreal

literalsvector

and

Better Solution

highlightssyntax

vectorsfor

and

matrices

Better Solution

operatoroverloading

Page 29: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

29

Better Solution

operatoroverloading

staticoptimization… symmetrical matrices… identity matrix… diagonal matrices

Better Solution

mathnotation

Better Solution

used only bythose who

separatea

modulelanguage

really need it

AvailableTooling

Intentional SoftwareDomain

Workbench

Page 30: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

30

CommercialProduct

Eval availableupon request

Eval availableupon request

Pension Workbench Example

Text Editing Domain

Pension Workbench Example

Insurance Mathematics Domain

Pension Workbench Example

Pension Contract Rules Domain

Pension Workbench Example

All in one Document

Page 31: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

31

Pension Workbench Example

Symbolically integrated

THE END.

web email skypetwitter

xinglinkedin

[email protected]@markusvoelter

http://www.xing.com/profile/Markus_Voelterhttp://www.linkedin.com/pub/0/377/a31

.coordinates

THE END.

web email skypetwitter

xinglinkedin

[email protected]@markusvoelter

http://www.xing.com/profile/Markus_Voelterhttp://www.linkedin.com/pub/0/377/a31

.coordinatesweb email skypetwitter

xinglinkedin

[email protected]@markusvoelter

http://www.xing.com/profile/Markus_Voelterhttp://www.linkedin.com/pub/0/377/a31

.coordinates

Page 32: Programmierung Programming und Modellierung and  · PDF fileXML yaml CSS json JEE WPF Rails Django JMS lift Frameworks Programming Languages Formats C# C++ Java Python ... Xtext

10.11.2009

32

web email skypetwitter

xinglinkedin

[email protected]@markusvoelter

http://www.xing.com/profile/Markus_Voelterhttp://www.linkedin.com/pub/0/377/a31

.coordinates