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

PDF
Zoo of domain-specific languages
PDF
Language Workbenches
PDF
Implementing DSLs in practice
PDF
DSL development
PDF
Design concerns for concrete syntax
PDF
Internal domain-specific languages
PPT
Programming paradigm and web programming
PPT
Lecture 10 software development
Zoo of domain-specific languages
Language Workbenches
Implementing DSLs in practice
DSL development
Design concerns for concrete syntax
Internal domain-specific languages
Programming paradigm and web programming
Lecture 10 software development

What's hot (20)

PPTX
Programming Languages
PDF
Envisioning the Future of Language Workbenches
PPTX
Architecting Domain-Specific Languages
PDF
BDD Testing Using Godog - Bangalore Golang Meetup # 32
PPTX
From Programming to Modeling And Back Again
PPTX
CS152 Programming Paradigm
PDF
Build your own Language - Why and How?
PDF
Algorithm pseudocode flowchart program notes
PPTX
Programming Paradigm & Languages
PPT
SD & D Types of programming language
PPT
Introduction to Go-Lang
PPT
SD & D Implementation
PPT
Text Editors and IDEs
PDF
Code Generation in Perl
PDF
Windows script host
PPTX
single pass compiler and its architecture
PDF
Windows batch scripting
PDF
ALPHA Script - Concept
PPT
Metaprogramming by brandon
Programming Languages
Envisioning the Future of Language Workbenches
Architecting Domain-Specific Languages
BDD Testing Using Godog - Bangalore Golang Meetup # 32
From Programming to Modeling And Back Again
CS152 Programming Paradigm
Build your own Language - Why and How?
Algorithm pseudocode flowchart program notes
Programming Paradigm & Languages
SD & D Types of programming language
Introduction to Go-Lang
SD & D Implementation
Text Editors and IDEs
Code Generation in Perl
Windows script host
single pass compiler and its architecture
Windows batch scripting
ALPHA Script - Concept
Metaprogramming by brandon
Ad

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

PPTX
Bdd and dsl как способ построения коммуникации на проекте
PPTX
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
PPTX
AestasIT - Internal DSLs in Scala
PPT
DSL explained _
PDF
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
PPT
Generative Programming from a DSL Viewpoint
PDF
Building DSLs On CLR and DLR (Microsoft.NET)
PDF
What if-your-application-could-speak
PDF
What if-your-application-could-speak, by Marcos Silveira
PDF
DSLs in JavaScript
PDF
Domain Specific Languages
PDF
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
PDF
Reverse-Engineering Reusable Language Modules from Legacy DSLs
PPTX
Specification Scala DSL for Mobile Application
PDF
Metamorphic Domain-Specific Languages
PDF
TI1220 Lecture 14: Domain-Specific Languages
PDF
Using Scala for building DSLs
PPTX
Creating a textual domain specific language
PDF
Writing a DSL for the Dense with Scala - JVMCon
PDF
ModelTalk - When Everything is a Domain Specific Language
Bdd and dsl как способ построения коммуникации на проекте
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
AestasIT - Internal DSLs in Scala
DSL explained _
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Generative Programming from a DSL Viewpoint
Building DSLs On CLR and DLR (Microsoft.NET)
What if-your-application-could-speak
What if-your-application-could-speak, by Marcos Silveira
DSLs in JavaScript
Domain Specific Languages
DSL Construction with Ruby - ThoughtWorks Masterclass Series 2009
Reverse-Engineering Reusable Language Modules from Legacy DSLs
Specification Scala DSL for Mobile Application
Metamorphic Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
Using Scala for building DSLs
Creating a textual domain specific language
Writing a DSL for the Dense with Scala - JVMCon
ModelTalk - When Everything is a Domain Specific Language
Ad

More from Mikhail Barash (20)

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

Recently uploaded (20)

PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PDF
infoteam HELLAS company profile 2025 presentation
PDF
Microsoft Office 365 Crack Download Free
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PPTX
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Human-Computer Interaction for Lecture 2
PPTX
Presentation by Samna Perveen And Subhan Afzal.pptx
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
Workplace Software and Skills - OpenStax
PDF
Guide to Food Delivery App Development.pdf
PDF
AI Guide for Business Growth - Arna Softech
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
PDF
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
infoteam HELLAS company profile 2025 presentation
Microsoft Office 365 Crack Download Free
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
What Makes a Great Data Visualization Consulting Service.pdf
Plex Media Server 1.28.2.6151 With Crac5 2022 Free .
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
BoxLang Dynamic AWS Lambda - Japan Edition
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Human-Computer Interaction for Lecture 2
Presentation by Samna Perveen And Subhan Afzal.pptx
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
Full-Stack Developer Courses That Actually Land You Jobs
Workplace Software and Skills - OpenStax
Guide to Food Delivery App Development.pdf
AI Guide for Business Growth - Arna Softech
CapCut PRO for PC Crack New Download (Fully Activated 2025)
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero

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