Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new!...

41
Rascal: A DSL for SCAM Jurgen Vinju Tijs van der Storm Paul Klint Amsterdam, The Netherlands Hall of fame Bob Fuhrer Emilie Balland Arnold Lankamp Bas Basten Tuesday, September 29, 2009

Transcript of Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new!...

Page 1: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal: A DSL for SCAMJurgen Vinju

Tijs van der StormPaul Klint

Amsterdam, The Netherlands

Hall of fameBob Fuhrer

Emilie BallandArnold Lankamp

Bas Basten

Tuesday, September 29, 2009

Page 2: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

The complexity of bridging an analysis tool to a transformation tool shadows the complexity of the analyses and transformations themselves

[Vinju & Cordy Dagstuhl 2005]

Tuesday, September 29, 2009

Page 3: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

Tuesday, September 29, 2009

Page 4: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

Refactoring

Tuesday, September 29, 2009

Page 5: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

RefactoringSlicing

Tuesday, September 29, 2009

Page 6: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

RefactoringSlicing

Reverse Engineering

Tuesday, September 29, 2009

Page 7: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

RefactoringSlicing

Reverse Engineering Compilation

Tuesday, September 29, 2009

Page 8: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

RefactoringSlicing

Reverse Engineering Compilation

Restructuring

Tuesday, September 29, 2009

Page 9: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Every SCAM tool requires both “analysis” and “transformation”

features

RefactoringSlicing

Reverse Engineering Compilation

Restructuring

Static checking

Tuesday, September 29, 2009

Page 10: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

Tuesday, September 29, 2009

Page 11: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

TXL

Tuesday, September 29, 2009

Page 12: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

TXLStrategoXT

Tuesday, September 29, 2009

Page 13: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

TXLStrategoXT

Crocopat

Tuesday, September 29, 2009

Page 14: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

TXLStrategoXT

Crocopat GROK

Tuesday, September 29, 2009

Page 15: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

TXLStrategoXT

Crocopat GROK

ASF+SDF

Tuesday, September 29, 2009

Page 16: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Most language parametric SCAM tools are geared towards

either “analysis” or “transformation”

TXLStrategoXT

Crocopat GROK

ASF+SDF

RScript

Tuesday, September 29, 2009

Page 17: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Many great SCAM tools are implemented in a GPL

Tuesday, September 29, 2009

Page 18: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Many great SCAM tools are implemented in a GPL

A GPL allows fine-grained integration between

analysis and transformation

Tuesday, September 29, 2009

Page 19: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Many great SCAM tools are implemented in a GPL

A GPL allows fine-grained integration between

analysis and transformation

Tuesday, September 29, 2009

Page 20: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

A DSL for SCAM?

That covers SCAM

That scales down and scales up

That is easier

Tuesday, September 29, 2009

Page 21: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

The SCAM domain

Source Code

Models

Pictures

GenerationExtraction

FormalizationVisualization

Transformation

Conversion

Analysis

Tuesday, September 29, 2009

Page 22: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

The SCAM domainUses common...

Data-structures

Algorithms

Nothing new! But still..

Synthesize into a DSL

Conceptually

Syntactically

Semantically

Source Code

Models

Pictures

GenerationExtraction

FormalizationVisualization

Transformation

Conversion

Analysis

Tuesday, September 29, 2009

Page 23: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

The SCAM domainUses common...

Data-structures

Algorithms

Nothing new! But still..

Synthesize into a DSL

Conceptually

Syntactically

Semantically

Source Code

Models

Pictures

GenerationExtraction

FormalizationVisualization

Transformation

Conversion

Analysis Pattern Matching

Tuesday, September 29, 2009

Page 24: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale down to make simple tasks short and easy to

experiment with

Tuesday, September 29, 2009

Page 25: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale down to make simple tasks short and easy to

experiment with

Plain old REPL, no static type

errors

Tuesday, September 29, 2009

Page 26: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale down to make simple tasks short and easy to

experiment with

Plain old REPL, no static type

errors

First regexps, then CFG’s

Tuesday, September 29, 2009

Page 27: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale down to make simple tasks short and easy to

experiment with

Plain old REPL, no static type

errors

First regexps, then CFG’s

Complete & domain specific, expression language: visit, pattern matching,

relational calculus

Tuesday, September 29, 2009

Page 28: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale down to make simple tasks short and easy to

experiment with

Plain old REPL, no static type

errors

First regexps, then CFG’s

Complete & domain specific, expression language: visit, pattern matching,

relational calculus

URI literals: files,

projects, SVN, ...

Tuesday, September 29, 2009

Page 29: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Tuesday, September 29, 2009

Page 30: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Modules are statically

checked

Tuesday, September 29, 2009

Page 31: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Modules are statically

checked

Immutable data

Tuesday, September 29, 2009

Page 32: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Modules are statically

checked

Immutable dataCo-variant sub-types

Tuesday, September 29, 2009

Page 33: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Modules are statically

checked

Immutable data h.o. parametric polymorphism, rank-1 and 2

Co-variant sub-types

Tuesday, September 29, 2009

Page 34: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Modules are statically

checked

Immutable data

Efficient and fully typed

(de)serialization

h.o. parametric polymorphism, rank-1 and 2

Co-variant sub-types

Tuesday, September 29, 2009

Page 35: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

Function-local type inference

Modules are statically

checked

Immutable data

Efficient and fully typed

(de)serialization

h.o. parametric polymorphism, rank-1 and 2

Co-variant sub-types

Tuesday, September 29, 2009

Page 36: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

lexically scoped

backtracking

Function-local type inference

Modules are statically

checked

Immutable data

Efficient and fully typed

(de)serialization

h.o. parametric polymorphism, rank-1 and 2

Co-variant sub-types

Tuesday, September 29, 2009

Page 37: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

lexically scoped

backtracking

Function-local type inference

Modules are statically

checked

Immutable data

Efficient and fully typed

(de)serialization

h.o. parametric polymorphism, rank-1 and 2

Co-variant sub-types

blaConcrete syntaxbla

bla

IDE support bla

blaVisualization support

bla

Tuesday, September 29, 2009

Page 38: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal has to scale up to complex analysis and transformation algorithms that employ reuse of

(library) functionality and allow design for maintainability

lexically scoped

backtracking

Function-local type inference

Modules are statically

checked

Immutable data

Efficient and fully typed

(de)serialization

h.o. parametric polymorphism, rank-1 and 2

Co-variant sub-types

blaConcrete syntaxbla

bla

IDE support bla

blaVisualization support

bla

Tuesday, September 29, 2009

Page 39: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

We have implemented Infer generic type arguments [Fuhrer et al. ECOOP2005]

on Generic Featherweight Java [Igarashi et al. TOPLAS2002]

The size of the Rascal code is equal to thesize of the formal definitions in the papers

Tuesday, September 29, 2009

Page 40: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal

Analysis and manipulation are happily married.

We should think of them as one.

Tuesday, September 29, 2009

Page 41: Rascal: A DSL for SCAM · The SCAM domain Uses common... Data-structures Algorithms Nothing new! But still.. Synthesize into a DSL Conceptually Syntactically Semantically Source Code

Rascal

Analysis and manipulation are happily married.

We should think of them as one.

http://www.meta-environment.org

Tuesday, September 29, 2009