SlideShare a Scribd company logo
DSLs: what, why, how?
What is a DSL?
DSL computer programming language
limited expressiveness
particular domain
used by humans to instruct a computer
bare minimum of features
entire system can’t be built in a DSL
sense of fluency
domain focus makes a limited language worthwhile
executable by a computer
language nature
Internal vs. external DSLs
internal DSL
external DSL
a particular way to use a GPL
embedded into GPL
script in internal DSL valid code in its host GPL
only uses a subset of GPL’s features
has a feel of custom language rather than its host language
Ruby on Rails often seen as a collection of DSLs
a separate language has custom syntax
script in external DSL parsed using text parsing techniques
Unix little languages
Graph g =
graph("example1")
.directed()
.with(
node("a")
.link(
node("b")
)
);
Command-query APIs
methods on an object
command
query
commands queries
returns a value
does not change the state of the system
may change state of the system
should not return a value
doesn’t have side effects
can be called multiple times in any order without changing the results
does have side effects
should make sense in stand-alone contextnames of methods
obj.getName()
obj.removeAt(1)
obj.toString()
obj.setName(’a’)
Command-query APIs Vaadin Framework
domain rich Internet applications
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
@Title("My UI")
public class HelloWorld extends UI {
@Override
protected void init(VaadinRequest request) {
// Create the content root layout for the UI
VerticalLayout content = new VerticalLayout();
setContent(content);
// Display the greeting
content.addComponent(new Label("Hello World!"));
// Have a clickable button
content.addComponent(new Button("Push Me!",
click -> Notification.show("Pushed!")));
}
} semantic model
http://vaadin.com
Vaadin-based language
HelloWorld {
Component content = VerticalLayout {
Component myLabel = Label {
String Label caption = “Hello world!”;
}
Component myButton = Button {
String Button caption = “Push Me!”;
Function changeCaption = () {
caption = “Pushed!”;
} listens to click;
}
}
}
HelloWorld {
VerticalLayout {
Label “Hello world!”;
Button “Push Me!” {
when click: caption = “Pushed”;
}
}
}
TouchScript (H. Westergård, 2013)
layout vertically:
label “Hello world!”
button “Push Me!” as myButton
events for myButton:
click { caption = “Pushed”; }
“Hello world!”
[“Push Me!”]
when click on [“Push Me!”] -> [“Pushed”]
numerous options on how to define a DSL
[ ] – represent a button
no names for components
“transformation operator”
similar to REBOL syntaxview layout [text "Hello world!" button "Quit" [quit]]
Why use a DSL?
tool with limited focusDSL
very specific tool for very particular conditions
typical project uses a dozen of DSLs
improving development productivity
communication with domain experts
change in execution context
alternative computation model
shift logic from compile time to runtime
The Why: development productivity
communicate intent of a part of a system
easier to understand DSLDSL vs. command-query API
aestheticsnot only code is easier to read
easier to find mistakes
easier to modify the system
limited expressiveness harder to express wrong things
DSL to wrap awkward third-party library
The Why: domain experts
domain experts
read code
write code
understand what the system thinks it’s doing
spot mistakes
talk more effectively to programmers
focus on reading code not writing
DSL shouldn’t necessarily be implemented useful to describe the system
communication issues
involving domain experts is difficult but has a high payoff
The Why: alternative computation model
mainstream programming imperative what to do and in what sequence
conditionals loopscontrol flow
declarative what should happen rather than how it should happen
state machine
decision table
Problems with DSLs (1)
language “hell”
cost of building
languages are hard to learn
far easier to learnDSL simpler than GPL
people aren’t used to building DSLs
cost of a DSL model
help think about the model reduce cost of building itDSL
too many DSLs bad DSLs
good DSL wrap a bad library
make it easier to deal with
waste of resources to maintain
cost over the cost of
Problems with DSLs (2)
ghetto language
limited
abstraction
the whole system built in a language it’s a GPL!
DSL GPLmight evolve into a
DSL should be focused on a narrow problem
ideally no features that fall outside that
DSL provides abstraction to think about subject area
behavior of the domain expressed easier
than using lower-level constructs
the world is fit into abstraction instead of the other way around
DSL something evolving unfinished

More Related Content

What's hot (20)

PPTX
Programming Languages
Edward Blurock
 
