concepts of jetbrains mps

Download Concepts of JetBrains MPS

If you can't read please download the document

Upload: vaclav-pech

Post on 16-Apr-2017

1.716 views

Category:

Technology


0 download

TRANSCRIPT

MPS

Are you talking my language?

Vclav Pech

Ruby on Rails as a DSL success storySpring dynamically loading generated Groovy (Ruby)YouTrack + other projects building on MPS

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 domain.

The abstractions and notations used are natural/suitable for the stakeholders who specify that particular concern.

Markus Voelter

Cypher for Neo4j

START john=node:node_auto_index(name = 'John')MATCH john-[:friend]->()-[:friend]->fofRETURN john, fof

http://docs.neo4j.org/chunked/milestone/cypher-query-lang.html

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: a | b | c

7 | 3 | 7 4 | 5 | 5 9 | 9 | 9 } } http://code.google.com/p/spock/

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

DSLs with the benefits of General Purpose Langs

Abstract Syntax Tree

Abstract Syntax Tree

Programs are trees

RABCDGREF

Models composed of nodes

Programs are trees

RAIfStatementExprStmtListGREF

condition

body

References cross the tree

RABCDGREF

Languages are sets of concepts

C1

C2

C3

Cn

L

Programs and Languages

RABCDGREF

C1

C2

C3

Cn

L

Models consist of nodes

Meta-models consist of concepts

Programs and Languages

RABCDGREF

WhileLoop

MethodDef

MethodCall

L

IfStatement

Models consist of nodes

Meta-models consist of concepts

Concept inheritance

C1

C2

C3

L1

C4

C5

L2

Domain Hierarchy

D0D1.1D1.2D2.1.1D2.1.2...

D2.2.1D2.2.2...

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() > populationLimit; })

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;

datetime meeting = now in (GMT) + 2 days with (hours = 11) with (minutes = 0) with (seconds = 0)

And a lot more

TuplesRegular expressionsBuildersXML processingUnit testingCustom operatorsAnd others ...

Java-MPS interoperability

Java into MPSIntegrate Java sourcesImport Java sourcesImport a libraryPaste Java code snippets

Java-MPS interoperability

MPS into JavaGenerate into a Java projectIDE plugin

Java IDE integration

Design DSLs in MPS

Use them in IntelliJ IDEA

Standalone IDE (on IntelliJ platform)

Web

Eclipse

Aspects of language definition

Abstract syntax

Concrete syntax (editor)

Static semanticsConstraints

Type-system

Dataflow

Execution semantics / Generator

IDE support

Aspects of language definition

Abstract syntax

Concrete syntax (editor)

Static semanticsConstraints

Type-system

Dataflow

Execution semantics / Generator

IDE support

Example: Range Iterator

Structure

Statement

Integration points

Statement

Integration points

ExpressionnumberOfIterations

Integration points

ExpressionnumberOfIterations

StatementListbody

Integration points

ExpressionnumberOfIterations

StatementListbody

Structure

Define the abstract syntaxnew concepts for nodes to use in the AST

Structure

Define the abstract syntaxnew concepts for nodes to use in the AST

Aspects of language definition

Abstract syntax

Concrete syntax (editor)

Static semanticsConstraints

Type-system

Dataflow

Execution semantics / Generator

IDE support

Editor

Define the concrete syntax the projection on the screen

Styling the editor

Aspects of language definition

Abstract syntax

Concrete syntax (editor)

Static semanticsConstraints

Type-system

Dataflow

Execution semantics / Generator

IDE support

Code generation

Java source

Java sourceMPS BaseLang

Text generation

Code generation

Java sourceMPS BaseLang

Text generation

Model to model transformation

ClosuresDate/Time

Code generation

Java sourceMPS BaseLang

Text generation

ClosuresDate/Time

Model to model transformation

Custom 2Custom 1

Model to model transformation

Code generation

Generator

Transform the new concept into BaseLanguage

mbeddr.com

What to expect?

Graphical notationsWeb-base editorEclipse integration

and a lot more

Grasp the subject, the words will follow. Cato the Elder

Questions

Want more? http://www.jetbrains.com/mpshttp://[email protected]

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/