User loginNavigation |
DSLs: Embedded, standalone, or both?I've a question for the group concerning domain-specific languages. One taxon by which DSLs can be categorized is whether or not they are standalone or embedded (my terms; don't know if there are better or more precise terms for the concepts in the literature). A standalone DSL is one which contains little or no trace of the language used to implement it (and indeed, implementations of the DSL may be written in any decent general-purpose language, with similar effort). When general-purpose computing constructs (flow control, recursion, arithmetic, error handling, type processing) is needed, it must be added as part of the DSL. HTML, to the extent that it is a programming language, would be one example. An embedded DSL is one which extends, in some fashion, an existing general-purpose language which I shall refer to as the host language (one which is typically the language of implementation)--code written in the host language, or a subset thereof, is also valid in the DSL. In such languages. Such language may be implemented via macros or similar "compile-time" metaprogramming means; by standalone programs which translate the DSL into the host language, or by interpreters which include the ability to evaluate statements in the host language (possibly relying on an eval() facility present in the host language itself). Generally, such DSLs are tightly coupled to their host, and writing code in the DSL will often require knowing the host language. Writing the DSL implementation in a different language than the host may be difficult; especially if the DSL is interpreted. (Writing a DSL compiler/translator is more easily done in a "third" language). Yacc is one example; while the part of the language for describing productions themselves isn't dependent on any other language, semantic actions pretty much have to be written in C/C++. If you want to write a LALR(1) parser in some other language, you're better off with a different tool. The universe is replete with experimental languages which compile into Java, and which typically allow Java to be embedded within. (Java generics started off this way, although adding decent polymorphism to Java is hardly domain-specific). The questions are: What are the design trade-offs between the two approaches? The embedded approach seems to be easier, especially in a language with decent metaprogramming. The standalone approach seems better for a language which is intended to be used by non-programmers, or which need to spread beyond a single project, organization, or language community--but when general-purpose programming facilities are needed, that wheel is often implemented poorly. (And in the degenerate case, the result is not really a DSL but yet another general-purpose language--quite a few general-purpose languages started off as DSLs but became generalized). By Scott Johnson at 2008-05-27 23:37 | LtU Forum | previous forum topic | next forum topic | other blogs | 9486 reads
|
Browse archives
Active forum topics |
Recent comments
25 weeks 5 days ago
25 weeks 5 days ago
25 weeks 5 days ago
48 weeks 4 hours ago
1 year 1 day ago
1 year 1 week ago
1 year 1 week ago
1 year 4 weeks ago
1 year 9 weeks ago
1 year 9 weeks ago