Your SlideShare is downloading. ×
0
MPS

Are you talking my language?
Václav Pech
Future
Code orchestra
mbeddr
YouTrack
Karel
High thoughts must have high language.
Aristophanes
DSL
A DSL is a focussed, processable language for describing a
specific concern when building a system in a specific domai...
Cypher for Neo4j
START john=node:node_auto_index(name = 'John')
MATCH john-[:friend]->()-[:friend]->fof
RETURN john, fof

...
Grails
Customer.findAllByNameAndAgeBetween('Joe', 20, 40)
class Phone {
....
static belongsTo = [owner : Person]
}
Spock (Groovy)
class DataDriven extends Specification {
def "maximum of two numbers"() {
expect:
Math.max(a, b) == c
where...
JMock
context.checking(new Expectations() {{
oneOf (clock).time(); will(returnValue(loadTime));
oneOf (clock).time(); will...
DSLs with the benefits of General Purpose Langs
Abstract Syntax Tree
Abstract Syntax Tree
Programs are trees
R
Models composed of nodes
A

B

C

E

D

F

G
Programs are trees
R

A

IfStatement
condition
Expr

E

body
StmtList

F

G
References cross the tree
R

A

B

C

E

D

F

G
Languages are sets of concepts

C1
L

Cn
C2

C3
Programs and Languages
C1

Cn

R
L
A

C2

Meta-models consist of concepts

B

C

E

C3

D

F

Models consist of nodes

G
Programs and Languages
WhileLoop

MethodDef

R
L
A

IfStatement
Meta-models consist of concepts

B

C

E

MethodCall

D

F...
Concept inheritance
C1
C2

L1

C3

C4
L2

C5
Domain Hierarchy

D2.1.1 D2.1.2

...

D2.2.1 D2.2.2

D1.1

D1.2

D0

More specialized domains
More specialized languages

...
Language modularization

Categorization proposed by Markus Voelter, http://http://voelter.de/
Projectional editor
The coding experience is different (better :)

Cooperate with the existing text tool-chain
Non-parseable notations
Multiple projections
Language combinations
Language combinations
Making Java in MPS better
Collections
cities.where({~it => it.startsWith("P"); })
.select({~it => it.toUpperCase(); })

cities.any({~it => it.size()...
Closures
{int => long} fact = {int n =>
if (n == 1) {
return 1L;
} else {
return n * invoke(n - 1);
}
};
Date/Time
datetime start = now in (Europe/Berlin);
......
period processingTime = now in (Europe/Berlin) – start;

datetim...
And a lot more
Tuples
Regular expressions
Builders
XML processing
Unit testing
Custom operators
And others ...
Java-MPS interoperability
Java into MPS
Integrate Java sources
Import Java sources
Import a library
Paste Java code snippe...
Java-MPS interoperability
MPS into Java
Generate into a Java project
IDE plugin
Java IDE integration
Design DSLs in MPS
Use them in
–
–
–
–

IntelliJ IDEA
Standalone IDE (on IntelliJ platform)
Web
Eclip...
Aspects of language definition
●

Abstract syntax

●

Concrete syntax (editor)

●

Static semantics
●

Constraints

●

Typ...
Aspects of language definition
●

Abstract syntax

●

Concrete syntax (editor)

●

Static semantics
●

Constraints

●

Typ...
Example: Range Iterator
Structure
Statement
Integration points
Statement
Integration points

Expression
numberOfIterations
Integration points

Expression
numberOfIterations
StatementList
body
Integration points

Expression
numberOfIterations
StatementList
body
Structure
Define the abstract syntax
new concepts for nodes to use in the AST
Structure
Define the abstract syntax
new concepts for nodes to use in the AST
Aspects of language definition
●

Abstract syntax

●

Concrete syntax (editor)

●

Static semantics
●

Constraints

●

Typ...
Editor
Define the concrete syntax
the projection on the screen
Styling the editor
Aspects of language definition
●

Abstract syntax

●

Concrete syntax (editor)

●

Static semantics
●

Constraints

●

Typ...
Code generation

Java source
Code generation

MPS BaseLang
Text generation
Java source
Code generation

Closures

Date/Time

Model to model transformation
MPS BaseLang
Text generation
Java source
Code generation
Custom 2
Custom 1
Model to model transformation
Closures

Date/Time

Model to model transformation
MPS Bas...
Generator
Transform the new concept into BaseLanguage
mbeddr.com
What to expect?
Graphical notations
Web-base editor
Eclipse integration

… and a lot more
Grasp the subject, the words will follow.
Cato the Elder
Questions

Want more?
http://www.jetbrains.com/mps
http://jetbrains.dzone.com
vaclav@jetbrains.com
Image credits
http://www.flickr.com/photos/horiavarlan/4329908160/sizes/m/in/photostream/
http://www.flickr.com/photos/pin...
Concepts of JetBrains MPS
Concepts of JetBrains MPS
Upcoming SlideShare
Loading in...5
×

Concepts of JetBrains MPS

920

Published on

An introductory presentation in JetBrains MPS

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
920
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Ruby on Rails as a DSL success story
    Spring dynamically loading generated Groovy (Ruby)
    YouTrack + other projects building on MPS
  • Transcript of "Concepts of JetBrains MPS"

    1. 1. MPS Are you talking my language? Václav Pech
    2. 2. Future
    3. 3. Code orchestra
    4. 4. mbeddr
    5. 5. YouTrack
    6. 6. Karel
    7. 7. High thoughts must have high language. Aristophanes
    8. 8. DSL A DSL is a focussed, processable language for describing a specific concern when building a system in a specific domain. The abstractions and notations used are natural/suitable for the stakeholders who specify that particular concern. Markus Voelter
    9. 9. Cypher for Neo4j START john=node:node_auto_index(name = 'John') MATCH john-[:friend]->()-[:friend]->fof RETURN john, fof http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html
    10. 10. Grails Customer.findAllByNameAndAgeBetween('Joe', 20, 40) class Phone { .... static belongsTo = [owner : Person] }
    11. 11. Spock (Groovy) class DataDriven extends Specification { def "maximum of two numbers"() { expect: Math.max(a, b) == c where: a|b|c 7|3|7 4|5|5 9|9|9 }} http://code.google.com/p/spock/
    12. 12. JMock context.checking(new Expectations() {{ oneOf (clock).time(); will(returnValue(loadTime)); oneOf (clock).time(); will(returnValue(fetchTime)); allowing (reloadPolicy).shouldReload(loadTime, fetchTime); will(returnValue(false)); }}); http://www.jmock.org/expectations.html
    13. 13. DSLs with the benefits of General Purpose Langs
    14. 14. Abstract Syntax Tree
    15. 15. Abstract Syntax Tree
    16. 16. Programs are trees R Models composed of nodes A B C E D F G
    17. 17. Programs are trees R A IfStatement condition Expr E body StmtList F G
    18. 18. References cross the tree R A B C E D F G
    19. 19. Languages are sets of concepts C1 L Cn C2 C3
    20. 20. Programs and Languages C1 Cn R L A C2 Meta-models consist of concepts B C E C3 D F Models consist of nodes G
    21. 21. Programs and Languages WhileLoop MethodDef R L A IfStatement Meta-models consist of concepts B C E MethodCall D F Models consist of nodes G
    22. 22. Concept inheritance C1 C2 L1 C3 C4 L2 C5
    23. 23. Domain Hierarchy D2.1.1 D2.1.2 ... D2.2.1 D2.2.2 D1.1 D1.2 D0 More specialized domains More specialized languages ...
    24. 24. Language modularization Categorization proposed by Markus Voelter, http://http://voelter.de/
    25. 25. Projectional editor The coding experience is different (better :) Cooperate with the existing text tool-chain
    26. 26. Non-parseable notations
    27. 27. Multiple projections
    28. 28. Language combinations
    29. 29. Language combinations
    30. 30. Making Java in MPS better
    31. 31. Collections cities.where({~it => it.startsWith("P"); }) .select({~it => it.toUpperCase(); }) cities.any({~it => it.size() > populationLimit; })
    32. 32. Closures {int => long} fact = {int n => if (n == 1) { return 1L; } else { return n * invoke(n - 1); } };
    33. 33. Date/Time datetime start = now in (Europe/Berlin); ...... period processingTime = now in (Europe/Berlin) – start; datetime meeting = now in (GMT) + 2 days with (hours = 11) with (minutes = 0) with (seconds = 0)
    34. 34. And a lot more Tuples Regular expressions Builders XML processing Unit testing Custom operators And others ...
    35. 35. Java-MPS interoperability Java into MPS Integrate Java sources Import Java sources Import a library Paste Java code snippets
    36. 36. Java-MPS interoperability MPS into Java Generate into a Java project IDE plugin
    37. 37. Java IDE integration Design DSLs in MPS Use them in – – – – IntelliJ IDEA Standalone IDE (on IntelliJ platform) Web Eclipse
    38. 38. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
    39. 39. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
    40. 40. Example: Range Iterator
    41. 41. Structure Statement
    42. 42. Integration points Statement
    43. 43. Integration points Expression numberOfIterations
    44. 44. Integration points Expression numberOfIterations StatementList body
    45. 45. Integration points Expression numberOfIterations StatementList body
    46. 46. Structure Define the abstract syntax new concepts for nodes to use in the AST
    47. 47. Structure Define the abstract syntax new concepts for nodes to use in the AST
    48. 48. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
    49. 49. Editor Define the concrete syntax the projection on the screen
    50. 50. Styling the editor
    51. 51. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
    52. 52. Code generation Java source
    53. 53. Code generation MPS BaseLang Text generation Java source
    54. 54. Code generation Closures Date/Time Model to model transformation MPS BaseLang Text generation Java source
    55. 55. Code generation Custom 2 Custom 1 Model to model transformation Closures Date/Time Model to model transformation MPS BaseLang Text generation Java source
    56. 56. Generator Transform the new concept into BaseLanguage
    57. 57. mbeddr.com
    58. 58. What to expect? Graphical notations Web-base editor Eclipse integration … and a lot more
    59. 59. Grasp the subject, the words will follow. Cato the Elder
    60. 60. Questions Want more? http://www.jetbrains.com/mps http://jetbrains.dzone.com vaclav@jetbrains.com
    61. 61. 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/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×