After reading DSLs in BOO I wanted to learn more about Domain Specific languages and DSLs in Action looked like a good fit – I wasn’t disappointed…
DSLs comes in many forms and flavors, most books divide them to to distinct groups – internal DSLs and External DSLs.
- Internal DSL is a language inside language, using the infrastructure of an existing language to create your syntax.
- External DSLs – think back to your compiler course. This refers to creating a new language from the ground up.
This book does an excellent job of showing how DSLs (internal and external) can be created at used in a real world scenario. The book isn’t about a single language either – right after a short introduction (chapters 1 – 3) the book dives into internal DSL creation using Ruby, Groovy, Clojure (chapters 4-6) and Scala (chapter 7) following by a chapter on external DSL creation using ANTLR.
The internal DSL part of the book is all about meta programming on top of the JVM along with ways to integrate the new language with main program written in Java. That’s right most of the book is about Java related languages and technologies. The knowledge can still be applied to other framework (.NET anyone?) but I feel that some hint regarding the Java orientation of this book was in order. My second (and last) beef with this book is its choice of domain: I understand the need to choose an actual real world example that the reader can relate to and understand and in this case trading system as the domain of choice – the whole buying and selling of stocks and what-not is explained in great details in order to help the reader understand the challenges of creating such a system – I found it a bit too much for my taste.
But these are very small issues compared to what I did manage to learn from this book. I was truly amazed that the author didn’t take the easy way out and dedicated a whole chapter to external DSL along with good solid examples and tools that can be used.
Because it’s easy to get lost in all of the information each chapter has a “roadmap” at its beginning that helps understanding what is the chapter is all about:
So if you’re interested in domain specific languages and meta programming you want to give this book a try – it’s well worth your time and effort.