도메인 특정 언어 (도메인 특정 언어, 영어 : domain-specific language , DSL)은 특정 작업을 위해 설계 된 컴퓨터 언어 를 의미한다. 도메인 특정 언어 또는 단순히 도메인 언어 라고도하지만 학술적으로는 도메인 특정 언어로 불리는 경우가 많다. C 언어 나 Java 와 같은 범용 프로그래밍 언어 와 UML 같은 범용 모델링 언어 와 대조되는 용어이다.
DSL은 한 가지 작업을 잘 수행하는 데 집중 한 것이다.
이용 패턴 [ 편집 ]
DSL을 사용하는 패턴은 다음과 같은 경우가있다 :
- 혼자 DSL을 사용하는 경우. 또한 (명령 줄이나 Makefile 에서) 사용자 조작의 직접적인 결과로 호출되는 경우.
- 프로그래밍 언어를 이용하여 구현 된 DSL은 컴파일 또는로드시 범용 프로그래밍 언어에 확장 / 변환된다.
- C 언어 나 Perl 등의 범용 프로그래밍 언어로 작성된 프로그램 (실행시) 호출, 특정 기능을 수행하고, 그 결과를 기본 프로그래밍 언어에 반환 처리를 계속라는 형태로 사용되는 DSL도 .
- 사용자 응용 프로그램에 DSL을 포함하는 경우 해당 응용 프로그램 사용자가 쓴 DSL 코드를 실행하거나 응용 프로그램 자체가 DSL 코드를 동적으로 생성하고 실행한다.
도메인 특정 언어의 정의 [ 편집 ]
DSL은 특정 영역 (도메인)의 문제를 해결하기 위해 만들어진, 그 이외의 영역의 문제를 푸는 것은 상정하고 있지 않다. 한편, 범용 프로그래밍 언어는 다양한 영역의 문제를 해결하도록 설계되어있다.
도메인은 비즈니스 영역에도 대응할 수있다. 예를 들어, 다음과 같은 DSL이있다.
- 대형 생명 보험 회사는 사내에서 사용하는 생명 보험 정책 DSL을 개발하고있다 [ 요청 출처 ] .
- 전투 시뮬레이션 DSL [ 요청 출처 ]
- 급여 DSL [ 요청 출처 ]
- 전표 DSL [ 요청 출처 ]
DSL은 언어로 (혹은 문법과 구문으로) 매우 제한된 목적으로 설계 / 구현된다. DSL은 시각화 된 언어 (도메인 특정 다이어그램이라고도 불린다)의 경우도 있고 ( GEMS 와 GME ) 프로그램 인 추상화의 경우도 있고 ( EMF ) 텍스트 인 언어의 경우도있다. 예를 들면, grep 이라는 명령 줄에서 사용되는 유틸리티는 텍스트의 패턴 매칭을위한 정규 표현식 이 가능하다. sed 유틸리티뿐만 아니라 정규 표현식을 사용하여 텍스트와 패턴 매칭시켜 문자열 바꾸기도한다. 이러한 간이 언어는 쉘 스크립트 에서 사용되어보다 복잡한 작업을 수행하는 일부를 구성한다.
DSL은 파일 시스템에 대한 액세스 기능과 프로세스 간 제어 등의 기능을 갖춘 프로그래밍 언어라면 당연히 가지고 있어야 기능이 부족한 경우가 많다. 많은 DSL은 바이트 코드 와 실행 코드라고 한 것에 컴파일되는 것이 아니라 다른 다양한 매체 용으로 변환되는 경우가 많다.
API 를 공개하고있다 DSL은 다른 프로그래밍 언어에서 호출 라이브러리 처럼 사용할 수있다.
기능을 갖춘 프로그래밍 도구가되기 확장되는 DSL도, 그래서 경계가 더 모호이다.
모델 기반 설계 는 OCL , ATL 등의 각종 DSL이 사용된다. 그러나 UML 은 DSL 대신 범용 모델링 언어 에 분류되는 것이 일반적이다.
요구 사양 [ 편집 ]
설계 목표 [ 편집 ]
DSL은 범용 프로그래밍 언어에 비해 다음과 같은 중요한 설계 목표이다 :
- DSL은 포괄적 일 필요는 없다.
- DSL은 그 영역 (도메인)을 더 표현하기 쉽게해야한다.
예 [ 편집 ]
- yacc
- 컴파일러 용 구문 분석
- SQL
- 데이터베이스 언어
- Csound
- 음성 파일 만들기
- GraphViz
- 유향 그래프 그리기
- 위키 마크 업
- 웹 페이지 만들기
소프트웨어 공학에의 응용 [ 편집 ]
도메인 특정 언어는 생산성과 품질을 향상시키는 것으로, 소프트웨어 공학 분야에서 주목 받고왔다. DSL이 효율적으로 소프트웨어 공학 도구의 토대가 될 가능성을 내포하고있다. 이러한 도구는 일부 시스템의 개발에 쓰이고있다.
SCR (Software Cost Reduction) 툴킷은 그 일례이다 [1] . 이 도구 키트는 요구 사양 을 작성하기위한 편집기 변수의 종속성을 표시하는 브라우저 사양의 조정 논리 식 으로 결함을 검사하는기구 사양과 응용 프로그램을 비교 검증하는 모델 검사 및 자동 정리 인증 기구, 사양에서 자동으로 불변 식 (invariants)을 구축하는 계획 등이 포함된다.
장점 [ 편집 ]
- DSL은 문제 영역에 적합한 추상 수준 관용구에서 솔루션을 표현한다. 따라서 그 지역의 전문가가 DSL로 작성된 프로그램을 이해하고 확인할 수, 수정할 수 있으며 또한 개발할 수있다.
- 코드 자체가 문서의 역할을한다.
- DSL은 품질 / 생산성 / 신뢰성 / 유지 보수 / 이식 / 재사용 성을 높인다.
- DSL은 그 영역의 수준에서 확인 가능하다. 언어 구성 요소가 안전하다 한 그것을 사용하여 작성된 프로그램은 안전 간주.
문제점 [ 편집 ]
- DSL 자체를 설계 / 구현 / 관리 비용
- 올바른 적용을 찾을
- 도메인 관련 부분과 범용 프로그래밍 언어의 구문과의 밸런스 조정의 어려움
- 하드 코드 된 소프트웨어에 비해 성능으로 불리한 가능성이있다
참고 문헌 [ 편집 ]
- Constance Heitmeyer. Using the SCR Toolset to Specify Software Requirements. Proceedings, Second IEEE Workshop on Industrial Strength Formal Specification Techniques , Boca Raton, FL, Oct 19, 1998.
- Diomidis Spinellis. Notable design patterns for domain specific languages . Journal of Systems and Software , 56 (1) : 91 - 99, February 2001.doi : 10.1016/S0164-1212 (00) 00089-3
- Marjan Mernik, Jan Heering, and Anthony M. Sloane. When and how to develop domain-specific languages. ACM Computing Surveys , 37 (4) :316-344, 2005. doi : 10.1145/1118890.1118892
관련 항목 [ 편집 ]
외부 링크 [ 편집 ]
A domain-specific language (DSL) is a type of programming language or specification language in software development and domain engineering dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique.
The concept isn't new. Special-purpose programming languages and all kinds of modeling/specification languages have always existed in the computer age. But the term has become more popular due to the rise ofdomain-specific modeling.
Examples of domain-specific languages include HTML, Logo for children, Verilog and VHDL hardware description languages, Mata for matrix programming, Mathematica and Maxima for symbolic mathematics,spreadsheet formulas and macros, SQL for relational database queries, YACC grammars for creating parsers,regular expressions for specifying lexers, the Generic Eclipse Modeling System for creating diagramming languages, Csound for sound and music synthesis, and the input languages of GraphViz and GrGen, software packages used for graph layout and graph rewriting.
The opposite is:
Creating a domain-specific language (with software to support it) 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. Language-Oriented Programming considers the creation of special-purpose languages for expressing problems a standard part of the problem solving process.
[edit]Overview
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 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:
- domain-specific language for life insurance policies developed internally in large insurance enterprise
- domain-specific language for combat simulation
- domain-specific language for salary calculation
- domain-specific language for billing
A domain-specific language is somewhere between a tiny programming language and a scripting language, and is often used in a way analogous to a programming library. The boundaries between these concepts are quite blurry, much like the boundary between scripting languages and general-purpose languages.
[edit]In design and implementation
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 the Generic Eclipse Modeling System, programmatic abstractions, such as the Eclipse Modeling Framework, or textual languages. For instance, the command line utility grep has a regular expression syntax which matches patterns in lines of text. The sed utility defines a syntax for matching and replacing regular expressions. Often, these tiny languages can be used together inside a shell to perform more complex programming tasks.
The line between domain-specific languages and scripting 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 to byte-code or executable code, but to various kinds of media objects: GraphViz exports to PostScript,GIF, JPEG, etc., where Csound compiles to audio files, and a ray-tracing domain-specific language like POV compiles to graphics files. A computer language like SQL 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.
[edit]Programming tools
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 the functional language XSLT, 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.
In model-driven engineering many examples of domain-specific languages may be found like OCL, a language for decorating models with assertions orQVT, a domain specific transformation language. However languages like UML 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. 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.
[edit]Domain-specific language topics
[edit]Usage patterns
There are several usage patterns for domain-specific languages:[1][2]
- processing with standalone tools, invoked via direct user operation, often on the command line or from a Makefile (e.g., the GraphViz tool set)
- 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 read-time
- embedded (or internal) domain-specific languages, implemented as libraries which exploit the syntax of their host general purpose language or a subset thereof, while adding domain-specific language elements (data types, routines, methods, macros etc.).
- domain-specific languages which are called (at runtime) from programs written in general purpose languages like 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 machinefor the domain-specific language is embedded into the host application
- domain-specific languages which are embedded into user applications (e.g., macro languages within spreadsheets) 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]
[edit]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 minimum redundancy according to the following subjective definition.
Redundancy of a program is defined as the average number of textual insertions, deletions, or replacements necessary to correctly implement a single stand-alone change in requirements. For a language, this is averaged over programs in the problem domain. This measure is useful because, the smaller it is, the less likely that bugs can be introduced by incompletely implementing changes.
In programming, idioms are methods imposed by programmers to handle common development tasks, e.g.:
- Ensure data is saved before the window is closed.
- Before conducting expensive tests, perform cheap tests that can rule out need for expensive tests.
- 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 smart test harness can learn what good tests are.
- A domain-specific language can parameterize command line input.
[edit]Examples
[edit]Unix shell scripts
Unix shell scripts give a good example of a domain-specific language for data organization. They can manipulate data in files or user input in many different ways. Domain abstractions and notations include streams (such as stdin and stdout) and operations on streams (such as redirection and pipe). These abstractions combine to make a robust language to talk about the flow and organization of data.
The language consists of a simple interface (a script) for running and controlling processes that perform small tasks. These tasks represent the idioms of organizing data into a desired format such as tables, graphs, charts, etc.
These tasks consist of simple control-flow and string manipulation mechanisms that cover a lot of common usages like searching and replacing string in files, or counting occurrences of strings (frequency counting).
Even though Unix scripting languages are Turing complete, they differ from general purpose languages.
In practice, scripting languages are used to weave together small Unix tools such as AWK (e.g., gawk), ls, sort or wc.
[edit]ColdFusion Markup Language
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.
The ColdFusion Markup Language includes a set of tags that can be used in ColdFusion pages to interact with data sources, manipulate data, and display output. CFML tag syntax is similar to HTML element syntax.
[edit]Erlang OTP
The Erlang Open Telecom Platform was originally designed for use inside Ericsson as a domain specific language. The language itself offers a platform of libraries to create finite state machines, generic servers and event managers that quickly allow an engineer to deploy applications, or support libraries, that have been shown in industry benchmarks to outperform other languages intended for a mixed set of domains, such as C and C++. The language is now officially open source and can be downloaded from their website.
[edit]FilterMeister
FilterMeister is a programming environment, with a programming language that is based on C, for the specific purpose of creating Photoshop-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.
[edit]MediaWiki templates
The Template feature of MediaWiki is an embedded domain-specific language whose fundamental purpose is to support the creation of page templatesand the transclusion (inclusion by reference) of MediaWiki pages into other MediaWiki pages.
A detailed description of that domain-specific language can be found at the corresponding article at the Wikimedia Foundation's Meta-Wiki.
[edit]Software engineering uses
There has been much interest in domain-specific languages to improve the productivity and quality of software 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 development of critical software systems.
The Software Cost Reduction Toolkit [2] is an example of this. The toolkit is a suite of utilities including a specification editor to create a requirements specification, a dependency graph browser to display variable dependencies, a consistency checker to catch missing cases in well-formed formulas in the specification, a model checker and a theorem prover to check program properties against the specification, and an invariant generator that automatically constructs invariants based on the requirements.
A newer development is Language-oriented programming, an integrated software engineering methodology based mainly on creating, optimizing, and using domain-specific languages.
[edit]Metacompilers
Complementing language-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 generating parsers and code generators for domain specific languages, but a metacompiler is also itself a domain-specific language for the domain of compiler writing. The feature that sets a metacompiler apart from a standard compiler-compiler is that a metacompiler is written in its own language and translates itself—the grammar productions defining itself written in its own specialized language—into the executable form of itself. Defining itself and translating itself constitute the meta-step that sets a metacompiler apart from other compiler-compilers.
Besides parsing domain-specific languages, metacompilers are useful for generating a wide range of software engineering and analysis tools. The meta-compiler methodology of self-regeneration for the purpose of bootstrapping generic tool building tools are often found in program transformation systems.
Metacompilers that played a significant role in both computer science and the computer industry include Meta-II[3] and its descendent TreeMeta.[4]
[edit]Unreal Engine and other games
Unreal and Unreal Tournament unveiled a language called UnrealScript. This allowed for rapid development of modifications compared to the competitorQuake (using the Id Tech engine). The Id Tech engine uses standard C[citation needed] code meaning C had to be learned and properly applied, while UnrealScript was optimized for ease of use and efficiency. Similarly, the development of more recent games introduced their own specific languages, one more common example is Lua for scripting.
[edit]Rules Engines for Policy Automation
Various Business 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 or Decision Tables) coupled with alternatives to programming syntax in favor of DSLs.
[edit]Statistical modelling languages
For statistical modelling, especially using Bayesian methods, there have been made domain-specific languages like Bugs and Jags. These languages provide a syntax for describing a Bayesian model, and generate a method for solving it using simulation.
[edit]Advantages and disadvantages
Some of the advantages:[1][2]
- Domain-specific languages allow solutions to be expressed in the idiom and at the level of abstraction of the problem domain. The idea is domain experts themselves may understand, validate, modify, and often even develop domain-specific language programs. However, this is seldom the case.[5]
- Self-documenting code.[citation needed]
- Domain-specific languages enhance quality, productivity, reliability, maintainability, portability and reusability.[citation needed]
- Domain-specific languages allow validation at the domain level. As long as the language constructs are safe any sentence written with them can be considered safe.[citation needed]
Some of the disadvantages:
- Cost of learning a new language vs. its limited applicability
- Cost of designing, implementing, and maintaining a domain-specific language as well as the tools required to develop with it (IDE)
- Finding, setting, and maintaining proper scope.
- Difficulty of balancing trade-offs between domain-specificity and general-purpose programming language constructs.
- Potential loss of processor efficiency compared with hand-coded software.
- Proliferation of similar non-standard domain specific languages, i.e. a DSL used within insurance company A versus a DSL used within insurance company B.[6]
- Non-technical domain experts can find it hard to write or modify DSL programs by themselves.[5]
- Increased difficulty of integrating the DSL with other components of the IT system (as compared to integrating with a general-purpose language).
- Low supply of experts in a particular DSL tends to raise labor costs.
- Harder to find code examples.
[edit]See also
[edit]References
- ^ a b Marjan Mernik, Jan Heering, and Anthony M. Sloane. When and how to develop domain-specific languages. ACM Computing Surveys, 37(4):316–344, 2005.[1] doi:10.1145/1118890.1118892
- ^ a b Diomidis Spinellis. Notable design patterns for domain specific languages. Journal of Systems and Software, 56(1):91–99, February 2001.doi:10.1016/S0164-1212(00)00089-3
- ^ Shorre, D.V., META II a syntax-oriented compiler writing language, Proceedings of the 1964 19th ACM National Conference, pp. 41.301-41.3011, 1964
- ^ C. Stephen Carr, David A. Luther, Sherian Erdmann, 'The TREE-META Compiler-Compiler System: A Meta Compiler System for the Univac 1108 and General Electric 645', University of Utah Technical Report RADC-TR-69-83.
- ^ a b Freudenthal, M. "Domain Specific Languages in a Customs Information System".
- ^ Miotto, Eric. "On the integration of domain-specific and scientific bodies of knowledge in Model Driven Engineering".
[edit]Further reading
- Dunlavey, "Building Better Applications: a Theory of Efficient Software Development" International Thomson Publishing ISBN 0-442-01740-5, 1994.
- Constance Heitmeyer. Using the SCR Toolset to Specify Software Requirements. Proceedings, Second IEEE Workshop on Industrial Strength Formal Specification Techniques, Boca Raton, FL, Oct. 19, 1998.
- Marjan Mernik, Jan Heering, and Anthony M. Sloane. When and how to develop domain-specific languages. ACM Computing Surveys, 37(4):316–344, 2005. [3] doi:10.1145/1118890.1118892
- Diomidis Spinellis. Notable design patterns for domain specific languages. Journal of Systems and Software, 56(1):91–99, February 2001.doi:10.1016/S0164-1212(00)00089-3
- Terence Parr. The Definitive ANTLR Reference: Building Domain-Specific Languages. ISBN 978-0-9787392-5-6
- James Larus. Spending Moore's Dividend. ISSN:0001-0782. Communications of the ACM. Volume 52, Issue 5 (May 2009).
- Werner Schuster (June 15, 2007). "What's a Ruby DSL and what isn't?". C4Media. Retrieved 2009-09-08.
- Martin Fowler. Domain Specific Languages. ISBN 978-0-321-71294-3
[edit]External links
- Articles
출처 - http://en.wikipedia.org/wiki/Domain-specific_language