SlideShare a Scribd company logo
1 of 73
Building DSLs
High Essence   Groovy MetaProgramming
         Venkat Subramaniam
      venkats@AgileDeveloper.com
Communication



How do we humans communicate?




                                2
First Moon Landing
Transcript...




Two things go through my mind:
 1. Wow     2. I’ve the faintest idea what
                 they’re talking about!      3
Communication
As human we communicate using Jargons




                                        4
Aren’t Jargons Bad?
They’re very bad for people who don’t understand
the domain or don’t share the context

  You’d be totally lost

But, they’re very good for people who share the
context in the domain

  The communication is highly effective

  Terse, high signal—to—noise ratio

  This is what professionals use in their respective
  fields
                                                       5
How do you use your App/
      Computer?
Typically you use keyword
input files, configuration
files, etc.

If you’re stuck at an
airport, which of these two
agents gives you the most
confidence you’ll be on your
way—one that uses the
keyboard, or the one that
mouses around?

  The former, uses direct
  queries                     6
Productivity is Key

A GUI makes an average
user productive, but often
may slowdown an expert
user or a user very fluent
with your application and
its domain.

You don't want to make the
novice productive at the
expense of making an
expert counterproductive.


                             7
Naked Objects
Richard Pawson and Robert
Matthews introduced the
concept of Naked Objects

They auto-build a thin
object-oriented user
interface (OOUI) from a
domain model

The OOUI exposes the
behavior of domain objects
for direct interaction by
the users.

                             8
How does an expert express
   Matrix Multiplication?




                             9
Goal of a DSL



The goal of DSLs is to provide a highly effective
interface for your users to interact with your
application.

The interface may be graphical or textual.




                                                    10
But?!




what’s a DSL?   11
Domain Specific Language

  A language targeted at a particular type of
  problem

  Syntax focuses on intended domain/problem

  Unlike a general purpose language, you can’t use it
  for all kinds of stuff (or don’t want to)

  Limited in scope and capability

  Hence, they’re small and simple—that’s good


                                                        12
Domain and Context
What’s Domain?

  It is an area of sphere or
  knowledge, influence, or activity

What’s Context?

  A logical framework within which
  we evolve models

What’s Bounded Context?
                                     Context
  Defines a logical boundary of
  relevance within the context
                                     Domain
                                               13
What is it really?


       It’s a ubiquitous language—only
       narrow within a domain

       Domain folks understand it well

       Highly expressive and easy to
       use




                                         14
Where does it fit?
You’re most likely to use multiple languages to build
your application—Neal Ford’s vision for Polyglot
Programmer.

Martin Fowler argues that rather than using one big
general purpose language, applications will use
several small and limited DSLs—Languages Oriented
Programming.

Ola Bini argues at http://ola-bini.blogspot.com/
2008/01/language-explorations.html that "three
language layers will emerge in large applications"

                                                        15
Where does it fit?
     Ola’s Pyramid

       Expressive
     Domain Specific      DSL
                        Layer

     Groovy/       Dynamic Layer
      JRuby      (Most Functionality)

Java/Scala/
   JVM           Small Stable Layer

                                        16
What’s Need to Build ‘em?



Objects + Meta Programming (Aspects) + lots of
Patience +




                                                 17
Types of DSLs


External DSLs



Internal DSLs




                         18
External DSL

You define a new language

You then parse the commands to take actions

You have the liberty to chose the syntax you like

You’re in full control—that’s good... and bad

Can be lot of fun ;)

One of my first jobs was to maintain lex and Yacc...




                                                      19
External DSL Examples




CSS is an example of an external DSL!




                                        20
External DSL Examples




Good old Makefile is an example of external DSL

                                                 21
External DSL Examples




Ant is an example of external DSL

                                    22
Internal DSL

Also known as Embedded DSLs

Built on top of a host language

Constructs of your host language are construed to form a
DSL

You don’t need to write an separate parser—that’s less work

Commands tactfully map over to constructs like methods, etc.

You can enjoy the host language’s flexibility, but you get
bitten by its limitations and idiosyncrasies



                                                               23
Internal DSL Examples




Rake is an example of internal DSL!

 It is pure Ruby


                                      24
Internal DSL Examples




Gant is an example of internal DSL!

 It is pure Groovy, wrapper around Ant
                                         25
Internal DSL Examples




easyb is an example of internal DSL

It is a Behavior Driven Design Tool and uses Groovy
for expressing stories and behavior in a DSL form
                                                      26
External or Internal

It depends on your application

Certain (dynamic) languages are better suited for
internal DSLs

  Smalltalk, Lisp, Ruby, Groovy, ...

Other languages are better suited for external DSL
and offer good parsing libraries or capabilities

  C++, Java, C#, ...


                                                     27
External or Internal
External                  Internal
+You decide syntax        - You decide within
                          limits of host language

