SlideShare a Scribd company logo
TI1220 2012-2013
Concepts of Programming Languages
Eelco Visser / TU Delft
Lecture 14: Domain-Specific Languages
Syntax and Semantics
Names, Bindings, and Scopes
Storage
Data Types
Functional Programming
First-class Functions
Polymorphism
Type Parameterization
Parsing and Interpretation
Data Abstraction / Modular Programming
Functional Programming Redux
Concurrency
Concurrent Programming
Domain-Specific Languages
Quarter 3
Quarter 4
Basics of
Scala
JavaScript
C
Linguistic Abstraction
Formalizing Design Patterns
Problem
Domain
Solution
Domain
implement
validate
Software Engineering
Software Reuse: Don’t RepeatYourself
software reuse patterns
• copy and paste
• libraries
• frameworks
• service APIs
• design patterns
Linguistic Abstraction
identify pattern
use new abstraction
language A language B
design abstraction
From Instructions to Expressions
mov &a, &c
add &b, &c
mov &a, &t1
sub &b, &t1
and &t1,&c
Source: http://sites.google.com/site/arch1utep/home/course_outline/translating-complex-expressions-into-assembly-language-using-expression-trees
c = a
c += b
t1 = a
t1 -= b
c &= t1
c = (a + b) & (a - b)
From Calling Conventions to Procedures
calc:
push eBP ; save old frame pointer
mov eBP,eSP ; get new frame pointer
sub eSP,localsize ; reserve place for locals
.
. ; perform calculations, leave result in AX
.
mov eSP,eBP ; free space for locals
pop eBP ; restore old frame pointer
ret paramsize ; free parameter space and return
f(e1,e2,...,en)
push eAX ; pass some register result
push byte[eBP+20] ; pass some memory variable (FASM/TASM syntax)
push 3 ; pass some constant
call calc ; the returned result is now in eAX
f(x) { ... }
http://en.wikipedia.org/wiki/Calling_convention
A structure is a collection of one or more variables, possibly of different types,
grouped together under a single name for convenient handling. (Structures are
called ``records'' in some languages, notably Pascal.)
struct point {
	 int x;
	 int y;
};
member
structure tag
Structures in C:Abstract from Memory Layout
Malloc/Free to Automatic Memory Management
/* Allocate space for an array with ten elements of type int. */
int *ptr = (int*)malloc(10 * sizeof (int));
if (ptr == NULL) {
/* Memory could not be allocated, the program
should handle the error here as appropriate. */
} else {
/* Allocation succeeded. Do something. */
free(ptr); /* We are done with the int objects,
and free the associated pointer. */
ptr = NULL; /* The pointer must not be used again,
unless re-assigned to using malloc again. */
}
http://en.wikipedia.org/wiki/Malloc
int [] = new int[10];
/* use it; gc will clean up (hopefully) */
typedef struct Base {
void* (**vtable)();
int x;
} Base;
void (*Base_Vtable[])() = { &Base_print };
Base* newBase(int v) {
Base* obj = (Base*)malloc(sizeof(Base));
obj->vtable = Base_Vtable;
obj->x = v;
return obj;
}
void print(Base* obj) {
obj->vtable[0](obj);
}
class Base {
Integer x;
public Base(Integer v) {
x = v;
}
public void print() {
System.out.println("Base: " + x);
}
}
class Child extends Base {
Integer y;
public Child(Integer v1, Integer v2) {
super(v1);
y = v2;
}
public void print() {
System.out.println("Child: (" + x + "," + y + ")");
}
}
Dynamic Dispatch
Polymorphic Higher-Order Functions
def map[A,B](f: A => B, xs: List[A]): List[B] = {
xs match{
case Nil() => Nil()
case Cons(y, ys) => Cons(f(y), map(f, ys))
}
}
def incList(xs: IntList): IntList =
xs match {
case Nil() => Nil()
case Cons(y, ys) => Cons(y + 1, incList(ys))
}
Abstractions in Programming Languages
❖ Structured control-flow
★ if-then-else, while
❖ Procedural abstraction
★ procedures, first-class functions (closures)
❖ Memory management
★ garbage collection
❖ Data abstraction
★ abstract data types, objects
❖ Modules
★ inheritance, traits, mixins
“A programming language is low level when its
programs require attention to the irrelevant”
Alan J. Perlis. Epigrams on Programming. SIGPLAN Notices, 17(9):7-13, 1982.
Do HLLs eliminate all irrelevant details?
What about
❖ data persistence
❖ data services
❖ concurrency
❖ distribution
❖ access control
❖ data invariants
❖ workflow
❖ ...
Do HLLs eliminate all irrelevant details?
What about
❖ data persistence
❖ data services
❖ concurrency
❖ distribution
❖ access control
❖ data invariants
❖ workflow
❖ ...
many of these
concerns require
programmatic
encodings
What is the Next Level of
Abstraction?
Problem
Domain
HLL Machine
Domain-Specific Languages
Problem
Domain
HLL MachineDSL
Example: Encoding Units
compiler
computerinput
input distance : Float;
input duration : Float;
output speed : Float := duration / distance;
output
Example: Encoding Units
compiler
computerinput
input distance : Float;
input duration : Float;
output speed : Float := duration / distance;
error
wrong output
Impact of Software Errors
compiler
computer
error
Mars Climate Orbiter
Unit mismatch: Orbiter
variables in Newtons,
Ground control software in
Pound-force.
Damage: ~350 M$
input distance : Float;
input duration : Float;
output speed : Float := duration / distance;
wrong output
Example: Explicit Representation of Units
computer
input distance : Meter;
input duration : Second;
output speed : Meter/Second := duration / distance;
compiler
formalize knowledge of application area (domain) in language
error
DSLs Provide Domain-Specific ...
Abstractions
★ directly represent domain concepts
Concrete syntax
★ natural notation
Optimization
★ based on domain assumptions
Error checking
★ report errors in terms of domain concepts
Tool support
★ interpreter, compiler, code generator, IDE
Internal DSL
Library in HLL
★ Haskell, Scala, Ruby, ...
★ API is language
★ language features for ‘linguistic abstraction’
Advantages
★ host language = implementation language
Disadvantages
★ host language = implementation language (encoding)
★ no portability
★ no domain-specific errors, analysis, optimization
External DSL
Dedicated language
★ independent of host/target language (portable)
★ implementation with interpreter or compiler
Advantages
★ language tuned to domain
★ domain-specific errors, analysis, optimizations
Disadvantages
★ cost of learning new language
★ cost of maintaining language
Example DSLs (1)
Spreadsheet
★ formulas, macros
Querying
★ SQL, XQuery, XPath
Graph layout
★ GraphViz
Web
★ HTML, CSS, RSS, XML, XSLT
★ Ruby/Rails, JSP, ASP, JSF, WebDSL
Example DSLs (2)
Games
★ Lua, UnrealScript
Modeling
★ UML, OCL, QVT
Language engineering
★ YACC, LEX, RegExp, ANTLR, SDF
★ TXL, ASF+SDF, Stratego
Example: Linguistic Integration in
WebDSL
browser server database
web app
Web Programming
browser server database
Java SQL
HTML,
JS, CSS
Web Programming = Distributed Programming
Concerns in Web
Programming
Data Persistence
Access Control
Injection Attacks
Search
XSS
DataValidation
Data Binding
Routing
... ...
Zef Hemel, Danny M. Groenewegen, Lennart C. L. Kats, EelcoVisser.
Static consistency checking of web applications with
WebDSL. Journal of Symbolic Computation, 46(2):150-182, 2011.
Late Failure Detection in Web Applications
Complexity in Web Programming:
Multiple Languages x Multiple Concerns
Consistency not statically checked
EelcoVisser. WebDSL: A Case Study in Domain-Specific Language Engineering. In
Ralf Lämmel, JoostVisser, João Saraiva, editors, Generative and Transformational Techniques in
Software Engineering II, International Summer School, GTTSE 2007.Volume 5235 of Lecture Notes
in Computer Science, pages 291-373, Springer, Braga, Portugal, 2007.
Separation of Concerns & Linguistic Integration
Formalizing Navigation Logic
http://eelcovisser.org/blog/post/42/dsl-engineering
“http://”
+ “eelcovisser.org” // host domain
+ “blog” // application name
+ “post” // page
+ “42” // identity
+ “dsl-engineering” // title
page blog(b: Blog, index: Int) {
main(b){
for(p: Post in b.recentPosts(index,5)) {
section{
header{ navigate post(p) { output(p.title) } }
par{ output(p.content) }
par{ output(p.created.format("MMMM d, yyyy")) }
}
}
}
page post(p: Post) { ... }
Statically checked navigation
entity Blog {
key :: String (id)
title :: String (name)
posts -> Set<Post> (inverse=Post.blog)
function recentPosts(index: Int, n: Int): List<Post> {
var i := max(1,index) - 1;
return [p | p: Post in posts
order by p.created desc
limit n offset i*n].list();
}
}
entity Post {
key :: String (id)
title :: String (name, searchable)
content :: WikiText (searchable)
blog -> Blog
}
Persistent Data Models
Generation of queries: no injection attacks
entity Assignment {
key :: String (id)
title :: String (name, searchable)
shortTitle :: String
description :: WikiText (searchable)
course -> CourseEdition (searchable)
weight :: Float (default=1.0)
deadline :: DateTime (default=null)
// ...
}
page assignment(assign: Assignment, tab: String) {
main{
progress(assign, tab)
pageHeader{
output(assign.title)
breadcrumbs(assign)
}
// ...
}
}
Persistent variables in WebDSL
http://department.st.ewi.tudelft.nl/weblab/assignment/752
objects are automatically persisted in database
1
2
3
page post(p: Post) { ... }
page editpost(p: Post) {
action save() { return blog(p); }
main(p.blog){
form{
formEntry("Title"){
input(p.title) }
formEntry("Content") {
input(p.content) }
formEntry("Posted") {
input(p.created) }
submit save() { "Save" }
}
}
}
Forms & Data Binding
No separate controller!
access control rules
principal is User
with credentials username, password
rule page blog(b: Blog, index: Int) {
true
}
rule page post(p: Post) {
p.public || p.author == principal
}
rule page editpost(p: Post) {
principal == p.author
}
extend entity User {
password :: Secret
}
extend entity Blog {
owner -> User
}
extend entity Post {
public :: Bool
}
Declarative Access Control Rules
Linguistically Integrated
Persistent data model
Logic
Templates (UI, Email, Service)
Data binding
Access control
Data validation
Faceted search
Collaborative filtering
DSL Summary
software reuse through linguistic abstraction
• capture understanding of design patterns in language concepts
• abstract from accidental complexity
• program in terms of domain concepts
• automatically generate implementation
When to Use/Create DSLs?
Hierarchy of abstractions
• first understand how to program it
• make variations by copy, paste, adapt
• (avoid over-engineering)
• make library of frequently used patterns
• find existing (internal) DSLs for the domain
Time for a DSL?
• large class of applications using same design patterns
• design patterns cannot be captured in PL
• lack of checking / optimization for DSL abstractions
Language Engineering
object ExpParser extends JavaTokenParsers with PackratParsers {
lazy val exp: PackratParser[Exp] =
(exp <~ "+") ~ exp1 ^^ { case lhs~rhs => Add(lhs, rhs) } |
exp1
lazy val exp1: PackratParser[Exp] =
(exp1 ~ exp0) ^^ { case lhs~rhs => App(lhs, rhs) } |
exp0
lazy val exp0: PackratParser[Exp] =
number | identifier | function | letBinding |
"(" ~> exp <~ ")"
// ...
def parse(text: String) = parseAll(exp, text)
}
syntax through parsers
sealed abstract class Value
case class numV(n: Int) extends Value
case class closureV(param: Symbol, body: Exp, env: Env)
extends Value
def eval(exp: Exp, env: Env): Value = exp match {
case Num(v) => numV(v)
case Add(l, r) => plus(eval(l, env), eval(r, env))
case Id(name) => lookup(name, env)
case Let(name, e1, e2) =>
eval(e2, bind(name, eval(e1, env), env))
case Fun(name, body) => closureV(name, body, env)
case App(fun, arg) => eval(fun, env) match {
case closureV(name, body, env2) =>
eval(body, bind(name, eval(arg, env), env2))
case _ => sys.error("Closure expected")
}
}
semantics through interpreter
Traditional Compilers
Traditional Compilers
ls
Course.java
Traditional Compilers
ls
Course.java
javac -verbose Course.java
[parsing started Course.java]
[parsing completed 8ms]
[loading java/lang/Object.class(java/lang:Object.class)]
[checking university.Course]
[wrote Course.class]
[total 411ms]
Traditional Compilers
ls
Course.java
javac -verbose Course.java
[parsing started Course.java]
[parsing completed 8ms]
[loading java/lang/Object.class(java/lang:Object.class)]
[checking university.Course]
[wrote Course.class]
[total 411ms]
ls
Course.class Course.java
Language Processors
syntax analysis
• parsing
• AST construction
static analysis
• name analysis
• type analysis
semantics
• generation
• interpretation
Integrated Development Environments (IDE)
Modern Compilers in IDEs
syntactic editor services
• syntax checking
• syntax highlighting
• outline view
• code folding
• bracket matching
semantic editor services
• error checking
• reference resolving
• hover help
• content completion
• refactoring
Eclipse Platform
runtime platform
• composition
• integration
development platform
• complex APIs
• abstractions for Eclipse IDEs
• concepts: editors, views, label provider, label provider
factory, …
• tedious, boring, frustrating
Spoofax Language Workbench
declarative meta-languages
• syntax definition
• editor services
• term rewriting
implementation
• generic integration into Eclipse and IMP
• compilation & interpretation of language definitions
agile
• Spoofax & IDE under development in same Eclipse instance
• support for test-driven development
A Taste of Language Engineering
with Spoofax
• abstract syntax trees
• declarative syntax definition
• name binding and scope
• transformation by term rewriting
EnFun: Entities with Functions
module blog
entity String {
function plus(that:String): String
}
entity Bool { }
entity Set<T> {
function add(x: T)
function remove(x: T)
function member(x: T): Bool
}
entity Blog {
posts : Set<Post>
function newPost(): Post {
var p : Post := Post.new();
posts.add(p);
}
}
entity Post {
title : String
}
Structure:Abstract Syntax
Signature & Terms
constructors
Module : ID * List(Definition) -> Module
Imports : ID -> Definition
Module(
"application"
, [Imports("library"),
Imports("users"),
Imports("frontend")]
)
Entities & Properties
constructors
Entity : ID * List(Property) -> Definition
Type : ID -> Type
New : Type -> Exp
constructors
Property : ID * Type -> Property
This : Exp
PropAccess : Exp * ID -> Exp
Module("users"
, [ Imports("library")
, Entity("User"
, [ Property("email", Type("String"))
, Property("password", Type("String"))
, Property("isAdmin", Type("Bool"))])])
Parsing: From Text to Structure
Declarative Syntax Definition
Entity("User", [
Property("first", Type("String")),
Property("last", Type("String"))
])
signature
constructors
Entity : ID * List(Property) -> Definition
Type : ID -> Type
Property : ID * Type -> Property
Declarative Syntax Definition
entity User {
first : String
last : String
}
Entity("User", [
Property("first", Type("String")),
Property("last", Type("String"))
])
signature
constructors
Entity : ID * List(Property) -> Definition
Type : ID -> Type
Property : ID * Type -> Property
Declarative Syntax Definition
entity User {
first : String
last : String
}
Entity("User", [
Property("first", Type("String")),
Property("last", Type("String"))
])
signature
constructors
Entity : ID * List(Property) -> Definition
Type : ID -> Type
Property : ID * Type -> Property
context-free syntax
"entity" ID "{" Property* "}" -> Definition {"Entity"}
ID -> Type {"Type"}
ID ":" Type -> Property {"Property"}
Prototyping Syntax Definition
Context-free Syntax
constructors
True : Exp
False : Exp
Not : Exp -> Exp
And : Exp * Exp -> Exp
Or : Exp * Exp -> Exp
context-free syntax
"true" -> Exp {"True"}
"false" -> Exp {"False"}
"!" Exp -> Exp {"Not"}
Exp "&&" Exp -> Exp {"And"}
Exp "||" Exp -> Exp {"Or"}
Lexical Syntax
constructors
True : Exp
False : Exp
Not : Exp -> Exp
And : Exp * Exp -> Exp
Or : Exp * Exp -> Exp
context-free syntax
"true" -> Exp {"True"}
"false" -> Exp {"False"}
"!" Exp -> Exp {"Not"}
Exp "&&" Exp -> Exp {"And"}
Exp "||" Exp -> Exp {"Or"}
lexical syntax
[a-zA-Z][a-zA-Z0-9]* -> ID
"-"? [0-9]+ -> INT
[ tnr] -> LAYOUT
constructors
: String -> ID
: String -> INT
scannerless generalized (LR) parsing
form of tokens (words, lexemes)
Ambiguity
constructors
True : Exp
False : Exp
Not : Exp -> Exp
And : Exp * Exp -> Exp
Or : Exp * Exp -> Exp
context-free syntax
"true" -> Exp {"True"}
"false" -> Exp {"False"}
"!" Exp -> Exp {"Not"}
Exp "&&" Exp -> Exp {"And"}
Exp "||" Exp -> Exp {"Or"}
isPublic || isDraft && (author == principal())
Ambiguity
constructors
True : Exp
False : Exp
Not : Exp -> Exp
And : Exp * Exp -> Exp
Or : Exp * Exp -> Exp
context-free syntax
"true" -> Exp {"True"}
"false" -> Exp {"False"}
"!" Exp -> Exp {"Not"}
Exp "&&" Exp -> Exp {"And"}
Exp "||" Exp -> Exp {"Or"}
isPublic || isDraft && (author == principal())
amb([
And(Or(Var("isPublic"), Var("isDraft")),
Eq(Var("author"), ThisCall("principal", []))),
Or(Var("isPublic"),
And(Var("isDraft"), Eq(Var("author"), ThisCall("principal", []))))
])
Disambiguation by Encoding Precedence
constructors
True : Exp
False : Exp
Not : Exp -> Exp
And : Exp * Exp -> Exp
Or : Exp * Exp -> Exp
context-free syntax
"true" -> Exp {"True"}
"false" -> Exp {"False"}
"!" Exp -> Exp {"Not"}
Exp "&&" Exp -> Exp {"And"}
Exp "||" Exp -> Exp {"Or"}
context-free syntax
"(" Exp ")" -> Exp0 {bracket}
"true" -> Exp0 {"True"}
"false" -> Exp0 {"False"}
Exp0 -> Exp1
"!" Exp0 -> Exp1 {"Not"}
Exp1 -> Exp2
Exp1 "&&" Exp2 -> Exp2 {"And"}
Exp2 -> Exp3
Exp2 "||" Exp3 -> Exp3 {"Or"}
Declarative Disambiguation
context-free syntax
"true" -> Exp {"True"}
"false" -> Exp {"False"}
"!" Exp -> Exp {"Not"}
Exp "&&" Exp -> Exp {"And", left}
Exp "||" Exp -> Exp {"Or", left}
"(" Exp ")" -> Exp {bracket}
context-free priorities
{left: Exp.Not} >
{left: Exp.Mul} >
{left: Exp.Plus Exp.Minus} >
{left: Exp.And} >
{non-assoc: Exp.Eq Exp.Lt Exp.Gt Exp.Leq Exp.Geq}
isPublic || isDraft && (author == principal())
Or(Var("isPublic"),
And(Var("isDraft"),
Eq(Var("author"), ThisCall("principal", []))))
Analysis: Name Resolution
+
Definitions and References
module test
entity String { }
entity User {
first : String
last : String
}
definition
reference
Name Binding in IDE
From Tree to Graph
Module(
"test"
, [ Entity("String", [])
, Entity(
"User"
, [ Property("first", )
, Property("last", )
]
)
]
)
NaBL: Name Binding Language
module names
imports
include/Cam
namespaces Type Property Function Variable
rules
Entity(name, None(), None(), _):
defines Type name of type Type(name, [])
scopes Type, Function, Property, Variable
Type(name, _):
refers to Type name
Transformation
Transformation by Strategic Rewriting
rules
desugar:
Plus(e1, e2) -> MethCall(e1, "plus", [e2])
desugar:
Or(e1, e2) -> MethCall(e1, "or", [e2])
desugar :
VarDeclInit(x, t, e) ->
Seq([VarDecl(x, t),
Assign(Var(x), e)])
strategies
desugar-all = topdown(repeat(desugar))
Return-Lifting Applied
function fact(n: Int): Int {
var res: Int;
if(n == 0) {
res := 1;
} else {
res := this * fact(n - 1);
}
return res;
}
function fact(n: Int): Int {
if(n == 0) {
return 1;
} else {
return this * fact(n - 1);
}
}
Return-Lifting Rules
rules
lift-return-all =
alltd(lift-return; normalize-all)
lift-return :
FunDef(x, arg*, Some(t), stat1*) ->
FunDef(x, arg*, Some(t), Seq([
VarDecl(y, t),
Seq(stat2*),
Return(Var(y))
]))
where y := <new>;
stat2* := <alltd(replace-return(|y))> stat1*
replace-return(|y) :
Return(e) -> Assign(y, e)
Language Engineering Summary
apply linguistic abstraction to language engineering
• declarative languages for language definition
• automatic derivation of efficient compilers
• automatic derivation of IDEs
Research Agenda
Example: Explicit Representation of Units
computer
input distance : Meter;
input duration : Second;
output speed : Meter/Second := duration / distance;
compiler
formalize knowledge of application area (domain) in language
error
error
Problem: Correctness of Language Definitions
computer
compiler
Can we
trust the
compiler?
wrong outputinput
program
type soundness: well-typed programs don’t go wrong
compiler
error
Challenge:AutomaticVerification of Correctness
computer
compiler
wrong output
program
type soundness: well-typed programs don’t go wrong
type
checker
code
generator
input
Correctness
Proof
Language Workbench
State-of-the-Art: Language Engineering
Syntax
Checker
Name
Resolver
Type
Checker
Code
Generator
focus on implementation; not suitable for verification
Compiler
Editor
(IDE)
Tests
Formal Language Specification
State-of-the-Art: Semantics Engineering
Abstract
Syntax
Type
System
Dynamic
Semantics
Transforms
focus on (only semi-automatic) verification; not suitable for implementation
Correctness
Proof
TestsCompiler
Editor
(IDE)
Declarative Language Definition
My Approach: Multi-Purpose Language Definitions
Syntax
Definition
Name
Binding
Type
System
Dynamic
Semantics
Transforms
Compiler
Editor
(IDE)
Correctness
Proof
Tests
bridging the gap between language engineering and semantics engineering
Software Development on the Web
revisiting the architecture of the IDE
Exam
Syntax and Semantics
Names, Bindings, and Scopes
Storage
Data Types
Functional Programming
First-class Functions
Polymorphism
Type Parameterization
Parsing and Interpretation
Data Abstraction / Modular Programming
Functional Programming Redux
Concurrency
Concurrent Programming
Domain-Specific Languages
Quarter 3
Quarter 4
Basics of
Scala
JavaScript
C
Material for exam
Slides from lectures
Tutorial exercises
Graded assignments
Sebesta: Chapters 1-13, 15
Programming in Scala: Chapters 1, 4-16, 19, 32-33
K&R C: Chapters 1-6
JavaScript Good Parts: Chapters 1-4
Content of exam
10% multiple choice questions
about concepts
50% Scala programming
(functional programming)
20% C programming
(structures and pointers)
20% JavaScript programming
(objects and prototypes)
Registration for Exam is Required
http://department.st.ewi.tudelft.nl/weblab/assignment/761 -> your submission
Good Luck!

More Related Content

What's hot

c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages
mohamed drahem
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
Ankur Pandey
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
shubhra chauhan
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N years
Ruslan Shevchenko
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Eelco Visser
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
Sagar Pednekar
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
PDC Video on C# 4.0 Futures
PDC Video on C# 4.0 FuturesPDC Video on C# 4.0 Futures
PDC Video on C# 4.0 Futures
nithinmohantk
 
Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
starlit electronics
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
Aniruddha Chakrabarti
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Ruslan Shevchenko
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
Ajit Nayak
 
Quick introduction to scala
Quick introduction to scalaQuick introduction to scala
Quick introduction to scala
Mohammad Hossein Rimaz
 
BUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERBUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILER
Ajeet Dubey
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
Michael Stal
 
Compilers Are Databases
Compilers Are DatabasesCompilers Are Databases
Compilers Are Databases
Martin Odersky
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
Michael Stal
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
Roberto Casadei
 

What's hot (20)

pebble - Building apps on pebble
pebble - Building apps on pebblepebble - Building apps on pebble
pebble - Building apps on pebble
 
c# usage,applications and advantages
c# usage,applications and advantages c# usage,applications and advantages
c# usage,applications and advantages
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N years
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
C by balaguruswami - e.balagurusamy
C   by balaguruswami - e.balagurusamyC   by balaguruswami - e.balagurusamy
C by balaguruswami - e.balagurusamy
 
PDC Video on C# 4.0 Futures
PDC Video on C# 4.0 FuturesPDC Video on C# 4.0 Futures
PDC Video on C# 4.0 Futures
 
Differences between c and c++
Differences between c and c++Differences between c and c++
Differences between c and c++
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
 
Quick introduction to scala
Quick introduction to scalaQuick introduction to scala
Quick introduction to scala
 
BUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERBUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILER
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
Compilers Are Databases
Compilers Are DatabasesCompilers Are Databases
Compilers Are Databases
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
 

Viewers also liked

Model-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive TransformationModel-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive Transformation
Eelco Visser
 
Building DSLs with the Spoofax Language Workbench
Building DSLs with the Spoofax Language WorkbenchBuilding DSLs with the Spoofax Language Workbench
Building DSLs with the Spoofax Language Workbench
Eelco Visser
 
Model-Driven Software Development - Web Abstractions 1
Model-Driven Software Development - Web Abstractions 1Model-Driven Software Development - Web Abstractions 1
Model-Driven Software Development - Web Abstractions 1
Eelco Visser
 
Type analysis
Type analysisType analysis
Type analysis
Eelco Visser
 
Composing Domain-Specific Languages
Composing Domain-Specific LanguagesComposing Domain-Specific Languages
Composing Domain-Specific Languages
Eelco Visser
 
Model-Driven Software Development - Web Abstractions 2
Model-Driven Software Development - Web Abstractions 2Model-Driven Software Development - Web Abstractions 2
Model-Driven Software Development - Web Abstractions 2
Eelco Visser
 
Static Analysis
Static AnalysisStatic Analysis
Static Analysis
Eelco Visser
 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow Analysis
Eelco Visser
 
From Muddling to Modelling
From Muddling to ModellingFrom Muddling to Modelling
From Muddling to Modelling
Jorn Bettin
 
Domain Analysis & Data Modeling
Domain Analysis & Data ModelingDomain Analysis & Data Modeling
Domain Analysis & Data Modeling
Eelco Visser
 
Dynamic Semantics
Dynamic SemanticsDynamic Semantics
Dynamic Semantics
Eelco Visser
 
Software languages
Software languagesSoftware languages
Software languages
Eelco Visser
 
Programming languages
Programming languagesProgramming languages
Programming languages
Eelco Visser
 

Viewers also liked (14)

Model-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive TransformationModel-Driven Software Development - Context-Sensitive Transformation
Model-Driven Software Development - Context-Sensitive Transformation
 
Building DSLs with the Spoofax Language Workbench
Building DSLs with the Spoofax Language WorkbenchBuilding DSLs with the Spoofax Language Workbench
Building DSLs with the Spoofax Language Workbench
 
Model-Driven Software Development - Web Abstractions 1
Model-Driven Software Development - Web Abstractions 1Model-Driven Software Development - Web Abstractions 1
Model-Driven Software Development - Web Abstractions 1
 
Code Generation
Code GenerationCode Generation
Code Generation
 
Type analysis
Type analysisType analysis
Type analysis
 
Composing Domain-Specific Languages
Composing Domain-Specific LanguagesComposing Domain-Specific Languages
Composing Domain-Specific Languages
 
Model-Driven Software Development - Web Abstractions 2
Model-Driven Software Development - Web Abstractions 2Model-Driven Software Development - Web Abstractions 2
Model-Driven Software Development - Web Abstractions 2
 
Static Analysis
Static AnalysisStatic Analysis
Static Analysis
 
Dataflow Analysis
Dataflow AnalysisDataflow Analysis
Dataflow Analysis
 
From Muddling to Modelling
From Muddling to ModellingFrom Muddling to Modelling
From Muddling to Modelling
 
Domain Analysis & Data Modeling
Domain Analysis & Data ModelingDomain Analysis & Data Modeling
Domain Analysis & Data Modeling
 
Dynamic Semantics
Dynamic SemanticsDynamic Semantics
Dynamic Semantics
 
Software languages
Software languagesSoftware languages
Software languages
 
Programming languages
Programming languagesProgramming languages
Programming languages
 

Similar to TI1220 Lecture 14: Domain-Specific Languages

Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptxPERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
TriSandhikaJaya
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
Jorge Antonio Contre Vargas
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud appsDavid Cunningham
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
Eelco Visser
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
Jorg Janke
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#Talbott Crowell
 
Software Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxSoftware Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & Spoofax
Eelco Visser
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep JoshiSpiffy
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#
Tomas Petricek
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
CHOOSE
 
Linguistic Abstraction for the Web
Linguistic Abstraction for the WebLinguistic Abstraction for the Web
Linguistic Abstraction for the Web
Eelco Visser
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
Guillaume Laforge
 
Dart
DartDart
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
Talentica Software
 
.NET and C# introduction
.NET and C# introduction.NET and C# introduction
.NET and C# introduction
Peter Gfader
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The EnterpriseDaniel Egan
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLsintelliyole
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
Ruslan Shevchenko
 

Similar to TI1220 Lecture 14: Domain-Specific Languages (20)

Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptxPERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
PERTEMUAN 1 - MENGENAL ENVIRONTMENT PROGRAM VISUAL C#.pptx
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
Software Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxSoftware Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & Spoofax
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
Linguistic Abstraction for the Web
Linguistic Abstraction for the WebLinguistic Abstraction for the Web
Linguistic Abstraction for the Web
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Dart
DartDart
Dart
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
.NET and C# introduction
.NET and C# introduction.NET and C# introduction
.NET and C# introduction
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 

More from Eelco Visser

CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
Eelco Visser
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
Eelco Visser
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
Eelco Visser
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
Eelco Visser
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
Eelco Visser
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
Eelco Visser
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
Eelco Visser
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Eelco Visser
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
Eelco Visser
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
Eelco Visser
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
Eelco Visser
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
Eelco Visser
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
Eelco Visser
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
Eelco Visser
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
Eelco Visser
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
Eelco Visser
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
Eelco Visser
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Eelco Visser
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Eelco Visser
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
Eelco Visser
 

More from Eelco Visser (20)

CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static Analysis
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

TI1220 Lecture 14: Domain-Specific Languages

  • 1. TI1220 2012-2013 Concepts of Programming Languages Eelco Visser / TU Delft Lecture 14: Domain-Specific Languages
  • 2. Syntax and Semantics Names, Bindings, and Scopes Storage Data Types Functional Programming First-class Functions Polymorphism Type Parameterization Parsing and Interpretation Data Abstraction / Modular Programming Functional Programming Redux Concurrency Concurrent Programming Domain-Specific Languages Quarter 3 Quarter 4 Basics of Scala JavaScript C
  • 5. Software Reuse: Don’t RepeatYourself software reuse patterns • copy and paste • libraries • frameworks • service APIs • design patterns
  • 6. Linguistic Abstraction identify pattern use new abstraction language A language B design abstraction
  • 7. From Instructions to Expressions mov &a, &c add &b, &c mov &a, &t1 sub &b, &t1 and &t1,&c Source: http://sites.google.com/site/arch1utep/home/course_outline/translating-complex-expressions-into-assembly-language-using-expression-trees c = a c += b t1 = a t1 -= b c &= t1 c = (a + b) & (a - b)
  • 8. From Calling Conventions to Procedures calc: push eBP ; save old frame pointer mov eBP,eSP ; get new frame pointer sub eSP,localsize ; reserve place for locals . . ; perform calculations, leave result in AX . mov eSP,eBP ; free space for locals pop eBP ; restore old frame pointer ret paramsize ; free parameter space and return f(e1,e2,...,en) push eAX ; pass some register result push byte[eBP+20] ; pass some memory variable (FASM/TASM syntax) push 3 ; pass some constant call calc ; the returned result is now in eAX f(x) { ... } http://en.wikipedia.org/wiki/Calling_convention
  • 9. A structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling. (Structures are called ``records'' in some languages, notably Pascal.) struct point { int x; int y; }; member structure tag Structures in C:Abstract from Memory Layout
  • 10. Malloc/Free to Automatic Memory Management /* Allocate space for an array with ten elements of type int. */ int *ptr = (int*)malloc(10 * sizeof (int)); if (ptr == NULL) { /* Memory could not be allocated, the program should handle the error here as appropriate. */ } else { /* Allocation succeeded. Do something. */ free(ptr); /* We are done with the int objects, and free the associated pointer. */ ptr = NULL; /* The pointer must not be used again, unless re-assigned to using malloc again. */ } http://en.wikipedia.org/wiki/Malloc int [] = new int[10]; /* use it; gc will clean up (hopefully) */
  • 11. typedef struct Base { void* (**vtable)(); int x; } Base; void (*Base_Vtable[])() = { &Base_print }; Base* newBase(int v) { Base* obj = (Base*)malloc(sizeof(Base)); obj->vtable = Base_Vtable; obj->x = v; return obj; } void print(Base* obj) { obj->vtable[0](obj); } class Base { Integer x; public Base(Integer v) { x = v; } public void print() { System.out.println("Base: " + x); } } class Child extends Base { Integer y; public Child(Integer v1, Integer v2) { super(v1); y = v2; } public void print() { System.out.println("Child: (" + x + "," + y + ")"); } } Dynamic Dispatch
  • 12. Polymorphic Higher-Order Functions def map[A,B](f: A => B, xs: List[A]): List[B] = { xs match{ case Nil() => Nil() case Cons(y, ys) => Cons(f(y), map(f, ys)) } } def incList(xs: IntList): IntList = xs match { case Nil() => Nil() case Cons(y, ys) => Cons(y + 1, incList(ys)) }
  • 13. Abstractions in Programming Languages ❖ Structured control-flow ★ if-then-else, while ❖ Procedural abstraction ★ procedures, first-class functions (closures) ❖ Memory management ★ garbage collection ❖ Data abstraction ★ abstract data types, objects ❖ Modules ★ inheritance, traits, mixins
  • 14. “A programming language is low level when its programs require attention to the irrelevant” Alan J. Perlis. Epigrams on Programming. SIGPLAN Notices, 17(9):7-13, 1982.
  • 15. Do HLLs eliminate all irrelevant details? What about ❖ data persistence ❖ data services ❖ concurrency ❖ distribution ❖ access control ❖ data invariants ❖ workflow ❖ ...
  • 16. Do HLLs eliminate all irrelevant details? What about ❖ data persistence ❖ data services ❖ concurrency ❖ distribution ❖ access control ❖ data invariants ❖ workflow ❖ ... many of these concerns require programmatic encodings
  • 17. What is the Next Level of Abstraction? Problem Domain HLL Machine
  • 19. Example: Encoding Units compiler computerinput input distance : Float; input duration : Float; output speed : Float := duration / distance; output
  • 20. Example: Encoding Units compiler computerinput input distance : Float; input duration : Float; output speed : Float := duration / distance; error wrong output
  • 21. Impact of Software Errors compiler computer error Mars Climate Orbiter Unit mismatch: Orbiter variables in Newtons, Ground control software in Pound-force. Damage: ~350 M$ input distance : Float; input duration : Float; output speed : Float := duration / distance; wrong output
  • 22. Example: Explicit Representation of Units computer input distance : Meter; input duration : Second; output speed : Meter/Second := duration / distance; compiler formalize knowledge of application area (domain) in language error
  • 23. DSLs Provide Domain-Specific ... Abstractions ★ directly represent domain concepts Concrete syntax ★ natural notation Optimization ★ based on domain assumptions Error checking ★ report errors in terms of domain concepts Tool support ★ interpreter, compiler, code generator, IDE
  • 24. Internal DSL Library in HLL ★ Haskell, Scala, Ruby, ... ★ API is language ★ language features for ‘linguistic abstraction’ Advantages ★ host language = implementation language Disadvantages ★ host language = implementation language (encoding) ★ no portability ★ no domain-specific errors, analysis, optimization
  • 25. External DSL Dedicated language ★ independent of host/target language (portable) ★ implementation with interpreter or compiler Advantages ★ language tuned to domain ★ domain-specific errors, analysis, optimizations Disadvantages ★ cost of learning new language ★ cost of maintaining language
  • 26. Example DSLs (1) Spreadsheet ★ formulas, macros Querying ★ SQL, XQuery, XPath Graph layout ★ GraphViz Web ★ HTML, CSS, RSS, XML, XSLT ★ Ruby/Rails, JSP, ASP, JSF, WebDSL
  • 27. Example DSLs (2) Games ★ Lua, UnrealScript Modeling ★ UML, OCL, QVT Language engineering ★ YACC, LEX, RegExp, ANTLR, SDF ★ TXL, ASF+SDF, Stratego
  • 29. browser server database web app Web Programming
  • 30. browser server database Java SQL HTML, JS, CSS Web Programming = Distributed Programming
  • 31. Concerns in Web Programming Data Persistence Access Control Injection Attacks Search XSS DataValidation Data Binding Routing ... ...
  • 32. Zef Hemel, Danny M. Groenewegen, Lennart C. L. Kats, EelcoVisser. Static consistency checking of web applications with WebDSL. Journal of Symbolic Computation, 46(2):150-182, 2011. Late Failure Detection in Web Applications
  • 33. Complexity in Web Programming: Multiple Languages x Multiple Concerns Consistency not statically checked
  • 34. EelcoVisser. WebDSL: A Case Study in Domain-Specific Language Engineering. In Ralf Lämmel, JoostVisser, João Saraiva, editors, Generative and Transformational Techniques in Software Engineering II, International Summer School, GTTSE 2007.Volume 5235 of Lecture Notes in Computer Science, pages 291-373, Springer, Braga, Portugal, 2007. Separation of Concerns & Linguistic Integration
  • 35.
  • 37. http://eelcovisser.org/blog/post/42/dsl-engineering “http://” + “eelcovisser.org” // host domain + “blog” // application name + “post” // page + “42” // identity + “dsl-engineering” // title
  • 38. page blog(b: Blog, index: Int) { main(b){ for(p: Post in b.recentPosts(index,5)) { section{ header{ navigate post(p) { output(p.title) } } par{ output(p.content) } par{ output(p.created.format("MMMM d, yyyy")) } } } } page post(p: Post) { ... } Statically checked navigation
  • 39. entity Blog { key :: String (id) title :: String (name) posts -> Set<Post> (inverse=Post.blog) function recentPosts(index: Int, n: Int): List<Post> { var i := max(1,index) - 1; return [p | p: Post in posts order by p.created desc limit n offset i*n].list(); } } entity Post { key :: String (id) title :: String (name, searchable) content :: WikiText (searchable) blog -> Blog } Persistent Data Models Generation of queries: no injection attacks
  • 40. entity Assignment { key :: String (id) title :: String (name, searchable) shortTitle :: String description :: WikiText (searchable) course -> CourseEdition (searchable) weight :: Float (default=1.0) deadline :: DateTime (default=null) // ... } page assignment(assign: Assignment, tab: String) { main{ progress(assign, tab) pageHeader{ output(assign.title) breadcrumbs(assign) } // ... } } Persistent variables in WebDSL http://department.st.ewi.tudelft.nl/weblab/assignment/752 objects are automatically persisted in database 1 2 3
  • 41. page post(p: Post) { ... } page editpost(p: Post) { action save() { return blog(p); } main(p.blog){ form{ formEntry("Title"){ input(p.title) } formEntry("Content") { input(p.content) } formEntry("Posted") { input(p.created) } submit save() { "Save" } } } } Forms & Data Binding No separate controller!
  • 42. access control rules principal is User with credentials username, password rule page blog(b: Blog, index: Int) { true } rule page post(p: Post) { p.public || p.author == principal } rule page editpost(p: Post) { principal == p.author } extend entity User { password :: Secret } extend entity Blog { owner -> User } extend entity Post { public :: Bool } Declarative Access Control Rules
  • 43. Linguistically Integrated Persistent data model Logic Templates (UI, Email, Service) Data binding Access control Data validation Faceted search Collaborative filtering
  • 44. DSL Summary software reuse through linguistic abstraction • capture understanding of design patterns in language concepts • abstract from accidental complexity • program in terms of domain concepts • automatically generate implementation
  • 45. When to Use/Create DSLs? Hierarchy of abstractions • first understand how to program it • make variations by copy, paste, adapt • (avoid over-engineering) • make library of frequently used patterns • find existing (internal) DSLs for the domain Time for a DSL? • large class of applications using same design patterns • design patterns cannot be captured in PL • lack of checking / optimization for DSL abstractions
  • 47. object ExpParser extends JavaTokenParsers with PackratParsers { lazy val exp: PackratParser[Exp] = (exp <~ "+") ~ exp1 ^^ { case lhs~rhs => Add(lhs, rhs) } | exp1 lazy val exp1: PackratParser[Exp] = (exp1 ~ exp0) ^^ { case lhs~rhs => App(lhs, rhs) } | exp0 lazy val exp0: PackratParser[Exp] = number | identifier | function | letBinding | "(" ~> exp <~ ")" // ... def parse(text: String) = parseAll(exp, text) } syntax through parsers
  • 48. sealed abstract class Value case class numV(n: Int) extends Value case class closureV(param: Symbol, body: Exp, env: Env) extends Value def eval(exp: Exp, env: Env): Value = exp match { case Num(v) => numV(v) case Add(l, r) => plus(eval(l, env), eval(r, env)) case Id(name) => lookup(name, env) case Let(name, e1, e2) => eval(e2, bind(name, eval(e1, env), env)) case Fun(name, body) => closureV(name, body, env) case App(fun, arg) => eval(fun, env) match { case closureV(name, body, env2) => eval(body, bind(name, eval(arg, env), env2)) case _ => sys.error("Closure expected") } } semantics through interpreter
  • 51. Traditional Compilers ls Course.java javac -verbose Course.java [parsing started Course.java] [parsing completed 8ms] [loading java/lang/Object.class(java/lang:Object.class)] [checking university.Course] [wrote Course.class] [total 411ms]
  • 52. Traditional Compilers ls Course.java javac -verbose Course.java [parsing started Course.java] [parsing completed 8ms] [loading java/lang/Object.class(java/lang:Object.class)] [checking university.Course] [wrote Course.class] [total 411ms] ls Course.class Course.java
  • 53. Language Processors syntax analysis • parsing • AST construction static analysis • name analysis • type analysis semantics • generation • interpretation
  • 55. Modern Compilers in IDEs syntactic editor services • syntax checking • syntax highlighting • outline view • code folding • bracket matching semantic editor services • error checking • reference resolving • hover help • content completion • refactoring
  • 56. Eclipse Platform runtime platform • composition • integration development platform • complex APIs • abstractions for Eclipse IDEs • concepts: editors, views, label provider, label provider factory, … • tedious, boring, frustrating
  • 57. Spoofax Language Workbench declarative meta-languages • syntax definition • editor services • term rewriting implementation • generic integration into Eclipse and IMP • compilation & interpretation of language definitions agile • Spoofax & IDE under development in same Eclipse instance • support for test-driven development
  • 58. A Taste of Language Engineering with Spoofax • abstract syntax trees • declarative syntax definition • name binding and scope • transformation by term rewriting
  • 59. EnFun: Entities with Functions module blog entity String { function plus(that:String): String } entity Bool { } entity Set<T> { function add(x: T) function remove(x: T) function member(x: T): Bool } entity Blog { posts : Set<Post> function newPost(): Post { var p : Post := Post.new(); posts.add(p); } } entity Post { title : String }
  • 61. Signature & Terms constructors Module : ID * List(Definition) -> Module Imports : ID -> Definition Module( "application" , [Imports("library"), Imports("users"), Imports("frontend")] )
  • 62. Entities & Properties constructors Entity : ID * List(Property) -> Definition Type : ID -> Type New : Type -> Exp constructors Property : ID * Type -> Property This : Exp PropAccess : Exp * ID -> Exp Module("users" , [ Imports("library") , Entity("User" , [ Property("email", Type("String")) , Property("password", Type("String")) , Property("isAdmin", Type("Bool"))])])
  • 63. Parsing: From Text to Structure
  • 64. Declarative Syntax Definition Entity("User", [ Property("first", Type("String")), Property("last", Type("String")) ]) signature constructors Entity : ID * List(Property) -> Definition Type : ID -> Type Property : ID * Type -> Property
  • 65. Declarative Syntax Definition entity User { first : String last : String } Entity("User", [ Property("first", Type("String")), Property("last", Type("String")) ]) signature constructors Entity : ID * List(Property) -> Definition Type : ID -> Type Property : ID * Type -> Property
  • 66. Declarative Syntax Definition entity User { first : String last : String } Entity("User", [ Property("first", Type("String")), Property("last", Type("String")) ]) signature constructors Entity : ID * List(Property) -> Definition Type : ID -> Type Property : ID * Type -> Property context-free syntax "entity" ID "{" Property* "}" -> Definition {"Entity"} ID -> Type {"Type"} ID ":" Type -> Property {"Property"}
  • 68. Context-free Syntax constructors True : Exp False : Exp Not : Exp -> Exp And : Exp * Exp -> Exp Or : Exp * Exp -> Exp context-free syntax "true" -> Exp {"True"} "false" -> Exp {"False"} "!" Exp -> Exp {"Not"} Exp "&&" Exp -> Exp {"And"} Exp "||" Exp -> Exp {"Or"}
  • 69. Lexical Syntax constructors True : Exp False : Exp Not : Exp -> Exp And : Exp * Exp -> Exp Or : Exp * Exp -> Exp context-free syntax "true" -> Exp {"True"} "false" -> Exp {"False"} "!" Exp -> Exp {"Not"} Exp "&&" Exp -> Exp {"And"} Exp "||" Exp -> Exp {"Or"} lexical syntax [a-zA-Z][a-zA-Z0-9]* -> ID "-"? [0-9]+ -> INT [ tnr] -> LAYOUT constructors : String -> ID : String -> INT scannerless generalized (LR) parsing form of tokens (words, lexemes)
  • 70. Ambiguity constructors True : Exp False : Exp Not : Exp -> Exp And : Exp * Exp -> Exp Or : Exp * Exp -> Exp context-free syntax "true" -> Exp {"True"} "false" -> Exp {"False"} "!" Exp -> Exp {"Not"} Exp "&&" Exp -> Exp {"And"} Exp "||" Exp -> Exp {"Or"} isPublic || isDraft && (author == principal())
  • 71. Ambiguity constructors True : Exp False : Exp Not : Exp -> Exp And : Exp * Exp -> Exp Or : Exp * Exp -> Exp context-free syntax "true" -> Exp {"True"} "false" -> Exp {"False"} "!" Exp -> Exp {"Not"} Exp "&&" Exp -> Exp {"And"} Exp "||" Exp -> Exp {"Or"} isPublic || isDraft && (author == principal()) amb([ And(Or(Var("isPublic"), Var("isDraft")), Eq(Var("author"), ThisCall("principal", []))), Or(Var("isPublic"), And(Var("isDraft"), Eq(Var("author"), ThisCall("principal", [])))) ])
  • 72. Disambiguation by Encoding Precedence constructors True : Exp False : Exp Not : Exp -> Exp And : Exp * Exp -> Exp Or : Exp * Exp -> Exp context-free syntax "true" -> Exp {"True"} "false" -> Exp {"False"} "!" Exp -> Exp {"Not"} Exp "&&" Exp -> Exp {"And"} Exp "||" Exp -> Exp {"Or"} context-free syntax "(" Exp ")" -> Exp0 {bracket} "true" -> Exp0 {"True"} "false" -> Exp0 {"False"} Exp0 -> Exp1 "!" Exp0 -> Exp1 {"Not"} Exp1 -> Exp2 Exp1 "&&" Exp2 -> Exp2 {"And"} Exp2 -> Exp3 Exp2 "||" Exp3 -> Exp3 {"Or"}
  • 73. Declarative Disambiguation context-free syntax "true" -> Exp {"True"} "false" -> Exp {"False"} "!" Exp -> Exp {"Not"} Exp "&&" Exp -> Exp {"And", left} Exp "||" Exp -> Exp {"Or", left} "(" Exp ")" -> Exp {bracket} context-free priorities {left: Exp.Not} > {left: Exp.Mul} > {left: Exp.Plus Exp.Minus} > {left: Exp.And} > {non-assoc: Exp.Eq Exp.Lt Exp.Gt Exp.Leq Exp.Geq} isPublic || isDraft && (author == principal()) Or(Var("isPublic"), And(Var("isDraft"), Eq(Var("author"), ThisCall("principal", []))))
  • 75. Definitions and References module test entity String { } entity User { first : String last : String } definition reference
  • 77. From Tree to Graph Module( "test" , [ Entity("String", []) , Entity( "User" , [ Property("first", ) , Property("last", ) ] ) ] )
  • 78. NaBL: Name Binding Language module names imports include/Cam namespaces Type Property Function Variable rules Entity(name, None(), None(), _): defines Type name of type Type(name, []) scopes Type, Function, Property, Variable Type(name, _): refers to Type name
  • 80. Transformation by Strategic Rewriting rules desugar: Plus(e1, e2) -> MethCall(e1, "plus", [e2]) desugar: Or(e1, e2) -> MethCall(e1, "or", [e2]) desugar : VarDeclInit(x, t, e) -> Seq([VarDecl(x, t), Assign(Var(x), e)]) strategies desugar-all = topdown(repeat(desugar))
  • 81. Return-Lifting Applied function fact(n: Int): Int { var res: Int; if(n == 0) { res := 1; } else { res := this * fact(n - 1); } return res; } function fact(n: Int): Int { if(n == 0) { return 1; } else { return this * fact(n - 1); } }
  • 82. Return-Lifting Rules rules lift-return-all = alltd(lift-return; normalize-all) lift-return : FunDef(x, arg*, Some(t), stat1*) -> FunDef(x, arg*, Some(t), Seq([ VarDecl(y, t), Seq(stat2*), Return(Var(y)) ])) where y := <new>; stat2* := <alltd(replace-return(|y))> stat1* replace-return(|y) : Return(e) -> Assign(y, e)
  • 83. Language Engineering Summary apply linguistic abstraction to language engineering • declarative languages for language definition • automatic derivation of efficient compilers • automatic derivation of IDEs
  • 85. Example: Explicit Representation of Units computer input distance : Meter; input duration : Second; output speed : Meter/Second := duration / distance; compiler formalize knowledge of application area (domain) in language error
  • 86. error Problem: Correctness of Language Definitions computer compiler Can we trust the compiler? wrong outputinput program type soundness: well-typed programs don’t go wrong
  • 87. compiler error Challenge:AutomaticVerification of Correctness computer compiler wrong output program type soundness: well-typed programs don’t go wrong type checker code generator input
  • 88. Correctness Proof Language Workbench State-of-the-Art: Language Engineering Syntax Checker Name Resolver Type Checker Code Generator focus on implementation; not suitable for verification Compiler Editor (IDE) Tests
  • 89. Formal Language Specification State-of-the-Art: Semantics Engineering Abstract Syntax Type System Dynamic Semantics Transforms focus on (only semi-automatic) verification; not suitable for implementation Correctness Proof TestsCompiler Editor (IDE)
  • 90. Declarative Language Definition My Approach: Multi-Purpose Language Definitions Syntax Definition Name Binding Type System Dynamic Semantics Transforms Compiler Editor (IDE) Correctness Proof Tests bridging the gap between language engineering and semantics engineering
  • 91. Software Development on the Web revisiting the architecture of the IDE
  • 92. Exam
  • 93. Syntax and Semantics Names, Bindings, and Scopes Storage Data Types Functional Programming First-class Functions Polymorphism Type Parameterization Parsing and Interpretation Data Abstraction / Modular Programming Functional Programming Redux Concurrency Concurrent Programming Domain-Specific Languages Quarter 3 Quarter 4 Basics of Scala JavaScript C
  • 94. Material for exam Slides from lectures Tutorial exercises Graded assignments Sebesta: Chapters 1-13, 15 Programming in Scala: Chapters 1, 4-16, 19, 32-33 K&R C: Chapters 1-6 JavaScript Good Parts: Chapters 1-4
  • 95. Content of exam 10% multiple choice questions about concepts 50% Scala programming (functional programming) 20% C programming (structures and pointers) 20% JavaScript programming (objects and prototypes)
  • 96. Registration for Exam is Required http://department.st.ewi.tudelft.nl/weblab/assignment/761 -> your submission