• No results found

Software Analysis and Transformation with Rascal

N/A
N/A
Protected

Academic year: 2022

Share "Software Analysis and Transformation with Rascal"

Copied!
53
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Software Analysis And Transformation

Software Analysis and Transformation

Rascal with

BioAssist Meeting Jan 11th, 2013

Jurgen Vinju

(2)

• Centrum Wiskunde & Informatica

• Programming languages and systems

Algol

Python

• ASF+SDF, Rascal

MonetDB

• Where mathematics meets informatics

• striving for fundamental (general) results

• motivated by and applied in industry, government, and the sciences

W3C

• Software Improvement Group (spin-off)

• Master Software Engineering @{Universiteit van Amsterdam, VU, HvA}

(3)

25 minutes

• What and why do we research software at CWI?

How?

• Two possible discussions

• Question: how is bio software unique?

• Perspective: meta data programming?

(4)

Our team

Paul Klint

Jurgen Vinju

Tijs

v/d Storm

Bob

Fuhrer

(5)

The problem with software is not in

constructing it

(given sufficiently experienced architects & engineers)

(6)

The problem is in understanding

existing software in

order to improve it

(7)

We study software systems:

their design, their construction and their inevitable evolution.

• learning to understand software systems

• learning to improve them

• focusing on complexity as the quality attribute

• studying the causes of software complexity

• studying solutions to get simpler software

• helping software engineers to be more effective

• shaping the future of programming languages and IDEs

(8)

Software is not so difficult to

understand, but it is extremely complex

(Cari Buziak, Celtic Knot)

(9)

Software - large and complex structures of computer instructions, written and read by man, executed by computers.

“marked by a senseless, disorienting, often menacing complexity...” (Infoplease.com)

Kafkaesque

(10)
(11)

Solution...

Tools

(12)

Transformation & Analysis

• (de)optimization

• GOTO removal

• Bug fixing (Y2K)

Porting

• Refactoring ...

• Model-to-code

Languages

• Code-to-model

• Quality assessment

• Mining trends

• Dead code detection

• Bug detection

• Model checking

• Impact analysis

Raphael (1509)

(etc)

(13)

Research

Tools

Application

“every week a new tool”

(14)

Research

Tools

Software Rascal

(15)

Code

Model

Picture

Generation Extraction

Formalization Visualization

Transformation

Conversion Analysis

Execution

Rendering

(Brueghel, Tower of Babel)

Rascal is a

DSL for

programming meta

(16)

Diversity

Multi-disciplinary

Precision vs Efficiency

The three

challenges

(17)

The key point of Rascal is that it is a one-stop-shop;

no hacking stuff together, just one consistent, typed,

and safe environment for meta-programming for

“any” language.

(18)

D.I.Y.

• That’s the goal

• We teach Rascal (master)

• We use Rascal

• Caveat: “Experimental”

(19)

highlight:A one-slide DSL

Code

Model

Picture

(20)

highlight:A one-slide DSL

metro {

Centraal Waterloo Weesperplein Wibautstraat Amstel;

Amstel Spaklerweg Overamstel Rai Zuid;

Rai Zuid Amstelveenseweg Lelylaan Sloterdijk;

Centraal Rokin FerdinandBol Zuid;

}

Code

Model

Picture

(21)

highlight:A one-slide DSL

metro {

Centraal Waterloo Weesperplein Wibautstraat Amstel;

Amstel Spaklerweg Overamstel Rai Zuid;

Rai Zuid Amstelveenseweg Lelylaan Sloterdijk;

Centraal Rokin FerdinandBol Zuid;

}

{ <“Centraal”, “Waterloo”>,

Code

Model

Picture

(22)

highlight:A one-slide DSL

metro {

Centraal Waterloo Weesperplein Wibautstraat Amstel;

Amstel Spaklerweg Overamstel Rai Zuid;

Rai Zuid Amstelveenseweg Lelylaan Sloterdijk;

Centraal Rokin FerdinandBol Zuid;

}

{ <“Centraal”, “Waterloo”>,

<“Waterloo”,” Weesperplein”>, … }

Code

Model

Picture

(23)

highlight:A one-slide DSL

metro {

Centraal Waterloo Weesperplein Wibautstraat Amstel;

Amstel Spaklerweg Overamstel Rai Zuid;

Rai Zuid Amstelveenseweg Lelylaan Sloterdijk;

Centraal Rokin FerdinandBol Zuid;

}

{ <“Centraal”, “Waterloo”>,

<“Waterloo”,” Weesperplein”>, … }

Code

Model

Picture digraph Metro {

node [shape=box]

Centraal -> Waterloo

Waterloo -> Weesperplein ...

Centraal [shape=ellipse]

}

(24)

A one-slide DSL

Code

Model

Picture

(25)

A one-slide DSL

module Metro Code

Model

Picture

(26)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

Code

Model

Picture

(27)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ;

Code

Model

Picture

(28)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

Code

Model

Picture

(29)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

Code

Model

Picture

(30)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

Code

Model

Picture

(31)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source),

Code

Model

Picture

(32)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

Code

Model

Picture

(33)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

Code

Model

Picture