-You write parser for     + Language takes care
it                        of parsing

+ A tad easier to         - You gotta find your
design                    way around host

+ Once you write a        - Hard to validate at
parser, validation is a   the moment, good
breeze                    research potential
                                                  28
Are all Languages Suited for
 Not really Internal DSLs?



 Low Ceremony + Metaprogramming is essential



 Scala, for example, has low ceremony, but lacks
 metaprogramming capabilities. So, not so easy to write
 internal DSLs with it

 Groovy, Ruby, ... shine due to high essence, low
 ceremony, and metaprogramming
                                                          29
Characteristics of a DSL

What are some of the qualities of a DSL?

  Context Driven

     Extremely context sensitive

  Fluent Interfaces

     Provides for a humane, easy to understand
     interface



                                                 30
Context Driven

DSL is extremely context sensitive or context driven

A lot of things are knows from the context

Without context, we may be confused or misled

With context, there is less clutter, terse, but
readable




                                                       31
Context Driven ...
 I heard my friend Neal Ford yell out

   Quad Venti Latte with 2 Extra Shots

 What’s he talking about?


He’s using the Starbucks DSL


Nowhere did he mention the word coffee, but he sure
got a good one at a high price ;)

That’s context driven
                                                      32
Context Driven ...
I heard my friend Scott Davis mutter

  place a $ in a GString

What’s he talking about?

You don’t want to know

He sure was talking about embedding variables into
the Groovy’s mutable string class

That’s also context driven :)


                                                     33
Fluent Interface

I was going to call this hygienic interface

I like the name Eric Evans and Martin Fowler
promote–Fluent Interface/Humane Interface

It’s designed to be readable and to flow naturally

Not easy to design–you put in more effort to create
it, so it is easier for users to use



                                                      34
Code With No Context



What do you do with mailer object after call to send?

Is the order important?

Do I have to create an object each time?

...

Can I just get my work done, can this be simpler?
                                                        35
Code With Context




                    36
Let’s Look at them both




 We’ll see later how to build these...   37
How do you write a Loop?
Find total of numbers from 1 to
10




 Why does the Java loop look
 like this?



                                  38
Fluent Loops (Groovy)




                        39
How to get Fluency?


You can achieve fluency in Java as well

You can use method chaining with a little
compromise




                                            40
A Little Compromise
Command Query Separation was promoted by
Bertrand Meyer

  Command methods—mutators or modifiers—affect
  object state and don’t return anything

  Query methods—don’t affect object state and
  return useful information

You compromise a little to be fluent (kind of like
words bent to rhyme in a poem)

Command methods return self or a promoter for a
good flow
                                                    41
Fluent Interface in EasyMock




                           42
Fluent Interface in
JSONObject Library




                       43
Fluent Interface in Guice




                            44
Fluency in Rails/Active Records




                              45
Fluency in Grails/GORM




                         46
Let’s Order Pizza
Voice on line (VOL): Thanks for calling Joe’s

You: Ya, A Large Thin Crust

VOL: Toppings?

You: Olives, Onions, Bell Pepper

VOL: Address

You: 101 Main St.,...

VOL: Card?

You: Visa 1234-1234-1234-1234

VOL: 20 minutes–Thank you                       47
Java Pizza Order



Not fluent

Very noisy—how many times do you have to say
joes_pizza?

Can we make it fluent?



                                               48
with
Some languages have a with keyword

within the scope, methods are invoked on an
implicit object

Here is an example from JavaScript




                                              49
with in Groovy?
Groovy has with keyword which is synonym for identity method




                                                               50
How about Fluent Java?



Less clutter

There is a context in each call

Each set method (except setCard()) returns this
(PizzaShop)

Can we make this a bit more readable?
                                                  51
A bit more Fluent...




Method names make sense in the flow, but may
not make sense alone

What’s a catch?


                                              52
Ordered vs. Unordered
Some DSLs may require a certain order in the
flow

  You can force ordering by tactfully defining
  return types that will allow method chaining in
  only certain order

      Not easy

Others may not require ordering

It depends on the particular problem

Ideally, not requiring an order is great, but may
not always be possible
                                                    53
How to Enforce Sequence?




                           54
Closures Make It Easier




                          55
OK, but...
You may not be able to deviate from standard API
conventions

What if it is existing API or there are other reasons
to follow conventions?

You can use a Façade or expression builder

  It sits on top of existing traditional API and
  provides context and fluency

  For example, Groovy has a number of these
  builders built-in

                                                        56
Groovy Builder: XML
Fluency to build XML




                            57
Groovy Builder: Swing
Fluency to build Swing GUI




                             58
Creating DSLs
You may use tools like Antlr for working with DSLs

JetBrains is working on Meta Programming
System(MPS)

Languages like Ruby and Groovy may it easier to
create (internal) DSLs

