Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "How domain specific are Domain Specific Languages? Greg Michaelson School of Mathematical & Computer Sciences Heriot-Watt University."— 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 s i ϵ switch b i ϵ {ON,OFF} m’ [s 1,...,s N ] {b 1,...,b N } = {m s 1 b 1,...,m s N b N }

14 What is domain specificity? Grid Light Bulbs Language program -> grid grid -> row | row grid r i ϵ row br i ϵ b* m’’ [r 1,...,r N ] {br 1,...,br N } = {m’ r 1 br 1,...,m’ r N br N }

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


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

Similar presentations


Ads by Google