SlideShare une entreprise Scribd logo
1  sur  13
Dsl In Groovy
Agenda
What are DSl
Types of DSL
Goals of a DSL
Groovy for Dsls
Groovy Shell and Binding
Compiler Customizers
Demo
What are DSL
A domain-specific language (DSL) is a computer language specialized to a
particular application domain.
Examples of domain-specific languages include HTML,Unix shell scripts,
spreadsheet formulas and macros, SQL for relational database queries,XSLT,
regular expressions
Types of DSL
External DSL is a language that's parsed independently of the host general
purpose language: good examples include regular expressions and CSS.
External DSLs have a strong tradition in the Unix community.
Internal DSLs are a particular form of API in a host general purpose language,
often referred to as a fluent interface.
Goals of a DSL
Use a more expressive language than a general-purpose one
Should be focussed towards one goal, one domain
It should not have too much of technical jargon because the target is a user
rather than machine as in case of general programming language
It should be able to embed other dsls
Why Groovy for Dsl
The syntax of language has less ceremony and is suited for designing
expressive syntax eg- optional parentheses, getters/setters
Groovy has support for operator overloading and metaprogramming at runtime
and compile time
Groovy has the capability to embed and execute scripts at runtime
IDE support
Tools in groovy for Dsl
Groovy Shell/Console
Compiler customizers
AST transformation
Builders
Type Checking Extensions
Tools that Use Groovy Dsl
Gradles
Grails
Spock Testing framework
Griffon
RatPack
Groovy Shell
Groovy Shell is a groovy Integration feature
The groovy.lang.GroovyShell class is the preferred way to evaluate scripts with
the ability to cache the resulting script instance.
Other mechanism in groovy are GroovyScriptEngine,GroovyClassLoader,Eval
Groovy Shell
Java provides its own integration feature with JSR-223 javax.script.* to hook in
multiple scripting languages
def shell = new GroovyShell(this.class.classLoader, binding)
shell.evaluate(new File("dsl_script_file"))
Binding in DSL
It is possible to share data between the application and the script using a
groovy.lang.Binding
def binding = new Binding([
robot: new Robot(),
h: new Duration(TimeUnit.hour)
])
Demo
https://github.com/NexThoughts/GroovyDSL
Reference
http://martinfowler.com/books/dsl.html
http://groovy.jmiguel.eu/groovy.codehaus.org/Advanced+compiler+configuration.
html
http://www.slideshare.net/glaforge/groovy-dsls-from-beginner-to-expert-
guillaume-laforge-and-paul-king-springone2gx-2011
https://www.youtube.com/watch?v=rk9ZR2EkE3g
https://www.youtube.com/watch?v=nqqGtdvPzus

Contenu connexe

Tendances

Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
Atul Shridhar
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
Jana Moudrá
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
Alex Ezell
 
GDG DART Event at Karachi
GDG DART Event at KarachiGDG DART Event at Karachi
GDG DART Event at Karachi
Imam Raza
 

Tendances (19)

Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
Let's Play Dart
Let's Play DartLet's Play Dart
Let's Play Dart
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Concepts of JetBrains MPS
Concepts of JetBrains MPSConcepts of JetBrains MPS
Concepts of JetBrains MPS
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart language
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
 
Php Vs Phyton
Php Vs PhytonPhp Vs Phyton
Php Vs Phyton
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Ruby
RubyRuby
Ruby
 
Go Lang
Go LangGo Lang
Go Lang
 
Add Perl to Your Toolbelt
Add Perl to Your ToolbeltAdd Perl to Your Toolbelt
Add Perl to Your Toolbelt
 
GDG DART Event at Karachi
GDG DART Event at KarachiGDG DART Event at Karachi
GDG DART Event at Karachi
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_iv
 
Breaking The Monotony
Breaking The MonotonyBreaking The Monotony
Breaking The Monotony
 
Why Ruby
Why RubyWhy Ruby
Why Ruby
 
