Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

The MPS Language Workbench

Talk for NYJavaSig meetup Oct 15 2014
by

Fabien Campagne

on 7 February 2015

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of The MPS Language Workbench

Traditional Programming
Languages
First high-order languages developed in the 50's (e.g., FORTRAN 1957, COBOL 1959)

Offer high-level abstractions: 1 line of FORTRAN ~ 20 lines of assembly language

Despite initial skepticism (it was a new idea at the time), they quickly displace assembly language for most applications

60 YEARS LATER...
There is a galaxy of programming languages

Thousands of languages

Great?
Not so much. Each language behaves like its own planet
Each planet is isolated from the others

Ideas move across very slowly
Java
C
Forth
Perl
Python
Erlang
Traditional
Programming
Languages rely on
compiler technology

Each language
has its own grammar

Used to generate
a language parser

Grammars cannot
easily be
combined
What's the problem?
Languages Are Not
Composable
For instance, consider
regexps in Java
Let's assume you need to use regular expressions (regexps)

You cannot modify the language itself, so you create an Application Programming Interface (API)

my ($hours, $minutes, $seconds) = ($time =~ m/(\d+):(\d+):(\d+)/);
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Pattern pattern = Pattern.compile("(\\d+):(\\d+):(\\d+)");
Matcher matcher = pattern.matcher(time);

if (matcher.matches()) {
hours = matcher.group(1);
minutes = matcher.group(2);
seconds = matcher.group(3);
}

(Perl)
(Java)
The result is verbose. Wouldn't you prefer to use the Perl regexp syntax, in Java as well?
Perl and Java are NOT
Composable
Using the same keyword in different language causes ambiguity and prevents from composing languages

In Perl, the
my
keyword declares local variables. Supporting this language construct in Java would conflict with the use of
my
as a variable (for instance)
(neither are any of the other languages you learned so far)
Storing programs as text was progress in the 50s

The alternative was


In 2014, it is keeping us back
The culprit:
We have stored programs as text since the 50s
Meet a Language Workbench
MPS Projectional Editor
Makes it possible to interact with the AST

First Release in 2006, Actively Developped and Maintained, Used by JetBrains to Build Commercial Applications
Get it at http://www.jetbrains.com/mps/,
Open Source (Apache 2.0)
Let's take an example:

MPS offers BaseLanguage (similar to Java 1.6)

Need to work with complex
numbers?

Let's define a 'complex'
language and compose it
with baseLanguage/Java

See the result to the right
Remember the regexp example?

MPS ships with a composable regexp language
What's
the big
deal?
For Programmers
For Language
Designers

Traditional
Languages

Composable
Languages !

For Software
Engineers

Applications
You get to choose which languages you need for each specific problem
Easier when you know what languages are available and what they can do
BaseLanguage
A composable language similar to Java 1.6

Ships with MPS

Generates to Pure Java 1.6
Closures
Brings Functional Programming to BaseLanguage
Collections
Sequence, Lists, Maps, etc.

Takes advantage of closures for Functional Programming Style (select, fold-left, foreach, etc.)
Tuples
XML
Regular
Expressions
Compose with BaseLanguage
BaseLanguage
Regexps
Closures
Collections
Tuples
Back to the galactic metaphor
Software Engineering
The art of managing complexity in large software projects
Domain Specific Languages
(DSLs)
DSL are a nice tool to hide complexity when it is useful

Nobody needs to be aware of all the details of a system all the time
MPS is a better platform for implementing DSLs
Full IDE Support
Built on top of the JetBrains IDEA platform
AVAILABLE FOR YOUR DSLs
Intelligent code completion
Intentions
Refactorings
Version Source Control, Debugger, etc.
Full Generator Support
You can translate your DSL programs to:

Any other language supported by the platform (with full editor support)

Text (useful for configuration files and legacy systems)
Supports Graphical DSLs
MPS supports graphical DSLs since Version 3.1
DSL as a diagram
Popular Software Engineering DSLs
Persistence (e.g., Protobuff, Hibernate, etc.)

Web app development (Rails, Grails)

Language Oriented Programming
Study a set of related problems
Design a set of languages that can help solve these problems
Generate the Languages to Executable Code or System
Try the languages with real-world problems
Refine and Iterate
Publish your languages so others can reuse them
Think
Micro-Language & Composition
Would extending an existing language do the job?
For instance
Let's extend BaseLanguage to offer
a Groovy-like string syntax

The Structure Aspect
Determines the Structure of a Language
Defines the AST Concept Hierarchy
The Editor Aspect
Determines how programs written in the language appear to end users
The Generator Aspect
Generate Other Languages For Programs Written in Your Language
For Data Analysts
Learning MPS
http://books.campagnelab.org
Online JetBrains Docs
My Book
http://tinyurl.com/LWDataAnalysis
Full transcript