Domain Specific Language with pleasure

44
MPS Domain Specific Languages with pleasure Václav Pech

Transcript of Domain Specific Language with pleasure

Page 1: Domain Specific Language with pleasure

MPS

Domain Specific Languageswith pleasure

Václav Pech

Page 2: Domain Specific Language with pleasure

JetBrains MPS

High thoughts must have high language.

Aristophanes

Page 3: Domain Specific Language with pleasure

Your vocabulary reflects the way you thinkSeth Godin

Page 4: Domain Specific Language with pleasure

[Embedded Software]mbeddr

Page 5: Domain Specific Language with pleasure

[Data analysis]MetaR

Page 6: Domain Specific Language with pleasure

[Business Application]Insurance Configuration Tool

Page 7: Domain Specific Language with pleasure

[Business Application]Insurance Configuration Tool

Page 8: Domain Specific Language with pleasure

<no variables> <no parent>

<no libraries>

<no business objects>

<no parent>

[Business Application]Insurance Configuration Tool

Page 9: Domain Specific Language with pleasure

Notations for DSLs

● Text● Diagrams● Tables● Forms● Mixtures of all● …

Page 10: Domain Specific Language with pleasure

The number and the type of the basic colour words of a language determine how one sees the rain bow

Page 11: Domain Specific Language with pleasure

Programs are trees

R

A B

C D

G

R

E F

Page 12: Domain Specific Language with pleasure

Programs are trees

R

A B

C D

G

R

E F

Page 13: Domain Specific Language with pleasure
Page 14: Domain Specific Language with pleasure
Page 15: Domain Specific Language with pleasure

Children have roles

R

A IfStatement

Expr StmtList

G

R

E F

condition body

Page 16: Domain Specific Language with pleasure

References cross the tree

R

Routine def B

Call D

G

R

E F

Page 17: Domain Specific Language with pleasure

Languages are sets of concepts

C1

C2C3

Cn

L1

L2

Page 18: Domain Specific Language with pleasure
Page 19: Domain Specific Language with pleasure
Page 20: Domain Specific Language with pleasure

Programs and Languages

R

A B

C D

G

R

E F

C1

C2C3

Cn

L

Models consist of nodes

Meta-models consist of concepts

Page 21: Domain Specific Language with pleasure

IntelliJ IDEA inspections

Page 22: Domain Specific Language with pleasure

Groovy AST transformations

Page 23: Domain Specific Language with pleasure

Groovy AST transformations

Page 24: Domain Specific Language with pleasure
Page 25: Domain Specific Language with pleasure
Page 26: Domain Specific Language with pleasure

There's no life without trees

● Extending IDEs● External DSLs● Internal DSLs in modern languages

● Groovy AST transformations● Scala macros● Lisp, Clojure macros● Lombok

Page 27: Domain Specific Language with pleasure

Notations for DSLs

● Text● Diagrams● Tables● Forms● Mixtures of all● …

Page 28: Domain Specific Language with pleasure

Parsing is the bottleneck

… of language expressiveness

Page 29: Domain Specific Language with pleasure

Editing text

Parsing

Page 30: Domain Specific Language with pleasure

Programs are trees

R

A B

C D

G

R

E F

WhileLoop

MethodDef

MethodCall

L IfStatement

Models consist of nodes

Meta-models consist of concepts

Page 31: Domain Specific Language with pleasure

Editing trees directly

Projecting

Page 32: Domain Specific Language with pleasure
Page 33: Domain Specific Language with pleasure
Page 34: Domain Specific Language with pleasure
Page 35: Domain Specific Language with pleasure

by Jens Nerche @jensnerche

Rich syntaxes

Page 36: Domain Specific Language with pleasure

Combine languages

Page 37: Domain Specific Language with pleasure

Multiple notations

Page 38: Domain Specific Language with pleasure

Parsing is the bottleneck

… of language expressiveness

● Limits the possible syntaxes● Allows only one editable code visualization● Complicates combining languages

Page 39: Domain Specific Language with pleasure

Aspects of language definition

● Abstract syntax● Concrete syntax (editor)● Static semantics

● Constraints● Type-system● Dataflow

● Execution semantics / Generator● IDE support

Page 40: Domain Specific Language with pleasure

Books

● http://books.campagnelab.org

● http://dslbook.org

https://www.jetbrains.com/mps/publications

Page 41: Domain Specific Language with pleasure

Books

● http://books.campagnelab.org

● http://dslbook.org

← He is a Biologist!

https://www.jetbrains.com/mps/publications

Page 42: Domain Specific Language with pleasure

The limits of language are the limits of one's worldLudwig Wittgenstein

Page 43: Domain Specific Language with pleasure

Questions

Want more?

http://www.jetbrains.com/mps

@vaclav_pech

Page 44: Domain Specific Language with pleasure

Image credits

http://www.flickr.com/photos/horiavarlan/4329908160/sizes/m/in/photostream/

http://www.flickr.com/photos/pink_floyd/2409134519/sizes/m/in/photostream/

http://www.flickr.com/photos/atache/4124732863/sizes/m/in/photostream/

http://www.flickr.com/photos/a_ninjamonkey/3294014627/sizes/m/in/photostream/

http://www.flickr.com/photos/carlc/1968636137/

http://www.flickr.com/photos/tasuki/3503304405/sizes/m/in/photostream/

http://www.flickr.com/photos/bmwccgb/5069454884/sizes/m/in/photostream/

http://www.flickr.com/photos/rpmarks/3932013183/sizes/m/in/photostream/

http://www.flickr.com/photos/orqwith/4325166853/

https://www.flickr.com/photos/charlestilford/732688216