7 Languages built with Xtext

The Xtext project has published seven little languages (call them DSLs or not) using a new API for JVM-based DSLs. They are examples and meant to help people understanding how to use the new approach. The basic idea is to allow reusing predefined general language constructs such as expressions and type references and use them at arbitrary places in your custom DSL.

The seven languages solve common problems :

  • a simple scripting language
  • a build language (similar to ANT or Gradle)
  • a language to describe MongoDB documents
  • something to wire up Guice modules
  • a language for HTTP routing (similar to the one from play!)
  • a template language for HTML docs
  • a sweet little Logo-clone

The basic ideas and implementation steps for these languages are explained including code snippets and examples. Real world usages of this API are Xtend and Jnario.

IMHO, one of the main advantages of embedded/internal DSLs over external ones has always been the possibility to call out to the host language. You need things like expressions in most DSLs at some point. Therefore in external DSLs people often start to design half-baked expressions or even worst built the most common use cases into the language just to get stuck again half-an-hour later and add the next half-baked ‘feature’. Other folks hook in or modify generated code and extend it with the needed behavior.

I think these are main problems with external DSLs and that they are completely eliminated with the approach taken in Xtext for JVM languages. At the same time the good parts of external DSLs such as the syntactical freedom, special domain-specific validation and tool integration are still there of course.

We are very happy with the abstractions and are looking forward to feedback from language design experts.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

nit

Creating "a build language" does not solve a problem. It could very well be you just created more problems than you solved. Rather than focus on domains as catch phrases, what does Xtext truly allow you to do better, semantically?

For example, you are not only syntactic freedom, but also for "special domain-specific validation". What non-trivial validation can your build language perform that requires thinking hard about what a good build language should do for its users automatically through a build spec? And so on for your other languages.