domain specific languages
DESCRIPTION
Design Patterns and methodologies for implementing DSL.TRANSCRIPT
![Page 1: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/1.jpg)
Domain Specific LanguagesDesign Patterns and Methodologies
Lakshan Perera ([email protected])
Faculty of Information TechnologyUniversity of Moratuwa
![Page 2: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/2.jpg)
![Page 3: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/3.jpg)
“Our understanding of the nature of language and the mental processes and structures that underlies its use and acquisition”
Noam ChomskyCartesian Linguistics
![Page 4: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/4.jpg)
What is Domain Specific Language(DSL) ?
![Page 5: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/5.jpg)
“(DSL) is a computer language that'stargeted to a particular kind of problem,rather than a general purpose languagethat's aimed at any kind of softwareproblem.”
Martin Fowler
![Page 6: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/6.jpg)
4th Generation of Programming Languages
![Page 7: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/7.jpg)
Evolution
➣ APT (1957 – 1958)
➣ COBOL, FORTRAN and PERL
➣ Unix Mini-languages (yacc, lex, make)
➣ Lisp (Bottom-up design)
![Page 8: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/8.jpg)
Advantages of using DSL
![Page 9: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/9.jpg)
Direct Involvement of Domain Expert
![Page 10: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/10.jpg)
Improved Productivity
![Page 11: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/11.jpg)
Runtime Efficiency
![Page 12: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/12.jpg)
Considerations
➣ Cost
➣ Language of choice
➣ Complexity of Design
➣ Scope
![Page 13: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/13.jpg)
Developing a DSL
![Page 14: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/14.jpg)
Domain Analysis
![Page 15: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/15.jpg)
Designing DSL
➣ Piggyback
➣ Language Extension
➣ Language Specialization
![Page 16: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/16.jpg)
Implementing DSL
![Page 17: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/17.jpg)
Internal vs External
![Page 18: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/18.jpg)
External DSL
➣ Interpreter
➣ Compiler/application generator
➣ Preprocessor
➣ Extensible compiler or preprocessor
![Page 19: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/19.jpg)
Internal DSL
➣ Method Chaining
➣ Expression Builder
➣ Closures
➣ Literal Collections
➣ Object Scoping
➣ Open Classes
![Page 20: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/20.jpg)
Real World Examples
![Page 21: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/21.jpg)
SELECT books .title, count(*) AS AuthorsFROM booksJOIN book_authors ON books .is bn = book_authors .is bnGROUP BY books .title;
![Page 22: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/22.jpg)
class Category < ActiveRecord::Base has_many :articles validates_presence_of :name validates_uniqueness_of :name def url_param self.name.downcase.gsub(/\s/,'_') endend
![Page 23: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/23.jpg)
employee John Doecompensate 500 dollars for each dealclosed in the past 30 days
compensate 100 dollars for each active dealthat closed more than 365 days ago
compensate 5 percent of gros s profits ifgross profits are greater than 1,000,000dollars
compensate 3 percent of gros s profits ifgross profits are greater than 2,000,000dollars
![Page 24: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/24.jpg)
Future(Everyone is a programmer)
![Page 25: Domain Specific Languages](https://reader034.vdocuments.mx/reader034/viewer/2022042715/5588ccafd8b42ae46d8b46a5/html5/thumbnails/25.jpg)
Questions?