What is Domain Specific Language or DSL?
In his book, Martin Fowler defines the DSLs as follows.
“A computer programming language of limited
expressiveness focused on a particular domain.” (Fowler, 2010)
“The basic idea of a domain
specific language (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.” (Fowler, 2010)
Summing up the above two quotes, a DSL can be define as follows
“A computer programming language of limited expressiveness that are
specialized and focused to specify a particular aspect of a software system at
a much higher level of abstraction than the general purpose programming
language. It is capable of capturing the abstractions related to that
particular aspect of the software system under development.”
In the literature, this particular aspect of the software system is also referred
by the terms “viewpoint” or the “domain”. So in this context of DSLs, the
viewpoint or the domain can be defined as follows
Domain or Viewpoint is the related set of concerns
that represent the particular aspect of a whole software system under
development that is important from the software development perspective. We can
define the two types of domain or viewpoint for a software system, the
horizontal and vertical domain (Maier, et al., 200X) (MDA Guide)
Horizontal Domain describes the technical aspects
related to the software system like the architectural view, persistency view,
user interface view, user interface look and feel view and user interface
interaction view. (?)
Vertical Domain describes the functional aspects
related to the software system like the insurance policy domain, banking
domain, air traffic control domain, air flight reservation domain, medical
domain, mobile software domain are the examples of few. (?)
DSLs do not live in isolation but they are
integrated. As a DSL fulfils only a narrow purpose and specify a particular aspect
of a software system. But the real world software has multiple aspects
associated with it and all such aspects are overlapping and tightly integrated
to each other. So a DSL in isolation is worthless. In order to specify all
aspects of the software system we must have multiple integrated set of DSLs.
(Fowler, 2010)
DSLs are not needed to be turing-complete
languages like the GPLs. As the scope of these languages is much narrowed to
specialized domain of a software system, therefore their capabilities are also
limited as compared to the GPLs like Java and C#. A DSL is not needed to be a
turing complete language like the GPLs having all kind of controls structures
like conditional structures, looping structures. Also these languages are not
necessarily to have the capability to create new abstraction styles. The
narrowed capabilities are enough to fully specify the particular aspect of the software
system. As these languages are more tilted toward the specialized domain,
therefore they are expected to have more user-friendly syntax as compared to
the GPLs. Due to this feature the programs or models specified in such
languages are more expressive, more focused, more fluent and more readable as
compared to the GPLs programs or models. (Fowler, 2010)
Examples of the DSLs include CSS, XML
configuration files , regular expressions, make, rake, ant, SQL, HQL, many bits
of Rails, expectations in JMock, graphviz's dot language, FIT, strut's
configuration file. (Fowler, 2010)