SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
Practical DSL Design
                       London Groovy & Grails User Group
                               May 17th, 2010

                                 Peter Bell
                            CEO/CTO SystemsForge



Monday, May 17, 2010
Overview
  • What is a DSL?
  • Key Concepts
  • DSL Design
  • Implementing DSLs
  • Additional Considerations
           •      Testing, evolution, documentation,
                  error handling , IDE support




Monday, May 17, 2010
Goals:
  • Understand:
    • What is a DSL
    • Where use one
    • Engineering considerations
  • NOT about syntax



Monday, May 17, 2010
Division of Labor

    •       My Job:
        •      Present ideas


    •       Your Job:
        •      Discriminate, select, adapt, experiment




Monday, May 17, 2010
About Me
   • Programmer: 50-80 projects/yr
   • Entrepreneur: profitable/practical
   • Research:
     • Domain Specific Modeling/DSLs
     • Software Product Lines
   • Writer: GroovyMag, InfoQ, IEEE
              Software, JSMag, Methods & Tools,
              Fusion Authority, Flex Authority . . .
      •       Presenter: ooPSLA, Code
              Generation, BCS SPA . . .

Monday, May 17, 2010
What is a DSL?
      •      Specific to single domain - generally not
             Turing complete (excl. XSLT)
      •      More expressive than GPL within the
             domain
      •      Executable
      •      Examples: SQL, CSS, Regex, PC
             configurator, document workflow rules




Monday, May 17, 2010
What is a DSL? - DSL vs. API
   • Subjective
   • Often facade to API
   • Focus on language nature
   • “Fluent” interface
     API: new event( startTime: "16:00", endTime: "18:00" )
     DSL: new event.from 4.pm, to: 6.pm



Monday, May 17, 2010
What is a DSL? - Benefits
   • Expressive (clear intent, concise)
   • Separate business logic from code
   • Separate lifecycle
   • SME readable (not writable)




Monday, May 17, 2010
What is a DSL? - When Use?
      •       Frequently changing business rules
      •       Interactions with stakeholders
      •       Relatively well understood domain
      •       Typical use cases:
            •      Product family
            •      Platform based development
            •      Configuration
            •      Business rule definitions

Monday, May 17, 2010
Key Concepts
   • Overview:
     • Vertical vs horizontal
     • Abstract vs Concrete
     • Projections
     • Three types of DSL
     • Internal vs. External


Monday, May 17, 2010
Vertical vs. Horizontal
      •       Horizontal: technical domain
            •      SQL, CSS, GORM . . .
            •      More maintainable/readable code
            •      Good enough is good enough
      •       Vertical: business domain
            •      Insurance, PC configurator . . .
            •      Share “code” with SME’s
            •      Readability is key

Monday, May 17, 2010
Abstract vs. Concrete
   • Abstract grammar       <person>
     • what say                <FirstName>Paul</FirstName>
                               <LastName>King</LastName>
   • Concrete syntax        </person>
     • how say new person( firstName: "Paul", lastName: "King" )
                                      person called “Paul “, “ King “

                                                          Paul King




Monday, May 17, 2010
Projections
   • Multiple projections
     • Textual
     • Spreadsheet
     • Visual
     • Form based



Monday, May 17, 2010
Three Broad Types of DSL
   • Internal (embedded)
   • External (parser)
   • Language workbench




Monday, May 17, 2010
Internal vs. External
   • Internal:              • External:
     • Easier to implement • Easier to evolve
     • Power of GPL:         • End user writable (forms)?
       • Loops               • Projectional:
       • Math                  • Forms
       • Conditionals . . .    • Visual
     • Refactor to external    • Spreadsheet

Monday, May 17, 2010
Top Down/Bottom Up
   • Bottom up:
     • Evolve from API (e.g.
                  Hibernate)
          •       Not very expressive, but
                  quick starting point
     •      Top down:
          •       Sketch out UL with
                  stakeholders
          •       Generally better language

Monday, May 17, 2010
General Hints
   • Learn from DDD/UL:
     • Common, rigorous understanding
     • Driven by domain model
     • Involve to SME’s
   • Lots of little languages (e.g. Grails)
     • Bounded contexts
   • Risk:
     • DSL eventually becomes badly designed GPL
     • Think: Ant
Monday, May 17, 2010
Implementing DSLs
   • API
   • Fluent interface
   • Reducing visual noise
   • Config file/XML/Json
   • Simple parser
   • Nested parser


