Adomain-specific language (DSL) is acomputer language specialized to a particular applicationdomain. This is in contrast to ageneral-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging from widely used languages for common domains, such asHTML for web pages, down to languages used by only one or a few pieces of software, such asMUSH soft code. DSLs can be further subdivided by the kind of language, and include domain-specificmarkup languages, domain-specificmodeling languages (more generally,specification languages), and domain-specificprogramming languages. Special-purpose computer languages have always existed in the computer age, but the term "domain-specific language" has become more popular due to the rise ofdomain-specific modeling. Simpler DSLs, particularly ones used by a single application, are sometimes informally calledmini-languages.
The line between general-purpose languages and domain-specific languages is not always sharp, as a language may have specialized features for a particular domain but be applicable more broadly, or conversely may in principle be capable of broad application but in practice used primarily for a specific domain. For example,Perl was originally developed as a text-processing and glue language, for the same domain asAWK andshell scripts, but was mostly used as a general-purpose programming language later on. By contrast,PostScript is aTuring-complete language, and in principle can be used for any task, but in practice is narrowly used as apage description language.
The design and use of appropriate DSLs is a key part ofdomain engineering, by using a language suitable to the domain at hand – this may consist of using an existing DSL or GPL, or developing a new DSL.Language-oriented programming considers the creation of special-purpose languages for expressing problems as standard part of the problem-solving process. Creating a domain-specific language (with software to support it), rather than reusing an existing language, can be worthwhile if the language allows a particular type of problem or solution to be expressed more clearly than an existing language would allow and the type of problem in question reappears sufficiently often. Pragmatically, a DSL may be specialized to a particular problem domain, a particular problem representation technique, a particular solution technique, or other aspects of a domain.
This sectiondoes notcite anysources. Please helpimprove this section byadding citations to reliable sources. Unsourced material may be challenged andremoved.(January 2026) (Learn how and when to remove this message) |
A domain-specific language is created specifically to solve problems in a particular domain and is not intended to be able to solve problems outside of it (although that may be technically possible). In contrast, general-purpose languages are created to solve problems in many domains. The domain can also be a business area. Some examples of business areas include:
A domain-specific language is somewhere between a tiny programming language and ascripting language, and is often used in a way analogous to aprogramming library. The boundaries between these concepts are quite blurry, much like the boundary between scripting languages and general-purpose languages.
Domain-specific languages are languages (or often, declared syntaxes or grammars) with very specific goals in design and implementation. A domain-specific language can be one of a visual diagramming language, such as those created by theGeneric Eclipse Modeling System, programmatic abstractions, such as theEclipse Modeling Framework, or textual languages. For instance, the command line utilitygrep has aregular expression syntax which matches patterns in lines of text. Thesed utility defines a syntax for matching and replacing regular expressions. Often, these tiny languages can be used together inside ashell to perform more complex programming tasks.
The line between domain-specific languages andscripting languages is somewhat blurred, but domain-specific languages often lack low-level functions for filesystem access, interprocess control, and other functions that characterize full-featured programming languages, scripting or otherwise. Many domain-specific languages do not compile tobyte-code or executable code, but to various kinds of media objects: GraphViz exports toPostScript,GIF,JPEG, etc., whereCsound compiles to audio files, and a ray-tracing domain-specific language likePOV compiles to graphics files.
Adata definition language likeSQL presents an interesting case: it can be deemed a domain-specific language because it is specific to a specific domain (in SQL's case, accessing and managing relational databases), and is often called from another application, but SQL has more keywords and functions than many scripting languages, and is often thought of as a language in its own right, perhaps because of the prevalence of database manipulation in programming and the amount of mastery required to be an expert in the language.
Further blurring this line, many domain-specific languages have exposed APIs, and can be accessed from other programming languages without breaking the flow of execution or calling a separate process, and can thus operate as programming libraries.
Some domain-specific languages expand over time to include full-featured programming tools, which further complicates the question of whether a language is domain-specific or not. A good example is thefunctional languageXSLT, specifically designed for transforming one XML graph into another, which has been extended since its inception to allow (particularly in its 2.0 version) for various forms of filesystem interaction, string and date manipulation, and data typing.
Inmodel-driven engineering, many examples of domain-specific languages may be found likeOCL, a language for decorating models with assertions orQVT, a domain-specific transformation language. However, languages likeUML are typically general-purpose modeling languages.
To summarize, an analogy might be useful: a Very Little Language is like a knife, which can be used in thousands of different ways, from cutting food to cutting down trees.[clarification needed] A domain-specific language is like an electric drill: it is a powerful tool with a wide variety of uses, but a specific context, namely, putting holes in things. A General Purpose Language is a complete workbench, with a variety of tools intended for performing a variety of tasks. Domain-specific languages should be used by programmers who, looking at their current workbench, realize they need a better drill and find that a particular domain-specific language provides exactly that.[citation needed]
DSLs implemented via an independent interpreter or compiler are known asExternal Domain Specific Languages. Well known examples include TeX or AWK. A separate category known asEmbedded (or Internal) Domain Specific Languages are typically implemented within a host language as a library and tend to be limited to the syntax of the host language, though this depends on host language capabilities.[1]
There are several usage patterns for domain-specific languages:[2][3]
Many domain-specific languages can be used in more than one way.[citation needed] DSL code embedded in a host language may have special syntax support, such as regexes in sed, AWK, Perl or JavaScript, or may be passed as strings.
Adopting a domain-specific language approach to software engineering involves both risks and opportunities. The well-designed domain-specific language manages to find the proper balance between these.
Domain-specific languages have important design goals that contrast with those of general-purpose languages:
In programming,idioms are methods imposed by programmers to handle common development tasks, e.g.:
General purpose programming languages rarely support such idioms, but domain-specific languages can describe them, e.g.:
Examples of domain-specific programming languages includeHTML,Logo for pencil-like drawing,Verilog andVHDL hardware description languages,MATLAB andGNU Octave for matrix programming,Mathematica,Maple andMaxima forsymbolic mathematics,Specification and Description Language for reactive and distributed systems,spreadsheet formulas and macros,SQL forrelational database queries,YACC grammars for creatingparsers,regular expressions for specifyinglexers, theGeneric Eclipse Modeling System for creating diagramming languages,Csound for sound and music synthesis, and the input languages ofGraphViz andGrGen, software packages used forgraph layout andgraph rewriting,Hashicorp Configuration Language used forTerraform and otherHashicorp tools,Puppet also has its ownconfiguration language.
The GML scripting language used byGameMaker Studio is a domain-specific language targeted at novice programmers to easily be able to learn programming. While the language serves as a blend of multiple languages includingDelphi,C++, andBASIC. Most of functions in that language after compiling in fact calls runtime functions written in language specific for targeted platform, so their final implementation is not visible to user. The language primarily serves to make it easy for anyone to pick up the language and develop a game, and thanks to GM runtime which handles main game loop and keeps implementation of called functions, few lines of code is required for simplest game, instead of thousands.
ColdFusion's associated scripting language is another example of a domain-specific language for data-driven websites.This scripting language is used to weave together languages and services such as Java, .NET, C++, SMS, email, email servers, http, ftp, exchange, directory services, and file systems for use in websites.
TheColdFusion Markup Language (CFML) includes a set of tags that can be used in ColdFusion pages to interact with datasources, manipulate data, and display output. CFML tag syntax is similar to HTML element syntax.
FilterMeister is a programming environment, with a programming language that is based on C, for the specific purpose of creatingPhotoshop-compatible image processing filter plug-ins; FilterMeister runs as a Photoshop plug-in itself and it can load and execute scripts or compile and export them as independent plug-ins.Although the FilterMeister language reproduces a significant portion of the C language and function library, it contains only those features which can be used within the context of Photoshop plug-ins and adds a number of specific features only useful in this specific domain.
TheTemplate feature ofMediaWiki is an embedded domain-specific language whose fundamental purpose is to support the creation ofpage templates and thetransclusion (inclusion by reference) of MediaWiki pages into other MediaWiki pages.
There has been much interest in domain-specific languages to improve the productivity and quality ofsoftware engineering. Domain-specific language could possibly provide a robust set of tools for efficient software engineering. Such tools are beginning to make their way into the development of critical software systems.
The Software Cost Reduction Toolkit[6] is an example of this. The toolkit is a suite of utilities including a specification editor to create arequirements specification, a dependency graph browser to display variable dependencies, aconsistency checker to catch missing cases inwell-formed formulas in the specification, amodel checker and atheorem prover to check program properties against the specification, and an invariant generator that automatically constructs invariants based on the requirements.
A newer development islanguage-oriented programming, an integrated software engineeringmethodology based mainly on creating, optimizing, and using domain-specific languages.
Complementinglanguage-oriented programming, as well as all other forms of domain-specific languages, are the class of compiler writing tools calledmetacompilers. A metacompiler is not only useful for generatingparsers andcode generators for domain-specific languages, but ametacompiler itself compiles a domain-specificmetalanguage specifically designed for the domain ofmetaprogramming.
Besides parsing domain-specific languages, metacompilers are useful for generating a wide range of software engineering and analysis tools. The meta-compiler methodology is often found inprogram transformation systems.
Metacompilers that played a significant role in both computer science and the computer industry includeMeta-II,[7] and its descendantTreeMeta.[8]
Unreal andUnreal Tournament unveiled a language calledUnrealScript. This allowed for rapid development of modifications compared to the competitorQuake (using theId Tech 2 engine). The Id Tech engine used standardC code meaning C had to be learned and properly applied, while UnrealScript was optimized for ease of use and efficiency. Similarly, more recent games have introduced their own specific languages for development. One more common example isLua for scripting.[citation needed]
Variousbusiness rules engines have been developed for automating policy and business rules used in both government and private industry.ILOG,Oracle Policy Automation, DTRules,Drools and others provide support for DSLs aimed to support various problem domains. DTRules goes so far as to define an interface for the use of multiple DSLs within a rule set.
The purpose of business rules engines is to define a representation of business logic in as human-readable fashion as possible. This allows bothsubject-matter experts and developers to work with and understand the same representation of the business logic. Most rules engines provide both an approach to simplifying the control structures for business logic (for example, using declarative rules ordecision tables) coupled with alternatives to programming syntax in favor of DSLs.
Statistical modelers have developed domain-specific languages such asR (an implementation of theS language),Bugs,Jags, andStan. These languages provide a syntax for describing a Bayesian model and generate a method for solving it using simulation.
Generate object handling and services based on anInterface Description Language for a domain-specific language such as JavaScript for web applications, HTML for documentation, C++ for high-performance code, etc. This is done by cross-language frameworks such asApache Thrift orGoogle Protocol Buffers.
Gherkin is a language designed to define test cases to check the behavior of software, without specifying how that behavior is implemented. It is meant to be read and used by non-technical users using a natural language syntax and aline-oriented design. The tests defined with Gherkin must then be implemented in a general programming language. Then, the steps in a Gherkin program acts as a syntax for method invocation accessible to non-developers.
Other prominent examples of domain-specific languages include:
Some of the disadvantages:
This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(September 2009) (Learn how and when to remove this message) |
{{cite journal}}:Cite journal requires|journal= (help){{cite journal}}:Cite journal requires|journal= (help)