Dconf2015 d2 t3
Dconf2015 d2 t3Dconf2015 d2 t3
Dconf2015 d2 t3
 

En vedette

En vedette (20)

Grails custom tag lib
Grails custom tag libGrails custom tag lib
Grails custom tag lib
 
Bootcamp linux commands
Bootcamp linux commandsBootcamp linux commands
Bootcamp linux commands
 
G pars
G parsG pars
G pars
 
Grails internationalization-160524154831
Grails internationalization-160524154831Grails internationalization-160524154831
Grails internationalization-160524154831
 
Groovy intro
Groovy introGroovy intro
Groovy intro
 
Groovy
GroovyGroovy
Groovy
 
Meta Programming in Groovy
Meta Programming in GroovyMeta Programming in Groovy
Meta Programming in Groovy
 
Docker
DockerDocker
Docker
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Spring boot
Spring bootSpring boot
Spring boot
 
Twilio
TwilioTwilio
Twilio
 
Gorm
GormGorm
Gorm
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
Java reflection
Java reflectionJava reflection
Java reflection
 
MetaProgramming with Groovy
MetaProgramming with GroovyMetaProgramming with Groovy
MetaProgramming with Groovy
 
Grails Controllers
Grails ControllersGrails Controllers
Grails Controllers
 
Grails services
Grails servicesGrails services
Grails services
 
Grails with swagger
Grails with swaggerGrails with swagger
Grails with swagger
 
Command objects
Command objectsCommand objects
Command objects
 

Similaire à Groovy DSL

Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
deimos
 
Domain Specific Language Design
Domain Specific Language DesignDomain Specific Language Design
Domain Specific Language Design
Markus Voelter
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проекте
ISsoft
 
0001 Genero Terms
0001 Genero Terms0001 Genero Terms
0001 Genero Terms
guest174e18
 
0001 Genero Terms
0001 Genero Terms0001 Genero Terms
0001 Genero Terms
guest174e18
 
0001 Genero Terms
0001 Genero Terms0001 Genero Terms
0001 Genero Terms
guest174e18
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
elliando dias
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
SIVAJISADHANA
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
SIVAJISADHANA
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
SIVAJISADHANA
 

Similaire à Groovy DSL (20)

What's DSL and what isn't
What's DSL and what isn'tWhat's DSL and what isn't
What's DSL and what isn't
 
DSL explained _
DSL explained _DSL explained _
DSL explained _
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
 
Log cat kotlindsl
Log cat kotlindslLog cat kotlindsl
Log cat kotlindsl
 
Domain Specific Language Design
Domain Specific Language DesignDomain Specific Language Design
Domain Specific Language Design
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проекте
 
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
 
Xbase implementing specific domain language for java
Xbase  implementing specific domain language for javaXbase  implementing specific domain language for java
Xbase implementing specific domain language for java
 
0001 Genero Terms
0001 Genero Terms0001 Genero Terms
0001 Genero Terms
 
0001 Genero Terms
0001 Genero Terms0001 Genero Terms
0001 Genero Terms
 
DSL, the absolute weapon for the development
DSL, the absolute weapon for the developmentDSL, the absolute weapon for the development
DSL, the absolute weapon for the development
 
0001 Genero Terms
0001 Genero Terms0001 Genero Terms
0001 Genero Terms
 
Building domain-specific languages with Groovy
Building domain-specific languages with GroovyBuilding domain-specific languages with Groovy
Building domain-specific languages with Groovy
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
 
Web programming technologies
Web programming technologiesWeb programming technologies
Web programming technologies
 
Introduction to programming world
Introduction to programming worldIntroduction to programming world
Introduction to programming world
 
Scala: a Cross-Platform Language
Scala: a Cross-Platform LanguageScala: a Cross-Platform Language
Scala: a Cross-Platform Language
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 

Plus de NexThoughts Technologies

Plus de NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Google authentication
Google authenticationGoogle authentication
Google authentication
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Groovy DSL