This document discusses how to write your own domain-specific language (DSL). It begins by defining what a DSL is - a language designed for a particular domain that allows for more expressive communication within that domain.
It then covers the key aspects of writing a DSL, including parsing the DSL into an abstract syntax tree using a parser generator like DSL::Maker, validating the parsed structure follows the rules of the language, and producing output from the validated structure.
An example DSL for defining vehicle data is used to demonstrate these concepts. The document concludes by noting that production from a parsed DSL structure is left to the developer and encourages an outside-in, multi-pass approach to transformation.
Stylus is a CSS preprocessor that aims to simplify CSS by removing syntactic sugar like brackets and semicolons, enforcing indentation, and allowing variables, mixins, and nested selectors. Nib is a library of mixins, utilities, and components for Stylus that handles vendor prefixes and provides things like clearfixes and hiding text. Together, Stylus and Nib allow for more concise and maintainable CSS code.
This document discusses domain specific languages (DSLs) in Scala. It defines a DSL as a computer language specialized to a particular application domain. DSLs can be either external and parsed independently, or internal and written inside an existing host language. The document then provides an example Money DSL in Scala for performing currency conversions and calculations, demonstrating how a DSL can make code more readable and expressive by using a natural domain-specific syntax. Key benefits of DSLs include high-level abstractions, conciseness, and expressiveness over general purpose languages.
This document discusses syntax-directed translation, which refers to a method of compiler implementation where the source language translation is completely driven by the parser. The parsing process and parse trees are used to direct semantic analysis and translation of the source program. Attributes and semantic rules are associated with the grammar symbols and productions to control semantic analysis and translation. There are two main representations of semantic rules: syntax-directed definitions and syntax-directed translation schemes. Syntax-directed translation schemes embed program fragments called semantic actions within production bodies and are more efficient than syntax-directed definitions as they indicate the order of evaluation of semantic actions. Attribute grammars can be used to represent syntax-directed translations.
The document discusses compilers and web applications. It begins by stating that writing web applications involves many technologies like HTML, CSS, JavaScript frameworks, databases, and more. In contrast, writing a compiler mainly involves processing source code through phases like lexing, parsing, type checking, and code generation. The document focuses on the code generation and semantic analysis phases of compilers. It provides examples of Crystal code for a compiler and explains key concepts like the Program object that holds compiled program data.
The document discusses the phases of a compiler and analyzing source code semantically. It explains that semantic analysis involves processing the abstract syntax tree (AST) to perform type checking and declaration of types, methods, etc. The key phases are the top-level phase which declares classes, modules, and other top-level items, and the semantic visitor which analyzes nodes in the AST while tracking the current type and looking up declarations.
The document discusses compilers and web applications. It begins by stating that writing web applications involves many technologies like HTML, CSS, JavaScript frameworks, databases, and more. In contrast, writing a compiler mainly involves processing source code through phases like lexing, parsing, type checking, and code generation. The document focuses on the semantic analysis phase, noting it involves processing the abstract syntax tree and is easier than writing a web application since it only deals with one language rather than multiple technologies. It provides details on the Crystal compiler's implementation and organization.
Deep dive into browser internal processingHarunaUtsumi
This was created during my time as a student at Code Chrysalis.
I mention three points.
First, I explain about three points that have a large impact on web site performance. They are Network processing, Rendering processing, and Script processing.
Second, I described a detail flow of the Rendering process.
And Last, I explained how multiple threads execute rendering processing.
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
The document describes a domain specific language (DSL) for specifying tests of a MiniBar simulation using the Specter testing framework in C#. It provides an example context and specifications to test that drinking a beer does not throw an exception, that drinking 5 beers results in a $-5 balance, and that drinking more than 10 beers throws an exception indicating the user is drunk. The specifications are translated to NUnit test methods with asserts to test the MiniBar behavior.
Stylus is a CSS preprocessor that aims to simplify CSS by removing syntactic sugar like brackets and semicolons, enforcing indentation, and allowing variables, mixins, and nested selectors. Nib is a library of mixins, utilities, and components for Stylus that handles vendor prefixes and provides things like clearfixes and hiding text. Together, Stylus and Nib allow for more concise and maintainable CSS code.
This document discusses domain specific languages (DSLs) in Scala. It defines a DSL as a computer language specialized to a particular application domain. DSLs can be either external and parsed independently, or internal and written inside an existing host language. The document then provides an example Money DSL in Scala for performing currency conversions and calculations, demonstrating how a DSL can make code more readable and expressive by using a natural domain-specific syntax. Key benefits of DSLs include high-level abstractions, conciseness, and expressiveness over general purpose languages.
This document discusses syntax-directed translation, which refers to a method of compiler implementation where the source language translation is completely driven by the parser. The parsing process and parse trees are used to direct semantic analysis and translation of the source program. Attributes and semantic rules are associated with the grammar symbols and productions to control semantic analysis and translation. There are two main representations of semantic rules: syntax-directed definitions and syntax-directed translation schemes. Syntax-directed translation schemes embed program fragments called semantic actions within production bodies and are more efficient than syntax-directed definitions as they indicate the order of evaluation of semantic actions. Attribute grammars can be used to represent syntax-directed translations.
The document discusses compilers and web applications. It begins by stating that writing web applications involves many technologies like HTML, CSS, JavaScript frameworks, databases, and more. In contrast, writing a compiler mainly involves processing source code through phases like lexing, parsing, type checking, and code generation. The document focuses on the code generation and semantic analysis phases of compilers. It provides examples of Crystal code for a compiler and explains key concepts like the Program object that holds compiled program data.
The document discusses the phases of a compiler and analyzing source code semantically. It explains that semantic analysis involves processing the abstract syntax tree (AST) to perform type checking and declaration of types, methods, etc. The key phases are the top-level phase which declares classes, modules, and other top-level items, and the semantic visitor which analyzes nodes in the AST while tracking the current type and looking up declarations.
The document discusses compilers and web applications. It begins by stating that writing web applications involves many technologies like HTML, CSS, JavaScript frameworks, databases, and more. In contrast, writing a compiler mainly involves processing source code through phases like lexing, parsing, type checking, and code generation. The document focuses on the semantic analysis phase, noting it involves processing the abstract syntax tree and is easier than writing a web application since it only deals with one language rather than multiple technologies. It provides details on the Crystal compiler's implementation and organization.
Deep dive into browser internal processingHarunaUtsumi
This was created during my time as a student at Code Chrysalis.
I mention three points.
First, I explain about three points that have a large impact on web site performance. They are Network processing, Rendering processing, and Script processing.
Second, I described a detail flow of the Rendering process.
And Last, I explained how multiple threads execute rendering processing.
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
The document describes a domain specific language (DSL) for specifying tests of a MiniBar simulation using the Specter testing framework in C#. It provides an example context and specifications to test that drinking a beer does not throw an exception, that drinking 5 beers results in a $-5 balance, and that drinking more than 10 beers throws an exception indicating the user is drunk. The specifications are translated to NUnit test methods with asserts to test the MiniBar behavior.
HTML5 is the latest version of HTML that fully supports CSS3. It introduces new elements and attributes, allows 2D/3D graphics with Canvas, supports media like audio and video, enables local storage, and responds to different devices through CSS3 media queries. HTML5 works together with CSS3 to provide richer content and layouts on the web.
You Can Work on the Web Patform! (GOSIM 2023)Igalia
Have you ever wanted to work on a web browser? Servo is an experimental web
engine written in Rust. Its small code base and friendly community mean that it
is an ideal project for those looking to dip their toes into the world of web
browser engineering.
In this, Martin Robinson covers the basics of building and running
Servo on your own computer. In addition, we'll take a tour of Servo's main
subsystems and see what kind of work goes into building them. Additionally,
we'll cover a variety of types of contributions to Servo, adapted to different
kinds of experience and specialization. By the end you should have the tools
you need to explore contributing yourself.
(c) GOSIM Workshop 2023
Sept 23-24
Grand Hyatt, Pudong, Shanghai
https://workshop2023.gosim.org/
https://www.bilibili.com/video/BV1Hw411r7Q6/
MongoDB and DigitalOcean Automation with Cloud ManagerJay Gordon
Cloud Manager automation is an easy way to create new MongoDB deployments without having to do much of the underlying configuration work. This talk is how you can get started using automation on your droplets.
Do you want to upgrade your GWT application or write a sizable web application? Dart is the efficient choice.
As a brief example, check out http://lightningdart.com
This presentation is updated October 2015 for Silicon Valley Code Camp
Here are a few ways a DSL could potentially benefit a current project:
- Simplify or reduce complexity of certain tasks. A DSL tailored to a specific domain or problem could make those tasks easier to understand and perform.
- Improve productivity of non-programmers. A DSL designed with the intended users in mind could allow others like domain experts or analysts to accomplish things without programming.
- Enforce correctness or best practices. By limiting what can be expressed in a DSL, it reduces the possibility of certain errors or forces compliance with standards.
- Separate logic from implementation. Expressing logic or algorithms in a DSL abstracts it away from implementation details, making it more portable and maintain
Dart is a new language for the web, enabling you to write JavaScript on a secure and manageable way. No need to worry about "JavaScript: The bad parts".
This presentation concentrates on the developer experience converting from the Java based GWT to Dart.
The document discusses implementing a mini programming language from scratch by first defining the grammar using ANTLR and then implementing that grammar to handle logical expressions, switch/case expressions, and comparisons for use in conversational agents. It provides examples of the types of expressions that could be supported and walks through defining tokens, rules, and grammars for WHEN and logical expressions.
Fuzzing softwares for bugs - OWASP SeasidesOWASPSeasides
The document discusses different types of software fuzzing techniques. It provides an overview of the fuzzing process, which involves generating test cases, feeding them to the target program, monitoring for crashes, saving any crash cases, and repeating. It then describes two main types of fuzzing: mutation-based using tools like AFL, and generation-based using techniques like Domato. The document demonstrates mutation-based fuzzing on tcpdump using AFL. It provides steps to set up AFL and tcpdump, generate test cases, run AFL in parallel, and analyze any crashes found.
When designing software, we often need to solve numerous instances of the same problem. When designing user-interfaces, we need to describe the layout and interaction. When financial systems, we need to describe a wide range of financial contracts or, for example, recognize different patterns in price change.
Domain Specific Languages (DSLs) give us a way to solve such repeating problems. By designing a composable functional library, we can build an expressive language for describing our problems. Using the flexible F# syntax, we can get code that even non-programmers can understand.
In this practically oriented talk, we'll develop a number of sample DSLs, ending with realistic examples. We'll cover both basic principles of DSL design as well as advanced tricks, such as using the F# 3.0 query syntax.
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014John Dalsgaard
Loose coupling of systems is key to future development! Why? Because it will allow us to change the "components" as we go along instead of creating monster big systems that are tied together using all sorts of different technologies. Webservices have been a way to obtain this over the last decade. More recently a special variant has become very popular, namely the JSON based REST service.
Imagine you could extend your data out to the world outside your Domino environment? - in an easy way....! And imagine those data could easily be incorporated into other systems via standardized interfaces... Could that extend the value of your current systems further? Could this be a way to use new technologies to modernize your users' experience of working with your systems?
Come and take away knowledge about how to open your Domino/XWork based systems up to the world outside using JSON based REST services. They are going to be key to future development in Domino/XWork - whether you want to use data in browser solutions (e.g. based on angular.js or ExtJS) or native mobile apps (built in whatever technology is best).
Talend connect BE Vincent Harcq - Talend ESB - DIVincent Harcq
This document discusses how to use Talend ESB to connect mediation routes to data integration jobs. It provides an example of setting up a route that passes context to a job. The route defines the context and calls the job, while the job reads the context and performs the data integration tasks. Tips are given on using context groups to pass parameters between routes and jobs to make them reusable. The presentation is from Audaxis, a Belgium-based company that provides data integration and other software solutions.
Building an E-commerce website in MEAN stackdivyapisces
This document provides an overview of building an eCommerce site using the MEAN stack. It begins with an introduction to JavaScript and then discusses the key components of the MEAN stack including Node.js, AngularJS, and MongoDB. It provides details on each component, their history, features, and how they work together. It emphasizes how MongoDB is well-suited for eCommerce applications due to its flexible schema and ability to store different product types within the same collection.
The document summarizes a talk given on Scala services frameworks. It introduces Play, HTTP4s, Spray/Akka HTTP, Finch, and Lagom frameworks. It discusses criteria for evaluating frameworks like routing, pluggability, and deployment. It provides high-level overviews of each framework, noting pros and cons. Design, build, support and extension aspects are summarized for each. Finally, it maps frameworks to developer personas and adoption curves, noting where each may be good fits based on priorities like rapid prototyping, functional programming, or enterprise needs.
The document provides an introduction to the C programming language and algorithms. It begins with an overview of C and its history. It then defines key concepts like keywords, data types, qualifiers, loops, storage classes, decision statements, and jumps. Examples of algorithms are provided for common problems like adding two numbers. Pattern printing algorithms are given as homework exercises. The document discusses where C is used and explains what a programming language and algorithms are. It emphasizes the importance of understanding requirements before implementation.
AD109 Navigating the Jungle of Modern Web DevelopmentShean McManus
In the beginning, the web was built largely on static HTML pages. While HTML is still the foundation for the modern web page, the explosion of JavaScript libraries, CSS frameworks, development tools, platforms and cloud offerings have made the understanding the universe of modern web development much more challenging. What is Angular? The MEAN stack? What is the difference between HTML and HTML5 or CSS and CSS3? To break it all down I will attempt to provide a clear overview of today's web including a taxonomy of common languages, tools, platforms and libraries. Learn how IBM xPages and IBM Blue Mix fit into this world and how all the terms you hear every day fit into the larger picture of modern web development.
Rubyconf Bangladesh 2017 - Lets start coding in RubyRuby Bangladesh
This document introduces Ruby programming concepts through code examples. It covers Ruby basics like variables, numbers, strings, symbols, constants, methods, arrays, hashes, classes and modules. It also discusses the Ruby ecosystem including RVM/rbenv, RubyGems, Bundler and Git/GitHub. The document compares Ruby and Ruby on Rails, lists popular editors for Ruby and provides references for further reading.
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...Andy Maleh
This document introduces Glimmer DSL for SWT, a Ruby GUI framework that allows building native graphical user interfaces in Ruby. It discusses the motivation for building native GUIs, provides examples of sample apps built with Glimmer, and outlines the basics of the GUI DSL syntax. Key aspects covered include widgets, properties, listeners, operations, software architecture patterns like MVC and MVP, data binding, custom components, drag and drop, and scaffolding tools. It also mentions the ability to package apps into various native executable formats like DMG, PKG, EXE, MSI, DEB, and RPM for different platforms.
Discover the benefits of outsourcing SEO to Indiadavidjhones387
"Discover the benefits of outsourcing SEO to India! From cost-effective services and expert professionals to round-the-clock work advantages, learn how your business can achieve digital success with Indian SEO solutions.
HTML5 is the latest version of HTML that fully supports CSS3. It introduces new elements and attributes, allows 2D/3D graphics with Canvas, supports media like audio and video, enables local storage, and responds to different devices through CSS3 media queries. HTML5 works together with CSS3 to provide richer content and layouts on the web.
You Can Work on the Web Patform! (GOSIM 2023)Igalia
Have you ever wanted to work on a web browser? Servo is an experimental web
engine written in Rust. Its small code base and friendly community mean that it
is an ideal project for those looking to dip their toes into the world of web
browser engineering.
In this, Martin Robinson covers the basics of building and running
Servo on your own computer. In addition, we'll take a tour of Servo's main
subsystems and see what kind of work goes into building them. Additionally,
we'll cover a variety of types of contributions to Servo, adapted to different
kinds of experience and specialization. By the end you should have the tools
you need to explore contributing yourself.
(c) GOSIM Workshop 2023
Sept 23-24
Grand Hyatt, Pudong, Shanghai
https://workshop2023.gosim.org/
https://www.bilibili.com/video/BV1Hw411r7Q6/
MongoDB and DigitalOcean Automation with Cloud ManagerJay Gordon
Cloud Manager automation is an easy way to create new MongoDB deployments without having to do much of the underlying configuration work. This talk is how you can get started using automation on your droplets.
Do you want to upgrade your GWT application or write a sizable web application? Dart is the efficient choice.
As a brief example, check out http://lightningdart.com
This presentation is updated October 2015 for Silicon Valley Code Camp
Here are a few ways a DSL could potentially benefit a current project:
- Simplify or reduce complexity of certain tasks. A DSL tailored to a specific domain or problem could make those tasks easier to understand and perform.
- Improve productivity of non-programmers. A DSL designed with the intended users in mind could allow others like domain experts or analysts to accomplish things without programming.
- Enforce correctness or best practices. By limiting what can be expressed in a DSL, it reduces the possibility of certain errors or forces compliance with standards.
- Separate logic from implementation. Expressing logic or algorithms in a DSL abstracts it away from implementation details, making it more portable and maintain
Dart is a new language for the web, enabling you to write JavaScript on a secure and manageable way. No need to worry about "JavaScript: The bad parts".
This presentation concentrates on the developer experience converting from the Java based GWT to Dart.
The document discusses implementing a mini programming language from scratch by first defining the grammar using ANTLR and then implementing that grammar to handle logical expressions, switch/case expressions, and comparisons for use in conversational agents. It provides examples of the types of expressions that could be supported and walks through defining tokens, rules, and grammars for WHEN and logical expressions.
Fuzzing softwares for bugs - OWASP SeasidesOWASPSeasides
The document discusses different types of software fuzzing techniques. It provides an overview of the fuzzing process, which involves generating test cases, feeding them to the target program, monitoring for crashes, saving any crash cases, and repeating. It then describes two main types of fuzzing: mutation-based using tools like AFL, and generation-based using techniques like Domato. The document demonstrates mutation-based fuzzing on tcpdump using AFL. It provides steps to set up AFL and tcpdump, generate test cases, run AFL in parallel, and analyze any crashes found.
When designing software, we often need to solve numerous instances of the same problem. When designing user-interfaces, we need to describe the layout and interaction. When financial systems, we need to describe a wide range of financial contracts or, for example, recognize different patterns in price change.
Domain Specific Languages (DSLs) give us a way to solve such repeating problems. By designing a composable functional library, we can build an expressive language for describing our problems. Using the flexible F# syntax, we can get code that even non-programmers can understand.
In this practically oriented talk, we'll develop a number of sample DSLs, ending with realistic examples. We'll cover both basic principles of DSL design as well as advanced tricks, such as using the F# 3.0 query syntax.
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014John Dalsgaard
Loose coupling of systems is key to future development! Why? Because it will allow us to change the "components" as we go along instead of creating monster big systems that are tied together using all sorts of different technologies. Webservices have been a way to obtain this over the last decade. More recently a special variant has become very popular, namely the JSON based REST service.
Imagine you could extend your data out to the world outside your Domino environment? - in an easy way....! And imagine those data could easily be incorporated into other systems via standardized interfaces... Could that extend the value of your current systems further? Could this be a way to use new technologies to modernize your users' experience of working with your systems?
Come and take away knowledge about how to open your Domino/XWork based systems up to the world outside using JSON based REST services. They are going to be key to future development in Domino/XWork - whether you want to use data in browser solutions (e.g. based on angular.js or ExtJS) or native mobile apps (built in whatever technology is best).
Talend connect BE Vincent Harcq - Talend ESB - DIVincent Harcq
This document discusses how to use Talend ESB to connect mediation routes to data integration jobs. It provides an example of setting up a route that passes context to a job. The route defines the context and calls the job, while the job reads the context and performs the data integration tasks. Tips are given on using context groups to pass parameters between routes and jobs to make them reusable. The presentation is from Audaxis, a Belgium-based company that provides data integration and other software solutions.
Building an E-commerce website in MEAN stackdivyapisces
This document provides an overview of building an eCommerce site using the MEAN stack. It begins with an introduction to JavaScript and then discusses the key components of the MEAN stack including Node.js, AngularJS, and MongoDB. It provides details on each component, their history, features, and how they work together. It emphasizes how MongoDB is well-suited for eCommerce applications due to its flexible schema and ability to store different product types within the same collection.
The document summarizes a talk given on Scala services frameworks. It introduces Play, HTTP4s, Spray/Akka HTTP, Finch, and Lagom frameworks. It discusses criteria for evaluating frameworks like routing, pluggability, and deployment. It provides high-level overviews of each framework, noting pros and cons. Design, build, support and extension aspects are summarized for each. Finally, it maps frameworks to developer personas and adoption curves, noting where each may be good fits based on priorities like rapid prototyping, functional programming, or enterprise needs.
The document provides an introduction to the C programming language and algorithms. It begins with an overview of C and its history. It then defines key concepts like keywords, data types, qualifiers, loops, storage classes, decision statements, and jumps. Examples of algorithms are provided for common problems like adding two numbers. Pattern printing algorithms are given as homework exercises. The document discusses where C is used and explains what a programming language and algorithms are. It emphasizes the importance of understanding requirements before implementation.
AD109 Navigating the Jungle of Modern Web DevelopmentShean McManus
In the beginning, the web was built largely on static HTML pages. While HTML is still the foundation for the modern web page, the explosion of JavaScript libraries, CSS frameworks, development tools, platforms and cloud offerings have made the understanding the universe of modern web development much more challenging. What is Angular? The MEAN stack? What is the difference between HTML and HTML5 or CSS and CSS3? To break it all down I will attempt to provide a clear overview of today's web including a taxonomy of common languages, tools, platforms and libraries. Learn how IBM xPages and IBM Blue Mix fit into this world and how all the terms you hear every day fit into the larger picture of modern web development.
Rubyconf Bangladesh 2017 - Lets start coding in RubyRuby Bangladesh
This document introduces Ruby programming concepts through code examples. It covers Ruby basics like variables, numbers, strings, symbols, constants, methods, arrays, hashes, classes and modules. It also discusses the Ruby ecosystem including RVM/rbenv, RubyGems, Bundler and Git/GitHub. The document compares Ruby and Ruby on Rails, lists popular editors for Ruby and provides references for further reading.
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...Andy Maleh
This document introduces Glimmer DSL for SWT, a Ruby GUI framework that allows building native graphical user interfaces in Ruby. It discusses the motivation for building native GUIs, provides examples of sample apps built with Glimmer, and outlines the basics of the GUI DSL syntax. Key aspects covered include widgets, properties, listeners, operations, software architecture patterns like MVC and MVP, data binding, custom components, drag and drop, and scaffolding tools. It also mentions the ability to package apps into various native executable formats like DMG, PKG, EXE, MSI, DEB, and RPM for different platforms.
Discover the benefits of outsourcing SEO to Indiadavidjhones387
"Discover the benefits of outsourcing SEO to India! From cost-effective services and expert professionals to round-the-clock work advantages, learn how your business can achieve digital success with Indian SEO solutions.
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...APNIC
Adli Wahid, Senior Internet Security Specialist at APNIC, delivered a presentation titled 'Honeypots Unveiled: Proactive Defense Tactics for Cyber Security' at the Phoenix Summit held in Dhaka, Bangladesh from 23 to 24 May 2024.
Securing BGP: Operational Strategies and Best Practices for Network Defenders...APNIC
Md. Zobair Khan,
Network Analyst and Technical Trainer at APNIC, presented 'Securing BGP: Operational Strategies and Best Practices for Network Defenders' at the Phoenix Summit held in Dhaka, Bangladesh from 23 to 24 May 2024.
HijackLoader Evolution: Interactive Process HollowingDonato Onofri
CrowdStrike researchers have identified a HijackLoader (aka IDAT Loader) sample that employs sophisticated evasion techniques to enhance the complexity of the threat. HijackLoader, an increasingly popular tool among adversaries for deploying additional payloads and tooling, continues to evolve as its developers experiment and enhance its capabilities.
In their analysis of a recent HijackLoader sample, CrowdStrike researchers discovered new techniques designed to increase the defense evasion capabilities of the loader. The malware developer used a standard process hollowing technique coupled with an additional trigger that was activated by the parent process writing to a pipe. This new approach, called "Interactive Process Hollowing", has the potential to make defense evasion stealthier.
5. What is a DSL?
● Domain-Specific Language
● Language - A vehicle for communication
6. What is a DSL?
● Domain-Specific Language
● Language - A vehicle for communication
● Domain - A restrained set of concepts
7. What is a DSL?
● Domain-Specific Language
● Language - A vehicle for communication
● Domain - A restrained set of concepts
● Specific - Limited to.
8. What is a DSL?
● Domain-Specific Language
● Language - A vehicle for communication
● Domain - A restrained set of concepts
● Specific - Limited to.
○ No, really. :)
11. Language and Communication
● Communicate in three directions
○ Author -> Executor
○ Author -> Maintainer
○ Specifier -> Author
12. Language and Communication
● Communicate in four directions
○ Author -> Executor
○ Author -> Maintainer
○ Specifier -> Author
○ Author -> Verifier
13. Language and Communication
● Communicate in MANY directions
○ Author -> Executor
○ Author -> Maintainer
○ Specifier -> Author
○ Author -> Verifier
○ Author -> Teammate(s)
○ Developer -> Sysadmin/Devops
○ … -> …
14. Language and Communication
● Communicate in MANY directions
○ Author -> Executor
○ Author -> Maintainer
○ Specifier -> Author
○ Author -> Verifier
○ Author -> Teammate(s)
○ Developer -> Sysadmin/Devops
○ … -> …
The ONLY
computer
15. Language and Communication
● Communicate in MANY directions
○ Author -> Executor
○ Author -> Maintainer
○ Specifier -> Author
○ Author -> Verifier
○ Author -> Teammate(s)
○ Developer -> Sysadmin/Devops
○ … -> …
All humans
16. Language and Communication
● Communicate in MANY directions
○ Author -> Executor
○ Author <-> Maintainer
○ Specifier <-> Author
○ Author <-> Verifier
○ Author <-> Teammate(s)
○ Developer <-> Sysadmin/Devops
○ … <-> …
All human
communication
is two-way
17. Domain-Specific
● Eskimos supposedly have 50+ words for
“snow”
○ Depends on how you count it
● Saami has 1000+ words dealing with
reindeer
○ snarri - a reindeer with short, branched horns
○ busat - a bull with a single, large testicle
19. DSLs you already use
● SQL
○ set manipulation DSL
● CSS
○ tree-visitor-defining DSL for setting metadata
● HAML
○ HTML-definition DSL
● Bash
○ A crappy way of issue shell commands with logic
20. Places for a DSL
● Packaging and orchestration
○ most devops/operations activities
● Configuration file generation
○ web servers
○ monitoring
○ datastores
● Configuration value management across environments
● Anything extremely complicated (such as SQL)
● Anything repetitive (such as CSS)
21. Reasons for a DSL
● Let the important things shine
● General-purpose is overly-verbose
● Bugs hide in boilerplate
● Non-developers can read and comprehend
○ And maybe even propose changes through PRs?
34. Writing a DSL - Validation
● DSL::Maker for parsing
● DSL::Maker for validation
35. . . .
class VehicleDSL < DSL::Maker
. . .
add_validation(:car) do |car|
unless car.engine
return “Cars must have an engine”
end
end
end
car {
make ‘Accord’
year 1990
engine {
hemi Yes
}
}
car ‘Civic’ {
year 2014
}
36. . . .
class VehicleDSL < DSL::Maker
. . .
add_validation(:car) do |car|
unless car.engine
return “Cars must have an engine”
end
end
end
car {
make ‘Accord’
year 1990
engine {
hemi Yes
}
}
car ‘Civic’ {
year 2014
}
37. #!/usr/bin/env ruby
require ‘vehicle/dsl’
filename = ARGV.shift ||
raise “No filename provided.”
# This raises the error
vehicles = Vehicle::DSL.parse_dsl(
IO.read(filename),
)
# Do something here with vehicles
Error: Cars must have an engine
38. Writing a DSL - Production
● DSL::Maker for parsing
● DSL::Maker for validation
● You’re on your own for production
39. Writing a DSL - Production
● Work from outside in.
○ Parsing is done inside-out.
● Transform in a series of passes.
○ Expand everything (it’s just data)
● Don’t do anything irrevocable until the end
○ Work in temp directories, stage everything
40. Conclusion
● DSL::Maker 0.1.0 is available right now
● Patches welcome
○ 100% test coverage
● I’m blogging about this at http:
//streamlined-book.blogspot.com
○ First post on the topic