Concepts of JetBrains MPS

  • 712 views
Uploaded on

An introductory presentation in JetBrains MPS

An introductory presentation in JetBrains MPS

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
712
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    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

  • 1. MPS Are you talking my language? Václav Pech
  • 2. Future
  • 3. Code orchestra
  • 4. mbeddr
  • 5. YouTrack
  • 6. Karel
  • 7. High thoughts must have high language. Aristophanes
  • 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. 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. Grails Customer.findAllByNameAndAgeBetween('Joe', 20, 40) class Phone { .... static belongsTo = [owner : Person] }
  • 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. 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. DSLs with the benefits of General Purpose Langs
  • 14. Abstract Syntax Tree
  • 15. Abstract Syntax Tree
  • 16. Programs are trees R Models composed of nodes A B C E D F G
  • 17. Programs are trees R A IfStatement condition Expr E body StmtList F G
  • 18. References cross the tree R A B C E D F G
  • 19. Languages are sets of concepts C1 L Cn C2 C3
  • 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. 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. Concept inheritance C1 C2 L1 C3 C4 L2 C5
  • 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. Language modularization Categorization proposed by Markus Voelter, http://http://voelter.de/
  • 25. Projectional editor The coding experience is different (better :) Cooperate with the existing text tool-chain
  • 26. Non-parseable notations
  • 27. Multiple projections
  • 28. Language combinations
  • 29. Language combinations
  • 30. Making Java in MPS better
  • 31. Collections cities.where({~it => it.startsWith("P"); }) .select({~it => it.toUpperCase(); }) cities.any({~it => it.size() > populationLimit; })
  • 32. Closures {int => long} fact = {int n => if (n == 1) { return 1L; } else { return n * invoke(n - 1); } };
  • 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. And a lot more Tuples Regular expressions Builders XML processing Unit testing Custom operators And others ...
  • 35. Java-MPS interoperability Java into MPS Integrate Java sources Import Java sources Import a library Paste Java code snippets
  • 36. Java-MPS interoperability MPS into Java Generate into a Java project IDE plugin
  • 37. Java IDE integration Design DSLs in MPS Use them in – – – – IntelliJ IDEA Standalone IDE (on IntelliJ platform) Web Eclipse
  • 38. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
  • 39. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
  • 40. Example: Range Iterator
  • 41. Structure Statement
  • 42. Integration points Statement
  • 43. Integration points Expression numberOfIterations
  • 44. Integration points Expression numberOfIterations StatementList body
  • 45. Integration points Expression numberOfIterations StatementList body
  • 46. Structure Define the abstract syntax new concepts for nodes to use in the AST
  • 47. Structure Define the abstract syntax new concepts for nodes to use in the AST
  • 48. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
  • 49. Editor Define the concrete syntax the projection on the screen
  • 50. Styling the editor
  • 51. Aspects of language definition ● Abstract syntax ● Concrete syntax (editor) ● Static semantics ● Constraints ● Type-system ● Dataflow ● Execution semantics / Generator ● IDE support
  • 52. Code generation Java source
  • 53. Code generation MPS BaseLang Text generation Java source
  • 54. Code generation Closures Date/Time Model to model transformation MPS BaseLang Text generation Java source
  • 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. Generator Transform the new concept into BaseLanguage
  • 57. mbeddr.com
  • 58. What to expect? Graphical notations Web-base editor Eclipse integration … and a lot more
  • 59. Grasp the subject, the words will follow. Cato the Elder
  • 60. Questions Want more? http://www.jetbrains.com/mps http://jetbrains.dzone.com vaclav@jetbrains.com
  • 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/