4

Possible Duplicate:
What is a DSL and where should I use it?

I've heard the term used a lot... what exactly does it mean for a language to be "domain-specific"?

Also, what does it mean for a language (e.g. Groovy) to support domain-specific languages?

Community
  • 1
  • 1
user541686
  • 205,094
  • 128
  • 528
  • 886
  • https://secure.wikimedia.org/wikipedia/en/wiki/Domain-specific_language – Felix Kling Oct 20 '11 at 08:52
  • @FelixKling: I've actually already read that, but it wasn't very helpful. For example, how can an arbitrary language "support (arbitrary?) domain-specific languages"? Is it related to metaprogramming or something? I guess the definition of the term itself might make sense, but the usage is really confusing me... – user541686 Oct 20 '11 at 08:53

2 Answers2

0

For your first question a bit of googling will be sufficient.

As for the second question: you can implement DSLs in any language. You can even implement eDSLs in almost any language. But some languages are much better in that than the others. The key feature is metaprogramming - an ability to generate code in your host language, which means you can plug in a compiler of your eDSL anywhere. Features which facilitate compiler construction are also useful - e.g., out of box parsing tools, extensible or just flexible syntax of the host language, algebraic data types for representing ASTs, pattern matching for simplifying compiler transformations, etc. There is a continuum of possibilities, with entirely static and unextensible languages on one side and absolutely flexible languages at the other side.

SK-logic
  • 9,605
  • 1
  • 23
  • 35
0

A "domain specific language" is one in which a class of problems (or solutions to problems) can be expressed succinctly, usually because the vocabulary aligns with the that of the problem domain, and the notation is similar (where possible) to that used by experts that work in the domain.

What this really means is a grammar representing what you can say, and a set of semantics that defines what those said things mean. This makes DSLs just like other conventional programming langauges (e.g., Java) in terms of how they are implemented. And in fact, you can think of such conventional languages as being "DSL"s that are good at describing procedural solutions to problems (but not necessary good at describing them). The implications are that you need the same set of machinery to process DSLs as you do to process conventional languages, and that's essentially compiler machinery.

Groovy has some of this machinery (by design) which is why it can "support" DSLs.

See Domain Specific Languages for a discussion about DSLs in general, and a particular kind of metaprogramming machinery that is very helpful for implementing them.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341