Home > Articles > Programming

An Interview with Martin Fowler and Rebecca Parsons on Domain-Specific Languages

Neal Ford interviews Martin Fowler and Rebecca Parsons about domain-specific languages, why general purpose languages aren't enough, the benefit of writing your own language, and the difference between polyglot programming and DSLs.

Also see a sample chapter from the book, An Introductory Example.

Like this article? We recommend

Like this article? We recommend

Domain-Specific LanguagesMartin Fowler is the author of and Rebecca Parsons is a contributor to Domain-Specific Languages.

BuyBuy the Book

Neal: I happen to know that you've been working on this book for a long time. Why so long from concept to publication?

Martin: I often wonder about that myself. Partly it may be due to the topic. There’s a lot to cover so we can provide enough breadth to show people the range of alternatives and depth to get people started. There was also a long period where I was just looking at existing DSLs and trying out ideas. My speaking and traveling schedule has been busy too, and I may not have as much energy as I did when I was younger. The sad news is that it seems to be getting harder rather than easier to write books.

Rebecca: Making things "simple" takes a lot longer than simply understanding them, and the purpose was to take this mass of programming language processing tools from something only compiler writers could understand to something that regular programmers concerned with things other than language implementations could understand.

Martin: The enjoyable part of writing this book was looking at lots of examples out there and figuring out how to put that material into a cohesive structure. None of the techniques in the book are new, but it still takes time to organize them in a way to make it easier to understand them.

Neal: Is it really useful to have developers write their own languages? Why isn't one of the multitude of general purpose languages enough?

Rebecca: One of the major problems in software development is the ineffective communication of requirements from users to developers. While I believe that true ubiquitous end user programming is a long way off, I do think we can improve the level of readability of at least parts of programs. Sufficient increases in the readability of aspects of programs make communication with the end user about what the program does much more effective. General purpose programming languages are designed for developers, not for marketing people, or biologists, or investment bankers. The problem domains that programs address all have their own terminology. We can improve communication by narrowing the gap between the language of the problem and the language of the solution.

Neal: Isn't this another one of those academic subjects like semantic web and artificial intelligence that comes up now and again but never really finds a good practical use?

Martin: One of the things that makes it hard to gauge how useful DSLs are is that fact that until now there’s been no decent source that people can use to understand the techniques you need to build them. It reminds me very much of the position of Refactoring before I wrote that book—some people knew what to do, but there wasn’t anywhere you could point to as a coherent source of information. My hope is that this book will provide this source for DSLs, people will find it easier to go off and try the techniques, and we’ll learn better how useful they really are.

Rebecca: It is true that we've heard—literally for decades—about domain specific languages. I believe two issues have precipitated much of the failure: the goal of user writable and the notion that the whole program needed to be written in the DSL. Business people know the business domain. Developers know software development. Trying to turn all business people into developers is not going to happen anytime soon; there is, after all, a reason most people study for at least a few years before really beginning to be productive as a developers. Right now, we simply don't yet have the tools and techniques to make software development "simple" enough for people to just "pick up" like they do a word processor, in addition to having to know their problem domain.

Martin: Indeed I don’t think that non programmers will ever be able to just pick up general purpose programming. I think to program well requires a different mind-set and practised skills. The trick is to find ways that non-programmers can most effectively collaborate with programmers.

Rebecca: The second issue led to language creep. Many languages started nice and compact and focused on the domain. Then, since the whole (or at least most of the) program needed to be written in this language, we needed conditionals, and then we needed iteration, and then we needed abstraction and soon you had a general purpose, turing complete programming language with a few domain concepts embedded in it. We then have programs that are just slightly less incomprehensible to people who know the problem domain.

Martin: This is the key point of what makes DSLs special—the fact that they are of limited expressiveness. So, to use them you combine several DSLs with a General-Purpose Language.

Neal: Do you have to understand things like language grammars and parsing to understand this subject?

Rebecca: Being a programming languages person, my answer might be a bit biased. However, I feel you need to understand language grammars, perhaps not in their full theoretical glory. A language grammar helps communicate what is legal in the language. It also provides the structure to allow the interpretation of the meaning of a fragment in the language. Whether you specify the grammar in full BNF or it is simply implied, the grammar has to exist. Grammar specification for programming languages provides a straightforward way to discuss what is a legal program. Understanding of parsing—at least understand how parsing happens or why parsing works—is not necessary. The book provides examples of some simple parser implementation techniques that end up being quite useful for DSLs, which often are relatively simple from a formal languages perspective. Using internal DSLs also takes away the need to understand parsing, although you'll still need to understand how the implementation language works well enough to get your internal DSL implementation to work as you intend.

Neal: Won't encouraging developers to write their own languages lead to cacophony?

Martin: This is a very common objection, but to think about this point clearly you have to remember the relationship between DSLs and frameworks. In general DSLs are nothing more than a thin facade over an underlying framework or library. Whenever developers find repetition in their code, they should abstract it into some common code. They then manipulate that abstraction using a normal API, which we term a command-query API in the book. Using a DSL is a decision that a command-query API isn’t the best way of working with that abstraction, so you layer a DSL on top to make it easier to use. With or without a DSL, you still have to understand the underlying abstraction.