(34)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) {

Code

Model

Picture

(35)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

Code

Model

Picture

(36)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

‘<for (<from, to> <- metro) {>

Code

Model

Picture

(37)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

‘<for (<from, to> <- metro) {>

‘ <from> -\> <to><}>

Code

Model

Picture

(38)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

‘<for (<from, to> <- metro) {>

‘ <from> -\> <to><}>

‘<for (st <- metro<from>, isHub(metro, st)){>

Code

Model

Picture

(39)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

‘<for (<from, to> <- metro) {>

‘ <from> -\> <to><}>

‘<for (st <- metro<from>, isHub(metro, st)){>

‘ <st> [shape=ellipse]<}>

Code

Model

Picture

(40)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

‘<for (<from, to> <- metro) {>

‘ <from> -\> <to><}>

‘<for (st <- metro<from>, isHub(metro, st)){>

Code

Model

Picture

(41)

A one-slide DSL

module Metro

start syntax System = “metro” “{“ Track* tracks “}”;

syntax Track = Id+ stations “;” ; lexical Id = [A-Za-z][A-Za-z0-9]*;

layout WS = [\ \t\n\r]*;

rel[Id,Id] extractMetroGraph(loc source) =

{<from, to> | /Track t := parse(#start[System], source), (Track) `<Id+ _> <Id from> <Id to> <Id+ _>;` := t};

bool isHub(rel[Id,Id] metro, Id station) = size(metro[Id]) > 1;

void synthesizeDotGraph(loc target, rel[Id from,Id to] metro) { writeFile(target,”digraph Metro { node [shape=box]

‘<for (<from, to> <- metro) {>

‘ <from> -\> <to><}>

‘<for (st <- metro<from>, isHub(metro, st)){>

‘ <st> [shape=ellipse]<}>

‘}”);

Code

Model

Picture

(42)

a one-slide DSL

Code

Model

Picture

(43)

a one-slide DSL

What is the point?

Rapid tool development No boilerplate

No glue No magic

Done. Next!

Code

Model

Picture

(44)

a one-slide DSL

What is the point?

Rapid tool development No boilerplate

No glue No magic

Done. Next!

This works for

all kinds of meta-programming tools

Code

Model

Picture

(45)

Library development

Code

Model

Picture

(46)

Library development

Type-safe access to resources such as bug databases, version management systems, spreadsheets, webservices

Code

Model

Picture

(47)

Library development

Type-safe access to resources such as bug databases, version management systems, spreadsheets, webservices

Front-ends for programming languages

Code

Model

Picture

(48)

Library development

Type-safe access to resources such as bug databases, version management systems, spreadsheets, webservices

Front-ends for programming languages Generic analyses; statistics, constraints, satisfiability, …

Code

Model

Picture

(49)

Library development

Type-safe access to resources such as bug databases, version management systems, spreadsheets, webservices

Front-ends for programming languages Generic analyses; statistics, constraints, satisfiability, …

Visualization: one-stop-library for any visualization (graph, chart, browser, …)

Code

Model

Picture

(50)

Library development

Type-safe access to resources such as bug databases, version management systems, spreadsheets, webservices

Front-ends for programming languages Generic analyses; statistics, constraints, satisfiability, …

Visualization: one-stop-library for any visualization (graph, chart, browser, …)

(this is our main challenge at the moment)

Code

Model

Picture

(51)

Current applications

• PHP, Lua static analysis of dynamic languages

• Modular/Language parametric refactoring

• Grammar engineering

• Domain specific languages

• Pacioli - Computational auditing

• Derric - Digital Forensics

• Design pattern diagnostics

(52)

Take home messages

• http://www.rascal-mpl.org

• for DYI tool building

• open-source

CWI - SWAT

• studies real software (for example yours)

• builds tools

• UvA Master Software Engineering

• part-time (2 year), full-time (1 year)

• (to be developed) “deep track” - domain specific SE tracks

(53)

Discussion

• For meta programming source code is data

• and, source code is big!

• so, is meta programming like big data?

• Common challenges, common solution patterns?

• Are meta programming solutions relevant for bd?

• Are big data solutions relevant for meta prog?

• {C,sh,w}ould Rascal be extended to big data use cases?

Referenties

GERELATEERDE DOCUMENTEN

This script, written in the meta-programming language Rascal, and targeting an interpreter written in Java, extracts facts from the interpreter code using the Eclipse JDT, performs

Scenarios for program analysis using Rascal can be viewed as a spectrum: at one end, Rascal acts just as a coordination language, with all the actual analysis work done using

To explain Resources, we first discuss four key enabling Rascal features: type literals that allow types to be treated as values, source location literals that provide access

It may be helpful to think of the commands as being divided between two categories: tree-building and line drawing; or alternatively between the operator projection commands, and

Results: Via a meta-analysis and using data from 13 countries and over 4,0 0 0 data points, highlights of the SLR include: (1) software requirements, design, and testing are the

12 With accumulation, the technical refers to the (changing) mass of raw materials worked up into final commodities by a given amount of labour power; the organic reflects this

We first identify all active concurrent activities in the POOSL model of figure 2 to enable specifying timed automata in UPPAAL for each of them. Although each switch in the POOSL

if production rules or instance graphs are added to or changed in the grammar, only nodes and edges that have corresponding node types and edge types in the type graph are