Download presentation
Presentation is loading. Please wait.
Published byAmie Lilian Black Modified over 9 years ago
1
1 Extending Java And Developing DSLs With Open Source Language Workbench JetBrains MPS Konstantin Solomatov JetBrains Lead Developer for JetBrains MPS Project
2
Agenda Extending languages. Why bother? Problems and solutions Composability Language support MPS’ approach Idea behind it Hands-on demo MPS & domain-specific languages 2
3
Why Bother? Specific domains = specific entities Drawbacks of general-purpose languages: Limited set of generic constructs Domains are described too verbosely Low code maintainability Domain-specific extensions Higher abstraction level Higher maintainability 3
4
Implicit Language Extensions Domain-specific constructs in Java: synchronized block in Java enhanced for in Java typesafe enums in Java Desired constructs: closures yield better support for regexps whatever else you are missing 4
5
Language Extensions Existing extensions Cover domain-specific needs Are built into existing languages Further extensions Hard to integrate Too long to wait until JCP accepts them Risks of incompatibility 5
6
MPS DEMO Closure & UI Language samples. 6
7
Agenda Extending Languages. Why bother? Problems and Solutions Composability Language support MPS’ Approach Idea behind it Hands-on Demo MPS & Domain-Specific Languages 7
8
Composability Definition: Components are composable when they can be used together even if created by different parties 8
9
Composability Desired Goal Java Libraries Hibernate Spring Joda Time Java Extensions DB Language DI Language Dates Language 9
10
Composability Libraries vs. Extensions Libraries are composable: Java + Hibernate=> OK Java + Spring => OK Java + Hibernate, Spring=> OK Language extensions are not Java + extension A => OK Java + extension B => OK Java + extensions A, B=> possible ambiguity 10
11
Composability Grammar Ambiguity Sample With String Interpolation Extension “A”: int resultsCount = ; string s = “Found ${resultCount} results”; Extension “B”: int resultCount = ; string t = “Found {resultCount} results”; “A” + “B” => ambiguity for the compiler: string a = “Account balance is ${balance}”; 11
12
Language Support Requirements Generic infrastructure Abstract grammar Type system Compiler Etc. IDE infrastructure Editor Error highlighting Refactoring Version control Etc. 12
13
Language Support Problems Time- and resource-consuming task Complicated algorithms for processing code Highly qualified developers required Resulting infrastructure composability Type systems to be compatible with different extensions Refactorings should support potential extensions Etc. 13
14
Existing Solutions Pros & Cons Composability Language Infrastructure LISPYesNo Internal DSLs in Ruby / Groovy YesNo XText FrameworkNoYes 14
15
Common Problem Existing solutions provide: Eithercomposable language extensions Ora decent infrastructure Not both 15
16
Agenda Extending Languages. Why bother? Problems and Solutions Composability Language support MPS’ Approach Idea behind it Hands-on Demo MPS & Domain-Specific Languages 16
17
Our Solution to the Problem JetBrains MPS Workbench for defining and extending languages IDE for new languages and extensions 17
18
Idea Behind It Text-based grammars lead to ambiguities Another approach needed MPS works with Abstract Syntax Tree directly 18
19
Idea Behind It Editing Abstract Syntax Tree Former attempts Diagram-based editing Limited domain of application MPS solution Keeps user in habitual environment Supports text-like editing 19
20
Idea Behind It Projectional Editor 20 Each node of a syntax tree has its projection in the MPS Editor
21
Idea Behind It Projectional Editor 21 Each node – in a dedicated cell A node is shown in its text/symbol representation Instantly synchronized editor and syntax tree
22
Idea Behind It Projection vs. Text Text-like projectional editor Has its pros & cons Reasonable learning curve: approx. 2 weeks 22
23
MPS DEMO Projectional editor in use. 23
24
Idea Behind It Language Support User-defined language infrastructure Abstract grammar Type system Editor Compiler Etc. Programming assistance Completion Find usages Rename Etc. 24
25
Idea Behind It Existing Languages & Extensions Java™ re-implemented with MPS + Extensions Collections language Dates language Closures language Regexp language Etc. Language definition languages Implemented with themselves i.e. bootstrapped Misc languages (XML, etc.) 25
26
Hands-On Demo Goal Java ReadWriteLock l = … l.readLock().lock(); try { //code } finally { l.readLock().unlock(); } Java + Extension ReadWriteLock l = … read (l) { //code } 26
27
Hands-On Demo Workflow We will define Structure Editor Typesystem Generator 27
28
MPS DEMO Adding lock statement to Java 28
29
Agenda Extending Languages. Why bother? Problems and Solutions Composability Language support MPS’ Approach Idea behind it Hands-on Demo MPS & Domain-Specific Languages 29
30
Domain-Specific Languages MPS suits nicely for creating DSLs Common language parts can be reused (e.g., expression language) You can embed general-purpose languages (e.g., Java) inside DSLs 30
31
Domain-Specific Languages Example 31
32
Existing Applications YouTrack – bug tracking system Completely developed with MPS Used internally Beta program Languages for Web Development DNQ Webr Spring language 32
33
Licensing/Pricing Almost fully open-sourced Apache 2.0 License MPS is absolutely FREE 33
34
Q & A 34
35
More info http://www.jetbrains.com/mpshttp://www.jetbrains.com/mps - MPS page http://blogs.jetbrains.com/mpshttp://blogs.jetbrains.com/mps - MPS blog 35
36
36 Konstantin Solomatov konstantin.solomatov@jetbrains.com Lead Developer for JetBrains MPS Project http://www.jetbrains.com/mps Thank You
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.