Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Domain-specific language
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Domain-specific language topics== ===External and Embedded Domain Specific Languages=== DSLs implemented via an independent interpreter or compiler are known as ''External Domain Specific Languages''. Well known examples include TeX or AWK. A separate category known as ''Embedded (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.<ref>{{cite web |last1=Fowler |first1=Martin |last2=Parsons |first2=Rebecca |title=Domain Specific Languages |url=https://martinfowler.com/books/dsl.html |access-date=6 July 2019}}</ref> ===Usage patterns=== There are several usage patterns for domain-specific languages:<ref name='Mernik05'>{{cite journal|first1=Marjan |last1=Mernik|first2=Jan |last2=Heering|first3=Anthony M. |last3=Sloane|title=When and how to develop domain-specific languages|journal=ACM Computing Surveys|volume=37|number=4|pages=316β344|year=2005|doi=10.1145/1118890.1118892}}</ref><ref name='Spinellis01'>{{cite journal|first1=Diomidis|last1=Spinellis|url=http://www.spinellis.gr/pubs/jrnl/2000-JSS-DSLPatterns/html/dslpat.html|title=Notable design patterns for domain specific languages|journal=Journal of Systems and Software|volume=56|number=1|pages=91β99|date=February 2001|doi=10.1016/S0164-1212(00)00089-3}}</ref> * Processing with standalone tools, invoked via direct user operation, often on the command line or from a [[Makefile]] (e.g., grep for regular expression matching, sed, lex, yacc, the [[GraphViz]] toolset, etc.) * Domain-specific languages which are implemented using programming language macro systems, and which are converted or expanded into a host general purpose language at compile-time or realtime * As {{anchor|eDSL}}'''embedded domain-specific language''' ('''eDSL''')<ref>{{cite journal |last1=Felleisen |first1=Matthias |last2=Findler |first2=Robert Bruce |last3=Flatt |first3=Matthew |last4=Krishnamurthi |first4=Shriram |last5=Barzilay |first5=Eli |last6=McCarthy |first6=Jay |last7=Tobin-Hochstadt |first7=Sam |title=A Programmable Programming Language |journal=Communications of the ACM |date=March 2018 |volume=61 |issue=3 |pages=62β71 |doi=10.1145/3127323 |s2cid=3887010 |url=https://cacm.acm.org/magazines/2018/3/225475-a-programmable-programming-language/fulltext |access-date=15 May 2019|url-access=subscription }}</ref> also known as an '''internal domain-specific language''', is a DSL that is implemented as a library in a "host" programming language. The embedded domain-specific language leverages the syntax, semantics and runtime environment (sequencing, conditionals, iteration, functions, etc.) and adds domain-specific primitives that allow programmers to use the "host" programming language to create programs that generate code in the "target" programming language. Multiple eDSLs can easily be combined into a single program and the facilities of the host language can be used to extend an existing eDSL. Other possible advantages using an eDSL are improved [[type safety]] and better [[Integrated_development_environment|IDE]] tooling. eDSL examples: [[SQLAlchemy]] "Core" an SQL eDSL in [[Python (programming language)|Python]], [[Java Object Oriented Querying|jOOQ]] an SQL eDSL in [[Java (programming language)|Java]], [[LINQ]]'s "method syntax" an SQL eDSL in [[C Sharp (programming language)|C#]] and [https://github.com/Kotlin/kotlinx.html kotlinx.html] an [[HTML]] eDSL in [[Kotlin (programming language)|Kotlin]]. * Domain-specific languages which are called (at runtime) from programs written in general purpose languages like [[C (programming language)|C]] or [[Perl]], to perform a specific function, often returning the results of operation to the "host" programming language for further processing; generally, an interpreter or [[virtual machine]] for the domain-specific language is embedded into the host application (e.g. [[format string]]s, a [[Regular expression|regular expression engine]]) * Domain-specific languages which are embedded into user applications (e.g., macro languages within spreadsheets)<ref name="stinson19910416">{{Cite magazine |last=Stinson |first=Craig |date=1991-04-16 |title=Building the Perfect Spreadsheet |url=https://books.google.com/books?id=_OEk1QOJYw0C&pg=PT112 |access-date=2025-03-14 |magazine=PC |pages=101β164}}</ref> and which are (1) used to execute code that is written by users of the application, (2) dynamically generated by the application, or (3) both. Many domain-specific languages can be used in more than one way.{{Citation needed|date=September 2009}} 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. ===Design goals=== 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: * Domain-specific languages are less comprehensive. * Domain-specific languages are much more expressive in their domain. * Domain-specific languages should exhibit minimal [[Redundant code|redundancy]]. ===Idioms=== In programming, [[Programming idiom|idioms]] are methods imposed by programmers to handle common development tasks, e.g.: * Ensure data is saved before the window is closed. * Edit code whenever command-line parameters change because they affect program behavior. General purpose programming languages rarely support such idioms, but domain-specific languages can describe them, e.g.: * A script can automatically save data. * A domain-specific language can parameterize command line input.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)