1 / 18

How domain specific are Domain Specific Languages?

How domain specific are Domain Specific Languages?. Greg Michaelson School of Mathematical & Computer Sciences H eriot-Watt University. Introduction. tiresome writing lots of small programs for same problem area end up using same set of: programming tropes abstractions types

walda
Télécharger la présentation

How domain specific are Domain Specific Languages?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How domain specific are Domain Specific Languages? Greg Michaelson School of Mathematical & Computer Sciences Heriot-Watt University

  2. Introduction • tiresome writing lots of small programs for same problem area • end up using same set of: • programming tropes • abstractions • types • data structures • control

  3. Introduction • construct an ad hoc command based framework • scripts to invoke and configure individual programs • nice to deploy some consistent notation oriented to problem area • with built in constructs capturing specialised abstractions • domain specific language - DSL

  4. Embeded DSL (EDSL) • DSL embeded in extant host language 1. add library to host language • call through API • can use arbitrary host language constructs • not a DSL?

  5. Embeded DSL 2. add abstract syntax • interpret abstract syntax trees • call interpreter components from arbitrary host language constructs • shallow embeding

  6. Embeded DSL 3. design concrete syntax • add concrete syntax -> AST compiler • call interpreter component with parsed strings • can embed interpreter component calls in arbitrary host language constructs • shallow embeding. 4. extend extant language syntax and semantics • deep embeding

  7. Embeded DSL • host language exposed • not Domain Specific? • EDSL inherits semantics of host language • if host language is not Turing complete (TC) then EDSL may be more expressive • can’t be less or differently expressive • if host language is TC then so is EDSL • not Domain Specific?

  8. Implemented DSL • expose parser/interpreter only as stand alone language processor • can only use domain specific syntax • have implemented DSL in host language

  9. Implemented DSL • tend to want familiar general purpose programming language abstractions as well: • arithmetic & logic • sequence/selection/iteration • sub programs • sequences etc • as DSL grows, tends to become less and less DS...

  10. Language • language = syntax + semantics • semantics: program * state -> state • semantics transforms initial state to final state guided by structure of program instance

  11. Language and program • program: input * state -> output * state • treat outputs as part of final state • program: input * state -> state • program changes initial state to final state depending on input structure • define input structure with syntax • program is semantics of inputs • does every program define a DSL?

  12. What is domain specificity? • Light Bulb Language program -> switch switch -> SWITCH |ε m [SWITCH] ON = OFF m [SWITCH] OFF = ON m [ε] ON = ON m [ε] OFF = OFF

  13. What is domain specificity? • Linear Light Bulbs Language program -> row | row program row -> switch | switch row si ϵswitch biϵ {ON,OFF} m’ [s1,...,sN] {b1,...,bN} = {m s1 b1,...,m sNbN}

  14. What is domain specificity? • Grid Light Bulbs Language program -> grid grid -> row | row grid riϵrow briϵ b* m’’ [r1,...,rN] {br1,...,brN} = {m’ r1br1,...,m’ rNbrN}

  15. What is domain specificity? • is GLBL domain specific...? • light bulbs? • B/W image inversion? • negating boolean values? • not very DS...

  16. What is domain specificity? • computer pioneers thought machine code was for configuring hardware • 60’s language designers thought languages were purpose specific: • FORTRAN - sums • COBOL - accounts • ALGOL - algorithms • LISP - symbols • IMP - systems

  17. What is domain specificity? • designers of new languages think they’ve enabled something other languages can’t do • new TC language ≡ old TC language + syntax + library • is every language really an embeded DSL with a TC host?

  18. DSL is about pragmatics • DSL abstractions & constructs make it easier to express particular things • what may be complex in an arbitrary TC language may become simpler in a DSL • domain may frame choice of DSL abstractions & constructions • abstractions and constructions from one domain may be appropriate for other domains

More Related