There are two types of DSL; external and built-in.
The external DSL is completely separate from your host language, that is, you write it outside the language, but is usually used to generate code in the host language. For this approach, XText with XPand is probably the best tool since a simple grammar file generates a full Eclipse editor for the new DSL, and you can use XPand's code templates to generate the actual Java code. XTend and XPand are written in Java, but this is accidental, as they can be written in everything while you finish the Java code at the end of the process. The disadvantage of this approach is that for any fairly complex problem, the language will become quite complex, and it will take a lot of work in grammar and even more in templates for generating code. You cannot use any features of the host language, such as evaluating expressions, so all this requires recovery in DSL if you need it. XText will soon include XBase, which is a partial language that will contain expressions that will help here.
Another approach is the built-in DSL, where higher-level domain functions are expressed in the host language or with higher-order constructs (e.g. HOF and monads), which are usually found in functional languages ββor through metaprogramming objects such as macros (e.g. Lisp). Java none of them is a bad choice for DSL (or most other forms of abstract programming) to work. Spring Roo offers a metaprogram type tool for Java using generation, so it may be an option. Otherwise, Scala is probably the most popular in Java, as the JVM language, and has the features you need.
Embedded DSLs are usually much simpler than external DSLs because you have full host language support, so I recommend trying Scala.
Andrew
source share