What makes Groovy attractive?

  Classes are always open

  Closures and Builders

  Categories and ExpandoMetaClass

  To some extent operator overloading
                                                     59
  Parenthesis are almost optional (a bit lacking)
Creating a DSL in Groovy
          file:order




                      See next page
                       file:process.groovy




                                     output



                                              60
Creating a DSL in Groovy
                contents of file:defs.groovy



methodMissing




                                              61
transmogrification
             How to deal with
             fluency, context, and
             ordering

             You can tactfully
             return different
             interfaces so only
             correct sequence of
             calls will fit in

             Return an appropriate
             interface from your
             methods and let
             method chaining take
             over
                                    62
Using Categories


Type conversions
------------------------
2        => int
.days => int
.ago => Calendar
.at     => Date

                            63
Using ExpandoMetaClass




                         64
Using EMC




            65
Categories vs.
         ExpandoMetaClass

Categories allows you to tactically enhance a class

ExpandoMetaClass is far reaching, global in nature

You may not want to affect a class globally

Categories provide controlled flexibility



                                                      66
Run Your DSL within a Context



  Running your DSL out in the open is not good:
  Unpredictable, unsettling

  Run it within the context of an object




                                                  67
Running in a context
     scores

              See next page




                          Output

                                   68
Running in a Context




                       69
Running in a Context




                       70
References
http://martinfowler.com/bliki/DomainSpecificLanguage.html

http://docs.codehaus.org/display/GROOVY/Writing+Domain-Specific+Languages

http://docs.codehaus.org/display/GROOVY/Gant

http://groovy.codehaus.org/ExpandoMetaClass

http://www.onboard.jetbrains.com/is1/articles/04/10/lop/

http://www.jetbrains.com/mps

Martin Fowler’s book work in progress: http://martinfowler.com/dslwip

A Chapter on creating DSL in Groovy: “Programming Groovy: Dynamic Productivity
for Java Developers” by Venkat Subramaniam (Pragmatic Bookshelf).

         You can download examples and slides from
          http://www.agiledeveloper.com - download                               71
References
A number of references from the following URL

http://martinfowler.com/bliki/DomainSpecificLanguage.html

http://docs.codehaus.org/display/GROOVY/Writing+Domain-Specific
+Languages

http://docs.codehaus.org/display/GROOVY/Gant

http://groovy.codehaus.org/ExpandoMetaClass

http://www.onboard.jetbrains.com/is1/articles/04/10/lop/

http://www.jetbrains.com/mps

       You can download examples and slides from
        http://www.agiledeveloper.com - download                 72
Thank You!
 Please fill in your session evaluations

You can download examples and slides from
 http://www.agiledeveloper.com - download   73

More Related Content

What's hot

Multiskill Conversational AI
Multiskill Conversational AIMultiskill Conversational AI
Multiskill Conversational AIDaniel Kornev
 
Managing Dialog Strategy in Multiskill AI Assistant with Discourse Management
Managing Dialog Strategy in Multiskill AI Assistant with Discourse ManagementManaging Dialog Strategy in Multiskill AI Assistant with Discourse Management
Managing Dialog Strategy in Multiskill AI Assistant with Discourse ManagementDaniel Kornev
 
Deep Learning in practice : Speech recognition and beyond - Meetup
Deep Learning in practice : Speech recognition and beyond - MeetupDeep Learning in practice : Speech recognition and beyond - Meetup
Deep Learning in practice : Speech recognition and beyond - MeetupLINAGORA
 
Vitalii Braslavskyi - Declarative engineering
Vitalii Braslavskyi - Declarative engineering Vitalii Braslavskyi - Declarative engineering
Vitalii Braslavskyi - Declarative engineering Grammarly
 
Deep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher ManningDeep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher ManningBigDataCloud
 
Programming Languages and Program Develompent
Programming Languages and Program DevelompentProgramming Languages and Program Develompent
Programming Languages and Program DevelompentSamudin Kassan
 
Domain Driven Design Mat Holroyd
Domain Driven Design   Mat HolroydDomain Driven Design   Mat Holroyd
Domain Driven Design Mat Holroydmelbournepatterns
 
Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...
Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...
Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...Grammarly
 
How to Design Frameworks
How to Design FrameworksHow to Design Frameworks
How to Design Frameworkselliando dias
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...InfinIT - Innovationsnetværket for it
 
Deep contextualized word representations
Deep contextualized word representationsDeep contextualized word representations
Deep contextualized word representationsJunya Kamura
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
Sequence to Sequence Learning with Neural Networks
Sequence to Sequence Learning with Neural NetworksSequence to Sequence Learning with Neural Networks
Sequence to Sequence Learning with Neural NetworksNguyen Quang
 
Lessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platformLessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platformJordi Cabot
 
