16 November 2011

DSL (Domain-Specific Language )

I recently see DSL in many places.I learning Scala and I see they have DSL. I need to use  Apache Camel and their have their own  DSL's .
Question is .. What is that ?
Let's start from decrypting acronym. DSL stands for Domain Specific Languages
Still didn't explain too much ?Let's see some definition from folks,who knows what they talking about.


from Martin Fowler ( http://martinfowler.com/books/dsl.html )
Domain Specific Languages (DSLs) have been around since I've been in computing, but it's hard to find much information about how to work with them. DSLs are small languages, focused on a particular aspect of a software system.
DSLs come in two main forms: external and internal.
An external DSL is a language that's parsed independently of the host general purpose language: good examples include regular expressions and CSS.
Internal DSLs are a particular form of API in a host general purpose language,

from Book Programming in Scala (http://ofps.oreilly.com/titles/9780596155957/DomainSpecificLanguages.html)

Domain-Specific Language is a programming language that mimics the terms, idioms, and expressions used among experts in the targeted domain. Code written in a DSL reads like structured prose for the domain. Ideally, a domain expert with little experience in programming can read, understand, and validate this code.
from  c2.com ( http://c2.com/cgi/wiki?DomainSpecificLanguage )
A Domain Specific Language (DSL) is a programming language designed specifically to express solutions to problems in a specific domain.

from Wikipedia (https://en.wikipedia.org/wiki/Domain_specific_language)
A domain-specific language (DSL) is a type of programming language or specification language in software development and domain engineering dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique.

Dictionary.com has crap definition but it said something useful: "A domain-specific language is often used as input to an application generator."

And as summary this is my version of DSL definition:

DSL (Domain-Specific Language ) is a programming language (or specification) that is designed and dedicated to specific aspect of a software system. (by using specific idioms, expressions and terms).They are in contrast to Generic purpose languages (GPLs).
There is 2 types of DSLs.Internal and External.
Internal DSL - it sit on a host language,so DSL's syntax is based on and restricted by host language
External DSL - it is more independent in syntax BUT requires a parser to 'communicate' with host language.


While  DSLs  are designed to solve in a particular problem space, or domain.  generic purpose languages (GPLs) are designed to describe problems of any kind, 


Example of Domain specific language: LaTex, SQL( for databases), Unix shell scripts, HTML.
Example of General Purpose Language: Java, UML, C,

That's all.I hope it will make more sense now.

btw. Domain language  in polish is Jezyk dziedzinowy