Reflective Embedding of Domain-Specific Languages.
[Ph.D. Thesis], (2011)
Reflective Embedding of Domain-Specific Languages -
(Portable Document Format Datei)
Available under Only rights of use according to UrhG.
Download (2MB) | Preview
|Item Type:||Ph.D. Thesis|
|Title:||Reflective Embedding of Domain-Specific Languages|
In the recent years, there is an increasing interest for new programming languages that are special for certain problem domains – so-called domain-specific languages. A domain-specific language (DSL) provides a syntax and semantics for a particular class of problems. When writing code in a DSL, its concrete syntax enables higher end-user productivity because the syntax is closer to the problem domain than the syntax of a general-purpose language (GPL). However, implementing a new programming language is expensive, because language developers need to design and develop a new syntax and semantics. Because of these high initial costs, stakeholders desist from implementing a new DSL from scratch.
To lower the initial costs of developing a DSL, there is the idea to embed a language into an existing language. The existing language—often a general-purpose language—acts as a host language for the guest language that is embedded into the host as a library. Such an embedded language reuses the general-purpose features of the host language. Consequently, this reduces the development costs of the embedded language by reusing these features and by reusing the existing host language infrastructure, i.e., its development tools, parser, compiler, and/or virtual machine. Furthermore, new language features can be incrementally added to the embedded language by “simply” extending its library. Indeed, there is a comparative study that shows that embedding requires significant lower investments to implement a new language compared to traditional non-embedded approaches.
However, existing language embedding approaches have several important limitations w.r.t. the features that are usually supported by non-embedded approaches. First and foremost, most embedding approaches and host languages lack support for designing a concrete syntax for an embedded language. Second, current approaches do not allow embedding special language semantics that the embedded language needs but that conflict the host semantics. Third, there is no support for embedding multiple languages that have interactions in their syntax and semantics. The lack of support for these features in current embedding approaches mostly stem from their restrictions to adapt constructs in embedded languages and host languages.
To address these limitations, this thesis proposes the reflective embedding architecture that embeds languages into reflective host languages. A reflective language is a special programming language with support for reflection that enables programs to reason about their structure and behavior. Specifically, there is support for introspection that allows analyzing programs, and support for intercession that allows transforming programs. Using reflection helps overcoming current limitations of language embedding, since it enables evolution of embedded languages by analyzing and transforming their libraries.
The reflective embedding architecture itself defines a process how to embed a language’s syntax and semantics as a set of artifacts. Every language is an encapsulated component that has a set of well-defined interfaces. The classes of the embedding implement these interfaces to define the details of the execution semantics for that language component. In addition, the architecture enables embedding of language compositions, scoping strategies, domain-specific analyses and transformations. What is special in the architecture is that every language component implicitly has a meta level. When necessary, the language developers can use this meta level to evolve embeddings, which enables a number of benefits.
First, in contrast to other embedded approaches, the reflective embedding architecture enables support for concrete syntax for embedded languages without high initial syntax costs. For an embedded language, developers can annotate its library with meta data for rewriting DSL programs in concrete syntax into a corresponding executable form. By using a special technique for agile grammar specification, called island grammars, developers only need to specify those parts of the embedded language’s grammar that deviate from the grammar of the host language. Island grammars help significantly reducing the initial syntax costs, while supporting the full class of context-free grammars.
Second, the meta level enables support for composition of languages with interactions in their syntax and semantics. On the one hand, the architecture provides special language combiners that analyze and compose the syntax of all embedded languages in a composition. On the other hand, there are language combiners that transform embedded languages so that they can interact at well-defined points in their evaluation logic. By allowing interacting compositions, the architecture enables embedding special language abstractions that facilitate end user programmers to implement more modular programs.
Third, the meta level enables embedding languages that interact with their host languages. The meta level uses reflective features to interact with the evaluation of host language constructs in order to change the host’s semantics. Only when the host semantics can be changed, developers can embed sophisticated DSLs.
To review the reflective embedding architecture, this thesis conducts a qualitative and quantitative evaluation of the proposed concepts. First, to qualitatively evaluate the concepts of this thesis, the evaluation reviews the support of the reflective embedding architecture for supporting a set of desirable properties and compares its support to related work. Second, to quantitatively evaluate the concepts, the evaluation compares to embedded and non-embedded approaches using benchmarks. The results show that the architecture’s flexibility only comes with moderately increased runtime costs.
|Place of Publication:||Darmstadt|
|Uncontrolled Keywords:||Eingebettete Domänenspezifische Sprachen, Interne DSLs, Meta-Object Protokolle, Aspektorientierte Programmierung, Domänenspezifische Sprachen, Reflexive Programmierung, Meta-Level Architekturen, Sprachimplementierung|
|Classification DDC:||000 Allgemeines, Informatik, Informationswissenschaft > 004 Informatik|
|Divisions:||20 Fachbereich Informatik
20 Fachbereich Informatik > Softwaretechnik
|Date Deposited:||06 Dec 2011 09:56|
|Last Modified:||07 Dec 2012 12:02|
|Referees:||Mezini, Prof. Dr.- Mira and Hirschfeld, Prof. Dr.- Robert|
|Refereed:||10 December 2010|