PDF
Envisioning the Future of Language Workbenches
Markus Voelter
 
PPTX
Architecting Domain-Specific Languages
Markus Voelter
 
PDF
BDD Testing Using Godog - Bangalore Golang Meetup # 32
OpenEBS
 
PPTX
From Programming to Modeling And Back Again
Markus Voelter
 
PPTX
CS152 Programming Paradigm
Kaya Ota
 
PDF
Build your own Language - Why and How?
Markus Voelter
 
PDF
Algorithm pseudocode flowchart program notes
ArghodeepPaul
 
PPTX
Programming Paradigm & Languages
Gaditek
 
PPT
SD & D Types of programming language
Forrester High School
 
PPT
Introduction to Go-Lang
Folio3 Software
 
PPT
SD & D Implementation
Forrester High School
 
PPT
Text Editors and IDEs
Forrester High School
 
PDF
Code Generation in Perl
Ian Kluft
 
PDF
Windows script host
ArghodeepPaul
 
PPTX
single pass compiler and its architecture
noor ul ain
 
PDF
Windows batch scripting
ArghodeepPaul
 
PDF
ALPHA Script - Concept
PROBOTEK
 
PPT
Metaprogramming by brandon
MaslowB
 
Programming Languages
Edward Blurock
 
Envisioning the Future of Language Workbenches
Markus Voelter
 
Architecting Domain-Specific Languages
Markus Voelter
 
BDD Testing Using Godog - Bangalore Golang Meetup # 32
OpenEBS
 
From Programming to Modeling And Back Again
Markus Voelter
 
CS152 Programming Paradigm
Kaya Ota
 
Build your own Language - Why and How?
Markus Voelter
 
Algorithm pseudocode flowchart program notes
ArghodeepPaul
 
Programming Paradigm & Languages
Gaditek
 
SD & D Types of programming language
Forrester High School
 
Introduction to Go-Lang
Folio3 Software
 
SD & D Implementation
Forrester High School
 
Text Editors and IDEs
Forrester High School
 
Code Generation in Perl
Ian Kluft
 
Windows script host
ArghodeepPaul
 
single pass compiler and its architecture
noor ul ain
 
Windows batch scripting
ArghodeepPaul
 
ALPHA Script - Concept
PROBOTEK
 
Metaprogramming by brandon
MaslowB
 

Similar to DSLs: what, why, how (20)

PPTX
Bdd and dsl как способ построения коммуникации на проекте
ISsoft
 
PPTX
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
SQALab
 
PPTX
AestasIT - Internal DSLs in Scala
Dmitry Buzdin
 
PPT
DSL explained _
Dmitry Kandalov
 
PDF
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Skills Matter
 
PPT
Generative Programming from a DSL Viewpoint
elliando dias
 
PDF
Building DSLs On CLR and DLR (Microsoft.NET)
Vitaly Baum
 
PDF
What if-your-application-could-speak
Marcos Vinícius
 
PDF
What if-your-application-could-speak, by Marcos Silveira
Thoughtworks
 
PDF
DSLs in JavaScript
elliando dias
 
PDF
Domain Specific Languages
elliando dias
 
PDF
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
Harshal Hayatnagarkar
 
PDF
Reverse-Engineering Reusable Language Modules from Legacy DSLs
David Méndez-Acuña
 
PPTX
Specification Scala DSL for Mobile Application
Alexander Evseenko
 
PDF
Metamorphic Domain-Specific Languages
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PDF
TI1220 Lecture 14: Domain-Specific Languages
Eelco Visser
 
PDF
Using Scala for building DSLs
IndicThreads
 
PPTX
Creating a textual domain specific language
Vicente García Díaz
 
PDF
Writing a DSL for the Dense with Scala - JVMCon
Jan-Hendrik Kuperus
 
PDF
ModelTalk - When Everything is a Domain Specific Language
Atzmon Hen-Tov
 
Bdd and dsl как способ построения коммуникации на проекте
ISsoft
 
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
SQALab
 
AestasIT - Internal DSLs in Scala
Dmitry Buzdin
 
DSL explained _
Dmitry Kandalov
 
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Skills Matter
 
Generative Programming from a DSL Viewpoint
elliando dias
 
Building DSLs On CLR and DLR (Microsoft.NET)
Vitaly Baum
 