Domain Driven Design in an Agile World
Domain Driven Design in an Agile WorldDomain Driven Design in an Agile World
Domain Driven Design in an Agile WorldLorraine Steyn
 

What's hot (17)

Multiskill Conversational AI
Multiskill Conversational AIMultiskill Conversational AI
Multiskill Conversational AI
 
Managing Dialog Strategy in Multiskill AI Assistant with Discourse Management
Managing Dialog Strategy in Multiskill AI Assistant with Discourse ManagementManaging Dialog Strategy in Multiskill AI Assistant with Discourse Management
Managing Dialog Strategy in Multiskill AI Assistant with Discourse Management
 
Oop Article Jan 08
Oop Article Jan 08Oop Article Jan 08
Oop Article Jan 08
 
Deep Learning in practice : Speech recognition and beyond - Meetup
Deep Learning in practice : Speech recognition and beyond - MeetupDeep Learning in practice : Speech recognition and beyond - Meetup
Deep Learning in practice : Speech recognition and beyond - Meetup
 
Vitalii Braslavskyi - Declarative engineering
Vitalii Braslavskyi - Declarative engineering Vitalii Braslavskyi - Declarative engineering
Vitalii Braslavskyi - Declarative engineering
 
Deep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher ManningDeep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
Deep Learning for NLP (without Magic) - Richard Socher and Christopher Manning
 
Programming Languages and Program Develompent
Programming Languages and Program DevelompentProgramming Languages and Program Develompent
Programming Languages and Program Develompent
 
Domain Driven Design Mat Holroyd
Domain Driven Design   Mat HolroydDomain Driven Design   Mat Holroyd
Domain Driven Design Mat Holroyd
 
Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...
Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...
Grammarly AI-NLP Club #2 - Recent advances in applied chatbot technology - Jo...
 
How to Design Frameworks
How to Design FrameworksHow to Design Frameworks
How to Design Frameworks
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Applying SOS to MDE
Applying SOS to MDEApplying SOS to MDE
Applying SOS to MDE
 
Deep contextualized word representations
Deep contextualized word representationsDeep contextualized word representations
Deep contextualized word representations
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Sequence to Sequence Learning with Neural Networks
Sequence to Sequence Learning with Neural NetworksSequence to Sequence Learning with Neural Networks
Sequence to Sequence Learning with Neural Networks
 
Lessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platformLessons learned from building a commercial bot development platform
Lessons learned from building a commercial bot development platform
 
Domain Driven Design in an Agile World
Domain Driven Design in an Agile WorldDomain Driven Design in an Agile World
Domain Driven Design in an Agile World
 

Viewers also liked

UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?Skills Matter
 
Rob Davies talks about Apache Open Source Software for Financial Services at ...
Rob Davies talks about Apache Open Source Software for Financial Services at ...Rob Davies talks about Apache Open Source Software for Financial Services at ...
Rob Davies talks about Apache Open Source Software for Financial Services at ...Skills Matter
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
Narrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony MarcanoNarrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony MarcanoSkills Matter
 
Keith Braithwaite on Domain Driven Design
Keith Braithwaite on Domain Driven DesignKeith Braithwaite on Domain Driven Design
Keith Braithwaite on Domain Driven DesignSkills Matter
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUSkills Matter
 
Five Steps to Kanban
Five Steps to KanbanFive Steps to Kanban
Five Steps to KanbanSkills Matter
 
Cqrs Ldnug 200100304
Cqrs   Ldnug 200100304Cqrs   Ldnug 200100304
Cqrs Ldnug 200100304Skills Matter
 
Use cases for cloud messaging
Use cases for cloud messaging Use cases for cloud messaging
Use cases for cloud messaging Skills Matter
 
Scala Presentation Work
Scala Presentation WorkScala Presentation Work
Scala Presentation WorkSkills Matter
 
Ria User Group Accessibility
Ria User Group Accessibility Ria User Group Accessibility
Ria User Group Accessibility Skills Matter
 
Hydras And Hypermedia
Hydras And HypermediaHydras And Hypermedia
Hydras And HypermediaSkills Matter
 
Teologia ecumenica e teologie nell'ecumene lezione 6
Teologia ecumenica e teologie nell'ecumene lezione 6Teologia ecumenica e teologie nell'ecumene lezione 6
Teologia ecumenica e teologie nell'ecumene lezione 6LuxEcclesiaeOrientalis
 
Startup Terms, A Breakdown For Everyone
Startup Terms, A Breakdown For EveryoneStartup Terms, A Breakdown For Everyone
Startup Terms, A Breakdown For EveryoneLuke Fitzpatrick
 

Viewers also liked (20)

Sug Jan 19
Sug Jan 19Sug Jan 19
Sug Jan 19
 
UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?UK G-Cloud: The First Instantiation of True Cloud?
UK G-Cloud: The First Instantiation of True Cloud?
 
