In my observation, sometimes implementing a library (or package, etc.) can also achieve the similar expressiveness as inventing a domain specific language. An example is comparing Numpy in Python with MATLAB (or Mathematica, Maple, etc.). Both of them could do matrix operations efficiently. But one is a package, the other is a DSL. Numpy appears as a package in Python, which makes it convenient to switch data between Numpy (and underlying core code implemented in C) and Python environment. Users could still use their knowledge and code of Python without sacrificing generality. MATLAB, however, needs users to learning another set of grammar (including things like "for loops") but may provide better expressiveness in the field of scientific computation. The tradeoff here is interesting to notice.
If creating a domain specific language is unavoidable, and you are developing the infrastructure of this language on JVM, you may want to consider using Scala. Scala supports DSLs, and you may not have to spend a lot of time in implementing a parser for you DSL with tools like Lex and Yacc.
I am not an expert of this. Please tell me if I am wrong.
Can Awk be considered a DSL for text processing?
@kapalani. Yes, I'd agree. It would meet the definition of a "little language".
"Little Languages" by John Bently.
@pagerank. We should be careful to not split hairs on what is a language and what is a library. In a formal sense, a language has a particular semantics for operations on state (variables in an environment). Those semantics could be implemented by means of a compiled (or interpreted) "programming language" or by an appropriate library in an existing language.
Keep in mind that although I definitely describe Halide as a domain-specific language in this lecture, its actual implementation is as a C++ library. (All the Halide code I have on the coming slides is valid C++ that makes heavy use of operator overloading.)
Using these API calls, an abstract syntax tree (AST) for the program is constructed, and then the Halide compiler (part of the API) compiles this representation into a sequence of instructions.
See more about Halide here: http://halide-lang.org/
Is MATLAB also an example of a DSL?