Monday, May 17, 2010
API
   • Good starting point
   • Easy to evolve
   • Often readable enough . . .
     Event salesMeet = new event( startTime: "16:00", endTime: "18:00" )
     Participant Joe = new Participant( firstName: “Joe”, lastName: “Smith” )
     Participant Fred = new Participant( firstName: “Fred”, lastName: “Jones” )
     salesMeet.addParticipant( Joe )
     salesMeet.addParticipant( Fred )




Monday, May 17, 2010
Fluent interface
   • The start of DSLs
   • Language nature
   • Focus on sentence like syntax
                       Event salesMeet = new event( from: 4.pm, to: 6.pm )
                                                  .with( “Joe”, “Smith” )
                                                  .and( “Fred”, “Jones” )




Monday, May 17, 2010
Reducing Visual Noise
   • Flexible and malleable
              syntax
      •       Metaprogramming
      •       AST transformations




     © Guillaume Laforge
Monday, May 17, 2010
Flexible and Malleable Syntax
   • Scripts
   • Optional typing
   • Native syntax constructs
     • (lists, maps)
   • Parentheses/semi omission
   • Named arguments
   • Operator overloading
   • Closures
     © Guillaume Laforge
Monday, May 17, 2010
Metaprogramming
   • PoGo
   • Categories
   • Builders
   • Custom metaclass
   • ExpandoMetaClass


     © Guillaume Laforge
Monday, May 17, 2010
AST Transformations
      •       AST traversal
      •       Local transformations
      •       Global transformations
      •       Hooks into ANTLR




     © Guillaume Laforge
Monday, May 17, 2010
Outcome:
               event from 4.pm to 6.pm
                        .with “Joe” “Smith”
                        .and “Fred” “Jones”




     © Guillaume Laforge
Monday, May 17, 2010
Config File/XML/Json
   • Introduction to external DSLs
   • Easy to load/parse
   • Supports projections and tooling
          <events>
            <event startTime=”16:00” endTime=”18:00”>
              <participants>
                <participant firstname=”Joe” lastName=”Smith” />
                <participant firstname=”Joe” lastName=”Smith” />
              </participants>
            </event>
          <events>


Monday, May 17, 2010
Simple Parser
   • Delimiter directed translation
     • Regex or similar
     • Doesn’t support nesting
     • Only for simplest languages




Monday, May 17, 2010
Nested Parser
   • Syntax directed translation
     • Grammar/parser
     • ANTLR




Monday, May 17, 2010
Additional Considerations
   • Testing
   • Evolution
   • Documentation
   • Error handling
   • IDE support



Monday, May 17, 2010
Testing DSLs
   • Test domain model
   • Test fluent interface
              (expression builder)
            •      Can Compile
            •      Scenarios
            •      Orthogonal test DSLs




Monday, May 17, 2010
DSL Evolution
   • The problem: success!
   • Approaches:
     • No changes
     • Backwards compatibility
     • Versioning
     • Model migrations


Monday, May 17, 2010
Documentation
   • Getting started guide
   • Samples
   • FAQs for common tasks
   • Language reference
   • Some debugging suggestions
   • Not more than API requires
   • Source/regression tests help but
              aren't enough


Monday, May 17, 2010
Error Handling
   • Throw while process = easy
   • Meaningful messages hard




Monday, May 17, 2010
IDE Support
   • Syntax highlighting
   • Code completion
   • Static verification
   • IntelliJ helps . . .
   • If important, consider Xtext/EMF



Monday, May 17, 2010
Conclusions
   • It’s all about the domain
   • Evolve to DSLs
   • API to internal . . .
   • . . . external if required
   • Check Guillaume’s preso
              for syntax
      •       Think about additional
              considerations from day 1



Monday, May 17, 2010
Resources

   History:
   http://www.faqs.org/docs/artu/minilanguageschapter.html

   DSM:
   JP Tolvanen: http://www.metacase.com/blogs/jpt/blogView
   Steve Kelly: http://www.metacase.com/blogs/stevek/blogView
   Markus Voelter: http://www.voelter.de/

   DDD:
   http://domaindrivendesign.org/