Rob Davies talks about Apache Open Source Software for Financial Services at ...
Rob Davies talks about Apache Open Source Software for Financial Services at ...Rob Davies talks about Apache Open Source Software for Financial Services at ...
Rob Davies talks about Apache Open Source Software for Financial Services at ...
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
SQL vs NoSQL
SQL vs NoSQLSQL vs NoSQL
SQL vs NoSQL
 
Narrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony MarcanoNarrative Acceptance Tests River Glide Antony Marcano
Narrative Acceptance Tests River Glide Antony Marcano
 
Keith Braithwaite on Domain Driven Design
Keith Braithwaite on Domain Driven DesignKeith Braithwaite on Domain Driven Design
Keith Braithwaite on Domain Driven Design
 
Using Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPUUsing Language Oriented Programming to Execute Computations on the GPU
Using Language Oriented Programming to Execute Computations on the GPU
 
Five Steps to Kanban
Five Steps to KanbanFive Steps to Kanban
Five Steps to Kanban
 
Cqrs Ldnug 200100304
Cqrs   Ldnug 200100304Cqrs   Ldnug 200100304
Cqrs Ldnug 200100304
 
Oc Cloud Obscurity
Oc Cloud ObscurityOc Cloud Obscurity
Oc Cloud Obscurity
 
Neo4 J
Neo4 J Neo4 J
Neo4 J
 
Use cases for cloud messaging
Use cases for cloud messaging Use cases for cloud messaging
Use cases for cloud messaging
 
Scala Presentation Work
Scala Presentation WorkScala Presentation Work
Scala Presentation Work
 
Ria User Group Accessibility
Ria User Group Accessibility Ria User Group Accessibility
Ria User Group Accessibility
 
Hydras And Hypermedia
Hydras And HypermediaHydras And Hypermedia
Hydras And Hypermedia
 
Traits & Mixins
Traits & Mixins Traits & Mixins
Traits & Mixins
 
Terza settimana
Terza settimanaTerza settimana
Terza settimana
 
Teologia ecumenica e teologie nell'ecumene lezione 6
Teologia ecumenica e teologie nell'ecumene lezione 6Teologia ecumenica e teologie nell'ecumene lezione 6
Teologia ecumenica e teologie nell'ecumene lezione 6
 
Startup Terms, A Breakdown For Everyone
Startup Terms, A Breakdown For EveryoneStartup Terms, A Breakdown For Everyone
Startup Terms, A Breakdown For Everyone
 

Similar to Building DSLs: Marriage of High Essence and Groovy Metaprogramming

Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languageselliando dias
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеISsoft
 
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...SQALab
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven designRick van der Arend
 
Agile DSL Development in Ruby
Agile DSL Development in RubyAgile DSL Development in Ruby
Agile DSL Development in Rubyelliando dias
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovydeimos
 
Os Alrubaie Ruby
Os Alrubaie RubyOs Alrubaie Ruby
Os Alrubaie Rubyoscon2007
 
Challenges In Dsl Design
Challenges In Dsl DesignChallenges In Dsl Design
Challenges In Dsl DesignSven Efftinge
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLCAbdul Karim
 
Build your own Language - Why and How?
Build your own Language - Why and How?Build your own Language - Why and How?
Build your own Language - Why and How?Markus Voelter
 
Go programming language
Go programming languageGo programming language
Go programming languageAppstud
 
02 c a306-phillips_langtags
02 c a306-phillips_langtags02 c a306-phillips_langtags
02 c a306-phillips_langtagssuvo1111
 
Beyond Sharing: Open Source Design
Beyond Sharing: Open Source DesignBeyond Sharing: Open Source Design
Beyond Sharing: Open Source DesignMushon Zer-Aviv
 
groovy DSLs from beginner to expert
groovy DSLs from beginner to expertgroovy DSLs from beginner to expert
groovy DSLs from beginner to expertPaul King
 
Metaprogramming patterns
Metaprogramming patternsMetaprogramming patterns
Metaprogramming patternsGlenn Espinosa
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific LanguagesLakshan Perera
 

Similar to Building DSLs: Marriage of High Essence and Groovy Metaprogramming (20)

Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проекте
 
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
BDD or DSL как способ построения коммуникации на проекте - опыт комплексного ...
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
Agile DSL Development in Ruby
Agile DSL Development in RubyAgile DSL Development in Ruby
Agile DSL Development in Ruby
 
Venkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In GroovyVenkat Subramaniam Building DSLs In Groovy
Venkat Subramaniam Building DSLs In Groovy
 
Os Alrubaie Ruby
Os Alrubaie RubyOs Alrubaie Ruby
Os Alrubaie Ruby
 
Metamorphic Domain-Specific Languages
Metamorphic Domain-Specific LanguagesMetamorphic Domain-Specific Languages
Metamorphic Domain-Specific Languages
 
