domain specific languages

25
  Domain Specific Languages Design Patterns and Methodologies Lakshan Perera ([email protected]) Faculty of Information Technology University of Moratuwa

Upload: lakshan-perera

Post on 23-Jun-2015

1.694 views

Category:

Technology


0 download

DESCRIPTION

Design Patterns and methodologies for implementing DSL.

TRANSCRIPT

Page 1: Domain Specific Languages

  

Domain Specific LanguagesDesign Patterns and Methodologies

Lakshan Perera ([email protected])

Faculty of Information TechnologyUniversity of Moratuwa

Page 2: Domain Specific Languages

  

Page 3: Domain Specific Languages

  

“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

  

What is Domain Specific Language(DSL) ?

Page 5: Domain Specific Languages

  

“(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

  

4th Generation of Programming Languages

Page 7: Domain Specific Languages

  

Evolution

➣ APT (1957 – 1958)

➣ COBOL, FORTRAN and PERL

➣ Unix Mini-languages (yacc, lex, make)

➣ Lisp (Bottom-up design)

Page 8: Domain Specific Languages

  

Advantages of using DSL

Page 9: Domain Specific Languages

  

Direct Involvement of Domain Expert

Page 10: Domain Specific Languages

  

Improved Productivity

Page 11: Domain Specific Languages

  

Runtime Efficiency

Page 12: Domain Specific Languages

  

Considerations

➣ Cost

➣ Language of choice

➣ Complexity of Design

➣ Scope

Page 13: Domain Specific Languages

  

Developing a DSL

Page 14: Domain Specific Languages

  

Domain Analysis

Page 15: Domain Specific Languages

  

Designing DSL

➣ Piggyback

➣ Language Extension

➣ Language Specialization

Page 16: Domain Specific Languages

  

Implementing DSL

Page 17: Domain Specific Languages

  

Internal vs External

Page 18: Domain Specific Languages

  

External DSL

➣ Interpreter

➣ Compiler/application generator

➣ Preprocessor

➣ Extensible compiler or preprocessor

Page 19: Domain Specific Languages

  

Internal DSL

➣ Method Chaining

➣ Expression Builder

➣ Closures

➣ Literal Collections

➣ Object Scoping

➣ Open Classes

Page 20: Domain Specific Languages

  

Real World Examples

Page 21: Domain Specific Languages

  

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

  

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

  

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

  

Future(Everyone is a programmer)

Page 25: Domain Specific Languages

  

Questions?