Rebecca: Clearly any tool can be misused. However, used properly, you'll have a close correspondence between the issues being faced by the system—both business and technical—and the DSLs that get created. Since the cognitive distance between concepts in the domain and constructs in the DSL should be smaller than when using a general purpose language, overall understanding of the working of the system should improve. No more concepts are introduced using DSL than already exist in the systems. The DSL simply provides a more readable description of the system behavior.

Neal: Is this subject really only applicable to people who use Ruby, Scala, and Groovy?

Rebecca: Not at all. Internal DSLs are easier to do in languages like Ruby and Groovy, but DSLs can co-exist quite happily with other languages. In those cases, you'll be more likely to be using an External DSL.

Martin: That’s partly why most of the examples in the book are in Java and C#. The point is that the techniques are general ones that can be used with any language. A common theme in my writing is to find general techniques that you can learn once and apply to many languages—and this topic is no exception.

Neal: What would you view as the best outcome from having published your book in terms of industry impact or behavior changes?

Rebecca: Many people who only learned about parsing in a compiler course think language processing is hard. The tools are much simpler than they are often presented, as long as the language being processed is simple enough. Implementing a full general purpose programming language is far harder than implementing something like the state machine in the book, and yet state machines are quite powerful tools. My goal is for people to no longer view these tools as something only those strange language freak types like me can use.

Martin: I want people to know the full range of techniques that you can use with a DSL, so they can make better choices should they consider going down this path. I think this will lead to more DSLs being used, and an improvement in how DSLs are implemented. The interesting question is how broad an impact this will have. At this point I think lack of knowledge of these techniques obscures the broader questions of their impact, so by removing this I hope we can see better what can be done with them.

Neal: Can you reconcile the concept of polyglot programming (using several general purpose languages within the same project but hosted on the same virtual machine) with DSLs? Are these concepts orthogonal or complementary?

Martin: They are different concepts in that DSLs are not general-purpose languages.

Rebecca: Mostly orthogonal I would say, but there is a relationship. Polyglot programming's premise is that one selects the right language for each of the parts of the system and then weaves these parts together using the underlying virtual machine. Using a DSL is about designing the right language for communicating a particular concept and then allowing that implementation to work together with the rest of the system written in one or more general purpose or domain specific languages. The similarity is in choosing the right language for each part of the system, rather than choosing a language that is acceptable for the whole system.

Martin: So they are different concepts, but built on the same premise. There is no One Best Language. Languages are tools so we need to use the right tool for the job. This principle leads to multiple general-purpose languages (polyglot programming) and to using DSLs.

Neal: Are average developers good enough to write DSLs?

Martin: Like so many questions you can replace ‘DSL’ with ‘library’. Are average developers good enough to write libraries?

Rebecca: I think there are two issues to separate here—language design and language implementation. I think an average developer can implement a DSL as described in the book with no more difficulty than the rest of the problem. I think the choice of implementation will vary based on the level of expertise available to understand the implementation. For example, some Ruby internal DSL implementations can be difficult to understand. Using an External DSL in that case might aid in understanding.

Martin: I think the hardest part is coming up with the abstraction, which usually manifests itself in the form of a library. That’s a fundamental part of programming. Any programmer has to learn how to do this, and only half of programmers do it better than average.

Rebecca: Designing a good DSL is a different issue. We don't really address the issue of good language design in the book—we couldn't cover everything. However, I think there's still a lot of research and study needed to come up with guidance for how to design a good DSL. I suspect the guidelines might also vary depending on the target user.

Martin: If the book is successful we’ll see many more cruddy DSLs—Sturgeon's Law always applies—but we’ll also see some more good DSLs. The good DSLs will provide the value that will make it all worthwhile.

Neal: What would you have a developer tell a manager to convince them to allow some of these techniques?

Rebecca: Two major benefits come to mind that apply in different situations. The first involves decreasing overall implementation time (when one includes user testing) by increasing the effectiveness of the communication of requirements. If the problem has been properly communicated, the probability that the system does "the right thing" increases significantly, and the problem of having to rewrite software simply because the requirement was misunderstood decreases dramatically.

Martin: This is the brass ring of DSLs—the ability to open up a deep collaboration between programmers and domain experts. Often this is expressed as saying domain experts will write programs in DSLs. My sense is that won’t be the case most of the time and that the more realistic point is where domain experts can read the DSLs. Readability is enough to unlock the key communication benefits.

Rebecca: The second benefit involves longer term maintenance. A system that is easier to understand is easier to maintain and evolve. Complex business logic buried in code is hard to understand. Putting that complex business logic in a language suited to it makes the job of understanding what the system really does simpler.

Martin: Consider regular expressions—they may be cryptic and often hard to follow, but they are much easier to understand than what the alternative code would look like.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020