What if-your-application-could-speak
Marcos Vinícius
 
What if-your-application-could-speak, by Marcos Silveira
Thoughtworks
 
DSLs in JavaScript
elliando dias
 
Domain Specific Languages
elliando dias
 
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
Harshal Hayatnagarkar
 
Reverse-Engineering Reusable Language Modules from Legacy DSLs
David Méndez-Acuña
 
Specification Scala DSL for Mobile Application
Alexander Evseenko
 
Metamorphic Domain-Specific Languages
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
TI1220 Lecture 14: Domain-Specific Languages
Eelco Visser
 
Using Scala for building DSLs
IndicThreads
 
Creating a textual domain specific language
Vicente García Díaz
 
Writing a DSL for the Dense with Scala - JVMCon
Jan-Hendrik Kuperus
 
ModelTalk - When Everything is a Domain Specific Language
Atzmon Hen-Tov
 
Ad

More from Mikhail Barash (20)

PDF
MODELS 2020 Tutorial on MPS - Supplementary Material 8 - TextGen
Mikhail Barash
 
PDF
MODELS 2020 Tutorial on MPS - Supplementary Material 5 - Creating concept Ent...
Mikhail Barash
 
PDF
MODELS 2020 Tutorial on MPS - Supplementary Material 3 - Creating editors for...
Mikhail Barash
 
PDF
MODELS 2020 Tutorial on MPS - Supplementary Material 1 - Creating concept Entity
Mikhail Barash
 
PDF
Towards a mnemonic classification of software languages
Mikhail Barash
 
PDF
Worst practices for domain-specific modelling
Mikhail Barash
 
PPTX
An ABC of JetBrains MPS
Mikhail Barash
 
PDF
KernelF: a functional core for domain-specific languages in JetBrains MPS
Mikhail Barash
 
PDF
Reflections on teaching JetBrains MPS within a university course
Mikhail Barash
 
PDF
Language Workbench Language Wheel
Mikhail Barash
 
PDF
Design dimensions of DSLs
Mikhail Barash
 
PDF
JetBrains MPS: Typesystem Aspect
Mikhail Barash
 
PDF
JetBrains MPS: Editor Aspect
Mikhail Barash
 
PDF
JetBrains MPS: Structure Aspect
Mikhail Barash
 
PDF
Projectional editing
Mikhail Barash
 
PDF
Xtext: type checking and scoping
Mikhail Barash
 
PDF
Xtext: code generation
Mikhail Barash
 
PDF
Xtext: validation, quickfixes, custom formatting
Mikhail Barash
 
PDF
Xtend Programming Language
Mikhail Barash
 
PDF
Xtext: Eclipse Modeling Framework
Mikhail Barash
 
MODELS 2020 Tutorial on MPS - Supplementary Material 8 - TextGen
Mikhail Barash
 
MODELS 2020 Tutorial on MPS - Supplementary Material 5 - Creating concept Ent...
Mikhail Barash
 
MODELS 2020 Tutorial on MPS - Supplementary Material 3 - Creating editors for...
Mikhail Barash
 
MODELS 2020 Tutorial on MPS - Supplementary Material 1 - Creating concept Entity
Mikhail Barash
 
Towards a mnemonic classification of software languages
Mikhail Barash
 
Worst practices for domain-specific modelling
Mikhail Barash
 
An ABC of JetBrains MPS
Mikhail Barash
 
KernelF: a functional core for domain-specific languages in JetBrains MPS
Mikhail Barash
 
Reflections on teaching JetBrains MPS within a university course
Mikhail Barash
 
Language Workbench Language Wheel
Mikhail Barash
 
Design dimensions of DSLs
Mikhail Barash
 
JetBrains MPS: Typesystem Aspect
Mikhail Barash
 
JetBrains MPS: Editor Aspect
Mikhail Barash
 
JetBrains MPS: Structure Aspect
Mikhail Barash
 
Projectional editing
Mikhail Barash
 
Xtext: type checking and scoping
Mikhail Barash
 
Xtext: code generation
Mikhail Barash
 
Xtext: validation, quickfixes, custom formatting
Mikhail Barash
 
Xtend Programming Language
Mikhail Barash
 
Xtext: Eclipse Modeling Framework
Mikhail Barash
 
