Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The webpage of Converge states that:

Converge has a macro-like facility that can embed domain specific languages with arbitrary syntaxes into source files.

I am most intrigued by the possibility to create domain specific languages. My understanding of the purpose of such languages, is that they enables the developer to become much more efficient when solving domain specific problems.

So, I went on to read the "about" section. There are two examples of usage here, but none of them describe how the developer could save development-time by utilizing Converge. Can anyone come up with an example or refer me to an example? I am happy to read examples in other languages than Converge.

share|improve this question
up vote 2 down vote accepted

I can't speak specifically of Converge, but I regularly use the D Programming Language which has very strong meta-programming features.

Here's an example of D library for units of measurement. The programmer can write:

auto dist1 = Meters(5.2);
auto velocity = dist1 / Seconds(2.1);
auto kmPerSecond = cast(Kilometers)velocity;

By using the type-system to create a DSL, the programmer is freed from juggling unit conversions and ensuring that operations make sense (e.g. time + distance would be an error).

Another (old) D example is the Blade library. This library is capable of parsing algebraic expressions at compile-time and generating very precise, fast assembly. For a programming who needs the speed, this sort of thing is a real life-saver.

Finally, check out Ruby on Rails if you haven't already. The whole thing is a giant DSL, though not a compile-time one.

share|improve this answer
Can you really cast velocity to Kilometers? – kevin cline Jan 17 '12 at 16:24
Whoops, nope. I meant to show off the automatic unit conversion. – user45121 Jan 18 '12 at 0:41

There are two canonical examples of domain specific languages:

  1. Regular expressions. They are simple language, but language nevertheless and they are compiled to the actual search automaton, so definitely benefit from compiler handling them. Other parsing languages like BNF are similar case.
  2. SQL. While this is normally compiled in the database server and so does not benefit from processing in the compiler this way, there is a huge benefit in support for it from the language if it can automatically bind variables for parameters and results.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.