Monday, May 17, 2010
Resources (2)
  DSLs:
  Martin Fowler: http://martinfowler.com/dslwip/

  Groovy DSLs:
  Google - Guillaume Laforge, Paul King, Hamlet D’Arcy,Venkat Subramaniam,
  Neil Ford

  DSL Evolution:
  http://www.infoq.com/articles/dsl-evolution

  Books:
  Domain Specific Modeling - Kelly/Tolvanen
  Generative Programming - Czarnecki/Eisenecker
  Domain Driven Design - Evans
Monday, May 17, 2010
The End!
  • http://gettinggroovy.com
  • Email: peter@pbell.com
  • Twitter: peterbell




Monday, May 17, 2010

Más contenido relacionado

Similar a GGUG:Practical DSL Design

An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming languageTechnology Parser
 
GoOpen 2010: David Elboth
GoOpen 2010: David ElbothGoOpen 2010: David Elboth
GoOpen 2010: David ElbothFriprogsenteret
 
Debugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsDebugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsAlvaro Videla
 
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...Brian Huff
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLAndreas Jung
 
Beyond Java: Go for Java developers
Beyond Java: Go for Java developersBeyond Java: Go for Java developers
Beyond Java: Go for Java developersNetcetera
 
150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugsNetcetera
 
Introduction to webprogramming using PHP and MySQL
Introduction to webprogramming using PHP and MySQLIntroduction to webprogramming using PHP and MySQL
Introduction to webprogramming using PHP and MySQLanand raj
 
MWLUG 2011: The Never Ending Integration Story
MWLUG 2011: The Never Ending Integration StoryMWLUG 2011: The Never Ending Integration Story
MWLUG 2011: The Never Ending Integration StoryJohn Head
 
OpenDocument Scripting
OpenDocument ScriptingOpenDocument Scripting
OpenDocument ScriptingMarco Fioretti
 
Becoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris AndreadisBecoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris AndreadisOpenBlend society
 
MyIBBT - Project Collaboration with Alfresco Share
MyIBBT - Project Collaboration with Alfresco ShareMyIBBT - Project Collaboration with Alfresco Share
MyIBBT - Project Collaboration with Alfresco ShareAmplexor
 
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...PatrickCrompton
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusioncolinbdclark
 
Operational MongoDB
Operational MongoDBOperational MongoDB
Operational MongoDBMitch Pirtle
 
Evergreen Documentation Lightning Talk
Evergreen Documentation Lightning TalkEvergreen Documentation Lightning Talk
Evergreen Documentation Lightning TalkEvergreen ILS
 
Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2rusersla
 

Similar a GGUG:Practical DSL Design (20)

An introduction to go programming language
An introduction to go programming languageAn introduction to go programming language
An introduction to go programming language
 
GoOpen 2010: David Elboth
GoOpen 2010: David ElbothGoOpen 2010: David Elboth
GoOpen 2010: David Elboth
 
Debugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsDebugging and Profiling Symfony Apps
Debugging and Profiling Symfony Apps
 
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQL
 
Rust 101 (2017 edition)
Rust 101 (2017 edition)Rust 101 (2017 edition)
Rust 101 (2017 edition)
 
Beyond Java: Go for Java developers
Beyond Java: Go for Java developersBeyond Java: Go for Java developers
Beyond Java: Go for Java developers
 
150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs150603 go go-beyond-vckovski-jugs
150603 go go-beyond-vckovski-jugs
 
Introduction to webprogramming using PHP and MySQL
Introduction to webprogramming using PHP and MySQLIntroduction to webprogramming using PHP and MySQL
Introduction to webprogramming using PHP and MySQL
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
MWLUG 2011: The Never Ending Integration Story
MWLUG 2011: The Never Ending Integration StoryMWLUG 2011: The Never Ending Integration Story
MWLUG 2011: The Never Ending Integration Story
 
OpenDocument Scripting
OpenDocument ScriptingOpenDocument Scripting
OpenDocument Scripting
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
Becoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris AndreadisBecoming an Open Source developer, Dimitris Andreadis
Becoming an Open Source developer, Dimitris Andreadis
 
MyIBBT - Project Collaboration with Alfresco Share
MyIBBT - Project Collaboration with Alfresco ShareMyIBBT - Project Collaboration with Alfresco Share
MyIBBT - Project Collaboration with Alfresco Share
 
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
eSynergy Andy Hawkins - Enabling DevOps through next generation configuration...
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusion
 
Operational MongoDB
Operational MongoDBOperational MongoDB
Operational MongoDB
 