Ad

Recently uploaded (20)

PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
AI Software Engineering based on Multi-view Modeling and Engineering Patterns
Hironori Washizaki
 
PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
PPTX
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
AI Software Engineering based on Multi-view Modeling and Engineering Patterns
Hironori Washizaki
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
Activate_Methodology_Summary presentatio
annapureddyn
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 

DSLs: what, why, how

  • 2. What is a DSL? DSL computer programming language limited expressiveness particular domain used by humans to instruct a computer bare minimum of features entire system can’t be built in a DSL sense of fluency domain focus makes a limited language worthwhile executable by a computer language nature
  • 3. Internal vs. external DSLs internal DSL external DSL a particular way to use a GPL embedded into GPL script in internal DSL valid code in its host GPL only uses a subset of GPL’s features has a feel of custom language rather than its host language Ruby on Rails often seen as a collection of DSLs a separate language has custom syntax script in external DSL parsed using text parsing techniques Unix little languages Graph g = graph("example1") .directed() .with( node("a") .link( node("b") ) );
  • 4. Command-query APIs methods on an object command query commands queries returns a value does not change the state of the system may change state of the system should not return a value doesn’t have side effects can be called multiple times in any order without changing the results does have side effects should make sense in stand-alone contextnames of methods obj.getName() obj.removeAt(1) obj.toString() obj.setName(’a’)
  • 5. Command-query APIs Vaadin Framework domain rich Internet applications import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @Title("My UI") public class HelloWorld extends UI { @Override protected void init(VaadinRequest request) { // Create the content root layout for the UI VerticalLayout content = new VerticalLayout(); setContent(content); // Display the greeting content.addComponent(new Label("Hello World!")); // Have a clickable button content.addComponent(new Button("Push Me!", click -> Notification.show("Pushed!"))); } } semantic model http://vaadin.com
  • 6. Vaadin-based language HelloWorld { Component content = VerticalLayout { Component myLabel = Label { String Label caption = “Hello world!”; } Component myButton = Button { String Button caption = “Push Me!”; Function changeCaption = () { caption = “Pushed!”; } listens to click; } } } HelloWorld { VerticalLayout { Label “Hello world!”; Button “Push Me!” { when click: caption = “Pushed”; } } } TouchScript (H. Westergård, 2013) layout vertically: label “Hello world!” button “Push Me!” as myButton events for myButton: click { caption = “Pushed”; } “Hello world!” [“Push Me!”] when click on [“Push Me!”] -> [“Pushed”] numerous options on how to define a DSL [ ] – represent a button no names for components “transformation operator” similar to REBOL syntaxview layout [text "Hello world!" button "Quit" [quit]]
  • 7. Why use a DSL? tool with limited focusDSL very specific tool for very particular conditions typical project uses a dozen of DSLs improving development productivity communication with domain experts change in execution context alternative computation model shift logic from compile time to runtime
  • 8. The Why: development productivity communicate intent of a part of a system easier to understand DSLDSL vs. command-query API aestheticsnot only code is easier to read easier to find mistakes easier to modify the system limited expressiveness harder to express wrong things DSL to wrap awkward third-party library
  • 9. The Why: domain experts domain experts read code write code understand what the system thinks it’s doing spot mistakes talk more effectively to programmers focus on reading code not writing DSL shouldn’t necessarily be implemented useful to describe the system communication issues involving domain experts is difficult but has a high payoff
  • 10. The Why: alternative computation model mainstream programming imperative what to do and in what sequence conditionals loopscontrol flow declarative what should happen rather than how it should happen state machine decision table
  • 11. Problems with DSLs (1) language “hell” cost of building languages are hard to learn far easier to learnDSL simpler than GPL people aren’t used to building DSLs cost of a DSL model help think about the model reduce cost of building itDSL too many DSLs bad DSLs good DSL wrap a bad library make it easier to deal with waste of resources to maintain cost over the cost of
  • 12. Problems with DSLs (2) ghetto language limited abstraction the whole system built in a language it’s a GPL! DSL GPLmight evolve into a DSL should be focused on a narrow problem ideally no features that fall outside that DSL provides abstraction to think about subject area behavior of the domain expressed easier than using lower-level constructs the world is fit into abstraction instead of the other way around DSL something evolving unfinished