Domain Specific Languages

1,932
-1

Published on

Design Patterns and methodologies for implementing DSL.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,932
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
75
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Domain Specific Languages

  1. 1. Domain Specific Languages Design Patterns and Methodologies Lakshan Perera (lakshan@web2media.net) Faculty of Information Technology University of Moratuwa    
  2. 2.    
  3. 3. “Our understanding of the nature of language and the mental processes and structures that underlies its use and acquisition” Noam Chomsky Cartesian Linguistics    
  4. 4. What is Domain Specific Language(DSL) ?    
  5. 5. “(DSL) is a computer language that's targeted to a particular kind of problem, rather than a general purpose language that's aimed at any kind of software problem.” Martin Fowler    
  6. 6. th 4 Generation of Programming Languages    
  7. 7. Evolution ➣ APT (1957 – 1958) ➣ COBOL, FORTRAN and PERL ➣ Unix Mini-languages (yacc, lex, make) ➣ Lisp (Bottom-up design)    
  8. 8. Advantages of using DSL    
  9. 9. Direct Involvement of Domain Expert    
  10. 10. Improved Productivity    
  11. 11. Runtime Efficiency    
  12. 12. Considerations ➣ Cost ➣ Language of choice ➣ Complexity of Design ➣ Scope    
  13. 13. Developing a DSL    
  14. 14. Domain Analysis    
  15. 15. Designing DSL ➣ Piggyback ➣ Language Extension ➣ Language Specialization    
  16. 16. Implementing DSL    
  17. 17. Internal vs External    
  18. 18. External DSL ➣ Interpreter ➣ Compiler/application generator ➣ Preprocessor ➣ Extensible compiler or preprocessor    
  19. 19. Internal DSL ➣ Method Chaining ➣ Expression Builder ➣ Closures ➣ Literal Collections ➣ Object Scoping ➣ Open Classes    
  20. 20. Real World Examples    
  21. 21. SELECT books .title, count(*) AS Authors FROM books JOIN book_authors ON books .is bn = book_authors .is bn GROUP BY books .title;    
  22. 22. class Category < ActiveRecord::Base has_many :articles validates_presence_of :name validates_uniqueness_of :name def url_param self.name.downcase.gsub(/s/,'_') end end    
  23. 23. employee John Doe compensate 500 dollars for each deal closed in the past 30 days compensate 100 dollars for each active deal that closed more than 365 days ago compensate 5 percent of gros s profits if gross profits are greater than 1,000,000 dollars compensate 3 percent of gros s profits if gross profits are greater than 2,000,000 dollars    
  24. 24. Future (Everyone is a programmer)    
  25. 25. Questions?    
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×