DSL in Scala

DSL (Domain Specific Languages) are, as the name implies, software development languages created for a specific niche or limited domain. Where could one use a DSL? For example, when writing a library to evaluate highly complicated financial products, it might be very beneficial to have a language designed to describe such products. The language will check correctness of a new product, will allow sharing of common pieces of definition, will be able to generate output that can be fed into other systems (risk calculation, trade processing, graphic representation). See this paper for a real world example of such a DSL.

Another example could be a language targeting automated trading. A simple set of instructions would allow a trader who is not an experienced software developer to design his/her own trading strategy. There would be statements to watch price movements of instruments and to execute orders when certain conditions are met. With a DSL strategies can be coded quickly by the traders who understand the business, back-tested to hammer out any errors and then applied in production.

Scala, a powerful and robust language, running on top of JVM, is a good choice as a development framework for a DSL. Writing your own can be made even easier if you use parboiled2 library, which is designed to facilitate writing language parsers. I am confident, that going forward more and more DSLs will be used in different areas.

Add new comment

Subscribe to Comments for "DSL in Scala"