Evergreen Documentation Lightning Talk
Evergreen Documentation Lightning TalkEvergreen Documentation Lightning Talk
Evergreen Documentation Lightning Talk
 
Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2Los Angeles R users group - Nov 17 2010 - Part 2
Los Angeles R users group - Nov 17 2010 - Part 2
 

Más de 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
 

Más de 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
 

Último

activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 

Último (20)

activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 

GGUG:Practical DSL Design

  • 1. Practical DSL Design London Groovy & Grails User Group May 17th, 2010 Peter Bell CEO/CTO SystemsForge Monday, May 17, 2010
  • 2. Overview • What is a DSL? • Key Concepts • DSL Design • Implementing DSLs • Additional Considerations • Testing, evolution, documentation, error handling , IDE support Monday, May 17, 2010
  • 3. Goals: • Understand: • What is a DSL • Where use one • Engineering considerations • NOT about syntax Monday, May 17, 2010
  • 4. Division of Labor • My Job: • Present ideas • Your Job: • Discriminate, select, adapt, experiment Monday, May 17, 2010
  • 5. About Me • Programmer: 50-80 projects/yr • Entrepreneur: profitable/practical • Research: • Domain Specific Modeling/DSLs • Software Product Lines • Writer: GroovyMag, InfoQ, IEEE Software, JSMag, Methods & Tools, Fusion Authority, Flex Authority . . . • Presenter: ooPSLA, Code Generation, BCS SPA . . . Monday, May 17, 2010
  • 6. What is a DSL? • Specific to single domain - generally not Turing complete (excl. XSLT) • More expressive than GPL within the domain • Executable • Examples: SQL, CSS, Regex, PC configurator, document workflow rules Monday, May 17, 2010
  • 7. What is a DSL? - DSL vs. API • Subjective • Often facade to API • Focus on language nature • “Fluent” interface API: new event( startTime: "16:00", endTime: "18:00" ) DSL: new event.from 4.pm, to: 6.pm Monday, May 17, 2010
  • 8. What is a DSL? - Benefits • Expressive (clear intent, concise) • Separate business logic from code • Separate lifecycle • SME readable (not writable) Monday, May 17, 2010
  • 9. What is a DSL? - When Use? • Frequently changing business rules • Interactions with stakeholders • Relatively well understood domain • Typical use cases: • Product family • Platform based development • Configuration • Business rule definitions Monday, May 17, 2010
  • 10. Key Concepts • Overview: • Vertical vs horizontal • Abstract vs Concrete • Projections • Three types of DSL • Internal vs. External Monday, May 17, 2010
  • 11. Vertical vs. Horizontal • Horizontal: technical domain • SQL, CSS, GORM . . . • More maintainable/readable code • Good enough is good enough • Vertical: business domain • Insurance, PC configurator . . . • Share “code” with SME’s • Readability is key Monday, May 17, 2010
  • 12. Abstract vs. Concrete • Abstract grammar <person> • what say <FirstName>Paul</FirstName> <LastName>King</LastName> • Concrete syntax </person> • how say new person( firstName: "Paul", lastName: "King" ) person called “Paul “, “ King “ Paul King Monday, May 17, 2010
  • 13. Projections • Multiple projections • Textual • Spreadsheet • Visual • Form based Monday, May 17, 2010
  • 14. Three Broad Types of DSL • Internal (embedded) • External (parser) • Language workbench Monday, May 17, 2010
  • 15. Internal vs. External • Internal: • External: • Easier to implement • Easier to evolve • Power of GPL: • End user writable (forms)? • Loops • Projectional: • Math • Forms • Conditionals . . . • Visual • Refactor to external • Spreadsheet Monday, May 17, 2010
  • 16. Top Down/Bottom Up • Bottom up: • Evolve from API (e.g. Hibernate) • Not very expressive, but quick starting point • Top down: • Sketch out UL with stakeholders • Generally better language Monday, May 17, 2010
  • 17. General Hints • Learn from DDD/UL: • Common, rigorous understanding • Driven by domain model • Involve to SME’s • Lots of little languages (e.g. Grails) • Bounded contexts • Risk: • DSL eventually becomes badly designed GPL • Think: Ant Monday, May 17, 2010
  • 18. Implementing DSLs • API • Fluent interface • Reducing visual noise • Config file/XML/Json • Simple parser • Nested parser Monday, May 17, 2010
  • 19. API • Good starting point • Easy to evolve • Often readable enough . . . Event salesMeet = new event( startTime: "16:00", endTime: "18:00" ) Participant Joe = new Participant( firstName: “Joe”, lastName: “Smith” ) Participant Fred = new Participant( firstName: “Fred”, lastName: “Jones” ) salesMeet.addParticipant( Joe ) salesMeet.addParticipant( Fred ) Monday, May 17, 2010
  • 20. Fluent interface • The start of DSLs • Language nature • Focus on sentence like syntax Event salesMeet = new event( from: 4.pm, to: 6.pm ) .with( “Joe”, “Smith” ) .and( “Fred”, “Jones” ) Monday, May 17, 2010
  • 21. Reducing Visual Noise • Flexible and malleable syntax • Metaprogramming • AST transformations © Guillaume Laforge Monday, May 17, 2010
  • 22. Flexible and Malleable Syntax • Scripts • Optional typing • Native syntax constructs • (lists, maps) • Parentheses/semi omission • Named arguments • Operator overloading • Closures © Guillaume Laforge Monday, May 17, 2010
  • 23. Metaprogramming • PoGo • Categories • Builders • Custom metaclass • ExpandoMetaClass © Guillaume Laforge Monday, May 17, 2010
  • 24. AST Transformations • AST traversal • Local transformations • Global transformations • Hooks into ANTLR © Guillaume Laforge Monday, May 17, 2010
  • 25. Outcome: event from 4.pm to 6.pm .with “Joe” “Smith” .and “Fred” “Jones” © Guillaume Laforge Monday, May 17, 2010
  • 26. Config File/XML/Json • Introduction to external DSLs • Easy to load/parse • Supports projections and tooling <events> <event startTime=”16:00” endTime=”18:00”> <participants> <participant firstname=”Joe” lastName=”Smith” /> <participant firstname=”Joe” lastName=”Smith” /> </participants> </event> <events> Monday, May 17, 2010
  • 27. Simple Parser • Delimiter directed translation • Regex or similar • Doesn’t support nesting • Only for simplest languages Monday, May 17, 2010
  • 28. Nested Parser • Syntax directed translation • Grammar/parser • ANTLR Monday, May 17, 2010
  • 29. Additional Considerations • Testing • Evolution • Documentation • Error handling • IDE support Monday, May 17, 2010
  • 30. Testing DSLs • Test domain model • Test fluent interface (expression builder) • Can Compile • Scenarios • Orthogonal test DSLs Monday, May 17, 2010
  • 31. DSL Evolution • The problem: success! • Approaches: • No changes • Backwards compatibility • Versioning • Model migrations Monday, May 17, 2010
  • 32. Documentation • Getting started guide • Samples • FAQs for common tasks • Language reference • Some debugging suggestions • Not more than API requires • Source/regression tests help but aren't enough Monday, May 17, 2010
  • 33. Error Handling • Throw while process = easy • Meaningful messages hard Monday, May 17, 2010
  • 34. IDE Support • Syntax highlighting • Code completion • Static verification • IntelliJ helps . . . • If important, consider Xtext/EMF Monday, May 17, 2010
  • 35. Conclusions • It’s all about the domain • Evolve to DSLs • API to internal . . . • . . . external if required • Check Guillaume’s preso for syntax • Think about additional considerations from day 1 Monday, May 17, 2010
  • 36. Resources History: http://www.faqs.org/docs/artu/minilanguageschapter.html DSM: JP Tolvanen: http://www.metacase.com/blogs/jpt/blogView Steve Kelly: http://www.metacase.com/blogs/stevek/blogView Markus Voelter: http://www.voelter.de/ DDD: http://domaindrivendesign.org/ Monday, May 17, 2010
  • 37. Resources (2) DSLs: Martin Fowler: http://martinfowler.com/dslwip/ Groovy DSLs: Google - Guillaume Laforge, Paul King, Hamlet D’Arcy,Venkat Subramaniam, Neil Ford DSL Evolution: http://www.infoq.com/articles/dsl-evolution Books: Domain Specific Modeling - Kelly/Tolvanen Generative Programming - Czarnecki/Eisenecker Domain Driven Design - Evans Monday, May 17, 2010
  • 38. The End! • http://gettinggroovy.com • Email: peter@pbell.com • Twitter: peterbell Monday, May 17, 2010