Challenges In Dsl Design
Challenges In Dsl DesignChallenges In Dsl Design
Challenges In Dsl Design
 
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
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
Build your own Language - Why and How?
Build your own Language - Why and How?Build your own Language - Why and How?
Build your own Language - Why and How?
 
Go programming language
Go programming languageGo programming language
Go programming language
 
sl slides-unit-1.pptx
sl slides-unit-1.pptxsl slides-unit-1.pptx
sl slides-unit-1.pptx
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
02 c a306-phillips_langtags
02 c a306-phillips_langtags02 c a306-phillips_langtags
02 c a306-phillips_langtags
 
Beyond Sharing: Open Source Design
Beyond Sharing: Open Source DesignBeyond Sharing: Open Source Design
Beyond Sharing: Open Source Design
 
groovy DSLs from beginner to expert
groovy DSLs from beginner to expertgroovy DSLs from beginner to expert
groovy DSLs from beginner to expert
 
Metaprogramming patterns
Metaprogramming patternsMetaprogramming patterns
Metaprogramming patterns
 
Domain Specific Languages
Domain Specific LanguagesDomain Specific Languages
Domain Specific Languages
 

More from Skills Matter

5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard LawrenceSkills Matter
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applicationsSkills Matter
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmSkills Matter
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimSkills Matter
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Skills Matter
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlSkills Matter
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsSkills Matter
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Skills Matter
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Skills Matter
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldSkills Matter
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Skills Matter
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Skills Matter
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingSkills Matter
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveSkills Matter
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tSkills Matter
 

More from Skills Matter (20)

5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence5 things cucumber is bad at by Richard Lawrence
5 things cucumber is bad at by Richard Lawrence
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
 
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvmScala e xchange 2013 haoyi li on metascala a tiny diy jvm
Scala e xchange 2013 haoyi li on metascala a tiny diy jvm
 
Oscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheimOscar reiken jr on our success at manheim
Oscar reiken jr on our success at manheim
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberlCukeup nyc ian dees on elixir, erlang, and cucumberl
Cukeup nyc ian dees on elixir, erlang, and cucumberl
 
Cukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.jsCukeup nyc peter bell on getting started with cucumber.js
Cukeup nyc peter bell on getting started with cucumber.js
 
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
Agile testing & bdd e xchange nyc 2013 jeffrey davidson & lav pathak & sam ho...
 
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
Progressive f# tutorials nyc rachel reese & phil trelford on try f# from zero...
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
Agile testing & bdd e xchange nyc 2013 gojko adzic on bond villain guide to s...
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
A poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testingA poet's guide_to_acceptance_testing
A poet's guide_to_acceptance_testing
 
Russ miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-diveRuss miles-cloudfoundry-deep-dive
Russ miles-cloudfoundry-deep-dive
 
Serendipity-neo4j
Serendipity-neo4jSerendipity-neo4j
Serendipity-neo4j
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Plug 20110217
Plug   20110217Plug   20110217
Plug 20110217
 
Lug presentation
Lug presentationLug presentation
Lug presentation
 
I went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_tI went to_a_communications_workshop_and_they_t
I went to_a_communications_workshop_and_they_t
 
