Domain-Specific Languages are designed for a particular problem domain, as opposed to general purpose programming languages. DSLs aim to help domain experts work with the code more easily, ideally without needing the translation of a developer. DSLs can be used for different purposes, e.g. to describe programs, models or tests.

Internal DSLs are built based on a general purpose host language. Internal DSLs provide a domain specific feel for a general purpose language (e.g. using attributes and fluent interfaces with C#). External DSLs have their own domain specific syntax and parser (like Gherkin syntax and the SpecFlow Gherkin parser).

Here is a simple example for a Given-When-Then scenario expressed with C# using an internal DSL:

public class Calculator : Scenario
public void AddToCurrentTotal()

Here is the same scenario expressed using Gherkin:

Feature: Calculator
Scenario: “+” should add to current total
Given the current total is “5”
When I enter “7”
And I enter “+”
Then the current total should be “12”

Internal DSLs have the advantage of being fully integrated with the general purpose tool chain, such as refactoring and editor integration. However, their usability is limited by the constraints of the underlying general purpose language.

External DSLs can be better tailored to the domain’s purpose, but their tool chain is usually less extensive than general purpose language tools.