Channels ▼

Mike Riley

Dr. Dobb's Bloggers

Domain-Specific Languages Book Review

November 08, 2010

Martin Fowler is the Chief Scientist at technology consulting firm Thoughtworks, and author of some of the most information-rich books in the field of computing today. He is also an author who takes his time when writing about subjects that deeply interest him. How does his latest book compare to his previous titles? Read on to find out.Using mostly Java and C# (with an occasional Ruby snippet), Martin demonstrates DSL principles with clarity and precision. He relays his findings not from an ivory tower but from one computer language enthusiast to another. In the opening chapter, Fowler even uses the example of a Gothic castle's secret compartment security system instead of the typical 'modern day' state machine event trigger because "When I start to write, I need to swiftly explain what it is I'm writing about."

The book moves from Gothic castle security systems to DSL life-cycles and their roles in the enterprise in chapter 2, followed by implementing DSL's in chapter 3 that includes considerations for DSL architecture, parsers, macros, grammars, syntax and semantics. Chapters 4, 5 and 6 cover implementing internal and external DSL's and deciding on which to use depending on such characteristics as domain expertise, cost and learning curve. Chapter 7, 8 and 9 conclude the first part of the book by examining alternative computational models, code generation and language workbenches (schema definition languages, meta-models, source and projectional editing and the various tools that can be used such as MetaCase, Xtext and JetBrain's MPS).

Part 2 of the book applies some of the theory discussed in Part 1 to more specific working examples, starting off with a look at existing DSL's such as CSS, Graphviz, JMock, XAML and others. The chapters that follow explore the semantic model, symbol table, context variable, construction builder, macro and notification. Part 3 takes a look at external DSL topics, ranging from syntax-directed translation, Backus-Naur Form (BNF), tree construction, embedded translation and interpretation, foreign code, alternate tokenization, nested operator expression and newline separators. Several chapters in this section of the book on DSL parsers were written by co-author Rebecca Parsons. Part 4 covers various internal DSL (Ruby on Rails is an internal DSL, for example) topics including method chaining, object scoping, literal lists and maps, dynamic reception, textural polishing and literal extension. Part 5 on alternative computation models spans decision tables, dependency networks and state machines. The final part covers various aspects of code generation, including transformer, templates, model-aware and model ignorant generation.

Thanks to the success of Ruby and Ruby on Rails, interest in DSL's is especially high and growing - DSL-based testing tools like RSpec and Cucumber come to mine. DSL's authored in Java and .NET are also on the rise for the reasons that Martin suggests in his book.

After reading Domain-Specific Languages, the task of creating my own DSL isn't as scary or arduous as I feared. The book also gave me a much deeper appreciation for the DSL's I call upon for my own projects and inspires me to look for opportunities in today's computing landscape where DSL's could hasten resolution to a specific problem. Anyone who is working with a DSL and would like to learn more about what is happening under the covers or is even considering creating their own DSL or extending an existing one, Domain-Specific Languages offers an excellent foundation to pursue such an education.

Fowler's UML Distilled, Refactoring and Continuous Integration are books that helped define those potent computing aspects, and Domain-Specific Languages will likely do the same for the DSL category.

Title: Domain-Specific Languages Author: Martin Fowler with Rebecca Parsons Publisher: Addison-Wesley ISBN: 978-0321712943 Pages: 640 Price: $54.99

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.