Plug saiku
Plug   saikuPlug   saiku
Plug saiku
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Building DSLs: Marriage of High Essence and Groovy Metaprogramming

  • 1. Building DSLs High Essence Groovy MetaProgramming Venkat Subramaniam venkats@AgileDeveloper.com
  • 2. Communication How do we humans communicate? 2
  • 3. First Moon Landing Transcript... Two things go through my mind: 1. Wow 2. I’ve the faintest idea what they’re talking about! 3
  • 4. Communication As human we communicate using Jargons 4
  • 5. Aren’t Jargons Bad? They’re very bad for people who don’t understand the domain or don’t share the context You’d be totally lost But, they’re very good for people who share the context in the domain The communication is highly effective Terse, high signal—to—noise ratio This is what professionals use in their respective fields 5
  • 6. How do you use your App/ Computer? Typically you use keyword input files, configuration files, etc. If you’re stuck at an airport, which of these two agents gives you the most confidence you’ll be on your way—one that uses the keyboard, or the one that mouses around? The former, uses direct queries 6
  • 7. Productivity is Key A GUI makes an average user productive, but often may slowdown an expert user or a user very fluent with your application and its domain. You don't want to make the novice productive at the expense of making an expert counterproductive. 7
  • 8. Naked Objects Richard Pawson and Robert Matthews introduced the concept of Naked Objects They auto-build a thin object-oriented user interface (OOUI) from a domain model The OOUI exposes the behavior of domain objects for direct interaction by the users. 8
  • 9. How does an expert express Matrix Multiplication? 9
  • 10. Goal of a DSL The goal of DSLs is to provide a highly effective interface for your users to interact with your application. The interface may be graphical or textual. 10
  • 12. Domain Specific Language A language targeted at a particular type of problem Syntax focuses on intended domain/problem Unlike a general purpose language, you can’t use it for all kinds of stuff (or don’t want to) Limited in scope and capability Hence, they’re small and simple—that’s good 12
  • 13. Domain and Context What’s Domain? It is an area of sphere or knowledge, influence, or activity What’s Context? A logical framework within which we evolve models What’s Bounded Context? Context Defines a logical boundary of relevance within the context Domain 13
  • 14. What is it really? It’s a ubiquitous language—only narrow within a domain Domain folks understand it well Highly expressive and easy to use 14
  • 15. Where does it fit? You’re most likely to use multiple languages to build your application—Neal Ford’s vision for Polyglot Programmer. Martin Fowler argues that rather than using one big general purpose language, applications will use several small and limited DSLs—Languages Oriented Programming. Ola Bini argues at http://ola-bini.blogspot.com/ 2008/01/language-explorations.html that "three language layers will emerge in large applications" 15
  • 16. Where does it fit? Ola’s Pyramid Expressive Domain Specific DSL Layer Groovy/ Dynamic Layer JRuby (Most Functionality) Java/Scala/ JVM Small Stable Layer 16
  • 17. What’s Need to Build ‘em? Objects + Meta Programming (Aspects) + lots of Patience + 17
  • 18. Types of DSLs External DSLs Internal DSLs 18
  • 19. External DSL You define a new language You then parse the commands to take actions You have the liberty to chose the syntax you like You’re in full control—that’s good... and bad Can be lot of fun ;) One of my first jobs was to maintain lex and Yacc... 19
  • 20. External DSL Examples CSS is an example of an external DSL! 20
  • 21. External DSL Examples Good old Makefile is an example of external DSL 21
  • 22. External DSL Examples Ant is an example of external DSL 22
  • 23. Internal DSL Also known as Embedded DSLs Built on top of a host language Constructs of your host language are construed to form a DSL You don’t need to write an separate parser—that’s less work Commands tactfully map over to constructs like methods, etc. You can enjoy the host language’s flexibility, but you get bitten by its limitations and idiosyncrasies 23
  • 24. Internal DSL Examples Rake is an example of internal DSL! It is pure Ruby 24
  • 25. Internal DSL Examples Gant is an example of internal DSL! It is pure Groovy, wrapper around Ant 25
  • 26. Internal DSL Examples easyb is an example of internal DSL It is a Behavior Driven Design Tool and uses Groovy for expressing stories and behavior in a DSL form 26
  • 27. External or Internal It depends on your application Certain (dynamic) languages are better suited for internal DSLs Smalltalk, Lisp, Ruby, Groovy, ... Other languages are better suited for external DSL and offer good parsing libraries or capabilities C++, Java, C#, ... 27
  • 28. External or Internal External Internal +You decide syntax - You decide within limits of host language -You write parser for + Language takes care it of parsing + A tad easier to - You gotta find your design way around host + Once you write a - Hard to validate at parser, validation is a the moment, good breeze research potential 28
  • 29. Are all Languages Suited for Not really Internal DSLs? Low Ceremony + Metaprogramming is essential Scala, for example, has low ceremony, but lacks metaprogramming capabilities. So, not so easy to write internal DSLs with it Groovy, Ruby, ... shine due to high essence, low ceremony, and metaprogramming 29
  • 30. Characteristics of a DSL What are some of the qualities of a DSL? Context Driven Extremely context sensitive Fluent Interfaces Provides for a humane, easy to understand interface 30
  • 31. Context Driven DSL is extremely context sensitive or context driven A lot of things are knows from the context Without context, we may be confused or misled With context, there is less clutter, terse, but readable 31
  • 32. Context Driven ... I heard my friend Neal Ford yell out Quad Venti Latte with 2 Extra Shots What’s he talking about? He’s using the Starbucks DSL Nowhere did he mention the word coffee, but he sure got a good one at a high price ;) That’s context driven 32
  • 33. Context Driven ... I heard my friend Scott Davis mutter place a $ in a GString What’s he talking about? You don’t want to know He sure was talking about embedding variables into the Groovy’s mutable string class That’s also context driven :) 33
  • 34. Fluent Interface I was going to call this hygienic interface I like the name Eric Evans and Martin Fowler promote–Fluent Interface/Humane Interface It’s designed to be readable and to flow naturally Not easy to design–you put in more effort to create it, so it is easier for users to use 34
  • 35. Code With No Context What do you do with mailer object after call to send? Is the order important? Do I have to create an object each time? ... Can I just get my work done, can this be simpler? 35
  • 37. Let’s Look at them both We’ll see later how to build these... 37
  • 38. How do you write a Loop? Find total of numbers from 1 to 10 Why does the Java loop look like this? 38
  • 40. How to get Fluency? You can achieve fluency in Java as well You can use method chaining with a little compromise 40
  • 41. A Little Compromise Command Query Separation was promoted by Bertrand Meyer Command methods—mutators or modifiers—affect object state and don’t return anything Query methods—don’t affect object state and return useful information You compromise a little to be fluent (kind of like words bent to rhyme in a poem) Command methods return self or a promoter for a good flow 41
  • 42. Fluent Interface in EasyMock 42
  • 47. Let’s Order Pizza Voice on line (VOL): Thanks for calling Joe’s You: Ya, A Large Thin Crust VOL: Toppings? You: Olives, Onions, Bell Pepper VOL: Address You: 101 Main St.,... VOL: Card? You: Visa 1234-1234-1234-1234 VOL: 20 minutes–Thank you 47
  • 48. Java Pizza Order Not fluent Very noisy—how many times do you have to say joes_pizza? Can we make it fluent? 48
  • 49. with Some languages have a with keyword within the scope, methods are invoked on an implicit object Here is an example from JavaScript 49
  • 50. with in Groovy? Groovy has with keyword which is synonym for identity method 50
  • 51. How about Fluent Java? Less clutter There is a context in each call Each set method (except setCard()) returns this (PizzaShop) Can we make this a bit more readable? 51
  • 52. A bit more Fluent... Method names make sense in the flow, but may not make sense alone What’s a catch? 52
  • 53. Ordered vs. Unordered Some DSLs may require a certain order in the flow You can force ordering by tactfully defining return types that will allow method chaining in only certain order Not easy Others may not require ordering It depends on the particular problem Ideally, not requiring an order is great, but may not always be possible 53
  • 54. How to Enforce Sequence? 54
  • 55. Closures Make It Easier 55
  • 56. OK, but... You may not be able to deviate from standard API conventions What if it is existing API or there are other reasons to follow conventions? You can use a Façade or expression builder It sits on top of existing traditional API and provides context and fluency For example, Groovy has a number of these builders built-in 56
  • 57. Groovy Builder: XML Fluency to build XML 57
  • 58. Groovy Builder: Swing Fluency to build Swing GUI 58
  • 59. Creating DSLs You may use tools like Antlr for working with DSLs JetBrains is working on Meta Programming System(MPS) Languages like Ruby and Groovy may it easier to create (internal) DSLs What makes Groovy attractive? Classes are always open Closures and Builders Categories and ExpandoMetaClass To some extent operator overloading 59 Parenthesis are almost optional (a bit lacking)
  • 60. Creating a DSL in Groovy file:order See next page file:process.groovy output 60
  • 61. Creating a DSL in Groovy contents of file:defs.groovy methodMissing 61
  • 62. transmogrification How to deal with fluency, context, and ordering You can tactfully return different interfaces so only correct sequence of calls will fit in Return an appropriate interface from your methods and let method chaining take over 62
  • 63. Using Categories Type conversions ------------------------ 2 => int .days => int .ago => Calendar .at => Date 63
  • 65. Using EMC 65
  • 66. Categories vs. ExpandoMetaClass Categories allows you to tactically enhance a class ExpandoMetaClass is far reaching, global in nature You may not want to affect a class globally Categories provide controlled flexibility 66
  • 67. Run Your DSL within a Context Running your DSL out in the open is not good: Unpredictable, unsettling Run it within the context of an object 67
  • 68. Running in a context scores See next page Output 68
  • 69. Running in a Context 69
  • 70. Running in a Context 70
  • 71. References http://martinfowler.com/bliki/DomainSpecificLanguage.html http://docs.codehaus.org/display/GROOVY/Writing+Domain-Specific+Languages http://docs.codehaus.org/display/GROOVY/Gant http://groovy.codehaus.org/ExpandoMetaClass http://www.onboard.jetbrains.com/is1/articles/04/10/lop/ http://www.jetbrains.com/mps Martin Fowler’s book work in progress: http://martinfowler.com/dslwip A Chapter on creating DSL in Groovy: “Programming Groovy: Dynamic Productivity for Java Developers” by Venkat Subramaniam (Pragmatic Bookshelf). You can download examples and slides from http://www.agiledeveloper.com - download 71
  • 72. References A number of references from the following URL http://martinfowler.com/bliki/DomainSpecificLanguage.html http://docs.codehaus.org/display/GROOVY/Writing+Domain-Specific +Languages http://docs.codehaus.org/display/GROOVY/Gant http://groovy.codehaus.org/ExpandoMetaClass http://www.onboard.jetbrains.com/is1/articles/04/10/lop/ http://www.jetbrains.com/mps You can download examples and slides from http://www.agiledeveloper.com - download 72
  • 73. Thank You! Please fill in your session evaluations You can download examples and slides from http://www.agiledeveloper.com - download 73