Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Composing Domain-Specific Languages

2,827 views

Published on

The history of programming languages shows a progressive development from low-level programming languages close to the machine, to high-level languages close to the problems being solved with software. Domain-specific languages take this a step further than general purpose programming languages by making assumptions about the class of applications for which the language is intended. Complete applications typically require programs in multiple (technical) domains, which can be catered for by separate domain-specific languages. While such separation of concerns is beneficial for domain expressivity, it often leads to loose coupling and lack of static verification. Hence, the design of individual DSLs needs to be complemented with their linguistic integration.

In this talk, I illustrate these ideas with the design of WebDSL, a domain-specific language for data centric web applications. WebDSL linguistically integrates the definition of data models, user interfaces, actions, access control rules, data validation rules, styling rules, and workflow definitions. While maintaining separation between these concerns through specialized sub-languages, linguistic integration ensures static consistency checking and correct code generation. The language allows developers to concentrate on the essential design of web applications, abstracting from accidental complexity, such as the details of data persistence. The combination of high-level and low-level constructs ensures high expressivity, while supporting customization to application requirements.

Published in: Technology

Composing Domain-Specific Languages

  1. 1. Composing Domain-Specific Languages Eelco Visser Delft University of Technology http://eelcovisser.org 12/11/2009 Technical University Eindhoven
  2. 2. Software Engineering implement Problem Solution Domain Domain validate
  3. 3. Programming Languages
  4. 4. Abstraction Scala Programming Languages machine
  5. 5. Abstraction Scala garbage collection objects Programming Languages expressions structured control-flow procedures machine
  6. 6. Problem GPL Machine Domain
  7. 7. The Next Level of Abstraction? Formal Methods
  8. 8. Spec Problem GPL Machine Domain
  9. 9. Spec Problem GPL Machine Domain
  10. 10. The Next Level of Abstraction? Domain-Specific Languages
  11. 11. The Next Level of Abstraction? SQL Domain-Specific Languages CFG (BNF) RegExp
  12. 12. Problem DSL GPL Machine Domain Domain-Specific Languages: Specialization
  13. 13. Software System Composition of Specialized Sub-domains
  14. 14. Software System Separation of Concerns Composition of Specialized Sub-domains
  15. 15. Loose Coupling Lack of consistency checks
  16. 16. Thesis Separation of Concerns requires Linguistic Integration
  17. 17. Case Study World Wide Web
  18. 18. where does that link point? is that URL unique? who may edit this entry? where is data stored?
  19. 19. request Client Server response Architecture
  20. 20. quest Convert Request Access Control Validate Forms Parameters Render Page Or Handle Actions Redirect ponse Update Database
  21. 21. Access Data Navigation quest Convert Request Control Validation Access Control Validate Forms Parameters Forms Data Model Actions Render Page Or Handle Actions Redirect ponse Object Page Data Binding Relational Templates Mapping Update Database
  22. 22. Access Data Navigation Control Validation Forms Data Model Actions Object Page Data Binding Relational Templates Mapping (Some) Concerns in Web Applications
  23. 23. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping data model entity class classes orm JPA active record actions Java/Seam Ruby data validation navigation servlets controllers page templates JavaServer Faces forms JSF tags embedded html data binding JSF + Seam access control Acegi
  24. 24. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping <s:link view="/entry.xhtml" value="#{entry.title}" propagation="none"> <f:param name="entry" value="#{entry.id}"/> </s:link> @Name("entry") public class EntryBean implements EntryBeanInterface { @RequestParameter("entry") private Long entryId; }
  25. 25. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping map.root :controller => "homme" # should be "home" http://zef.me/2308/when-rails-fails
  26. 26. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping data model entity class classes orm JPA active record actions Java/Seam boilerplate code Ruby data validation navigation loose coupling servlets controllers page templates JavaServer Faces forms no/little consistency checking JSF tags embedded html data binding JSF + Seam access control Acegi
  27. 27. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping - separate languages for separate concerns - linguistically integrated - compile-time consistency checking - 100% code generation (no scaffolding)
  28. 28. Access Data Navigation Control Validation Forms Data Model Actions entity Blog { name :: String (id) Object Page Templates Data Binding Relational entries -> Set<Entry> Mapping authors -> Set<User> } entity Entry { url :: String (id) title :: String (name) text :: WikiText blog -> Blog (inverse=Blog.entries) author -> User (inverse=User.entries) created :: DateTime } entity User { username :: String password :: Secret blogs -> Set<Blog> (inverse=Blog.authors) entries -> Set<Entry> (inverse=Entry.author) }
  29. 29. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping define page entry(e : Entry) { header{output(e.title)} output(e.text) “Posted by “ output(e.author) “ on “ output(e.created) navigate(editentry(e)){“Edit”} }
  30. 30. Access Data Navigation Control Validation Data Forms Actions Model define page editentry(e : Entry) { Object Page Data Relational Templates Binding Mapping form{ input(e.url) input(e.title) input(e.text) input(e.author) input(e.created) action(“Save”, action{ return entry(e); }) } }
  31. 31. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping entity Entry { url validate(isUniqueEntry(this), “Entry with that URL already exists”) }
  32. 32. Access Data Navigation Control Validation Forms Data Actions access control rules Model Page Data Object Relational principal is User Templates Binding Mapping with credentials username, password rule page entry(e : Entry) { !e.private || principal in e.blog.authors } rule page newentry(b : Blog) { principal in e.blog.authors } rule page editentry(e : Entry) { e.author == principal }
  33. 33. Access Data Navigation Control Validation Data Forms Actions Model Object Page Data Relational Templates Binding Mapping - separate languages for separate concerns - linguistically integrated - compile-time consistency checking - 100% code generation (no scaffolding) - order of magnitude decrease in code size
  34. 34. http://researchr.org
  35. 35. Access Data Navigation Control Validation Data Forms Actions Model Object Stratego/XT Page Data Relational Templates Binding Mapping Domain-Specific Language Engineering
  36. 36. Access Data Navigation Control Validation Data Forms Actions Model Object Stratego/XT Page Data Relational Templates Binding Mapping WebDSL Java
  37. 37. Access Data Navigation Control Validation Data Forms Actions Model Object Stratego/XT Page Data Relational Templates Binding Mapping Core WebDSL Java WebDSL
  38. 38. Access Data Navigation Control Validation Data Forms Actions Model Object Stratego/XT Page Data Relational Templates Binding Mapping Python Core WebDSL Java WebDSL C#
  39. 39. Access Data Navigation Control Validation Data Forms Actions Model Object Stratego/XT Page Data Relational Templates Binding Mapping Python Core WebDSL PIL Java WebDSL C#
  40. 40. Access Data Navigation Control Validation Data Forms Actions Model Object Stratego/XT Page Data Relational Templates Binding Mapping Component-Based Language Engineering DM PIL Python UI PIL AC PIL + WebDSL Core WebDSL PIL Java C# DV PIL
  41. 41. Access Data Navigation Control Validation Data Forms Actions Model Page Data Object Relational - separate languages for separate concerns Templates Binding Mapping - linguistically integrated - compile-time consistency checking - 100% code generation (no scaffolding) - order of magnitude decrease in code size http://webdsl.org http://strategoxt.org http://researchr.org

×