One of the most powerful new features of
Xtext is the capability to
build languages for the JVM. In my opinion, these languages are a real breakthrough in domain-specific language design:
- These DSLs directly interoperate with Java. They compile to Java code and allow to refer to Java artifacts.
- They not only cover structural aspects but also behavior. DSLs become really powerful with a rich expression language offering today what Java has been missing for years, like type inference, lambda expressions, extension methods etc.
- Complicated integration patterns like Generation Gap or Protected Regions become obsolete. Everything can be expressed on the same level of abstraction
- They offer top-notch Eclipse-based tooling and integrate into the Java IDE. Switch between the DSL and the Java code during debugging, refactor across multiple languages, navigate to source etc.
Yet we have the impression that the concept and the benefits of JVM DSLs have not been well understood and adopted. This is why we decided it was time for another example and documentation offensive. The result is the
7 Languages project: Seven example JVM languages highlighting the benefits of this approach in various use cases of Java development:
- A scripting language. Write code without any boilerplate.
- A build language similar to Gradle but statically typed.
- JavaBeans facades for mongoDB objects.
- A DSL to define Guice modules.
- A language to route HTTP requests with conditions, variables and dependency injection.
- A template language
- A LOGO-like turtle drawing environment.
Clone or fork the code from
github and enjoy the
documentation on theXtext website.