Thilo Ernst
Posts: 3
Nickname: te0006
Registered: Apr, 2003
|
|
Re: Programming Close to the Domain
|
Posted: Apr 8, 2003 8:43 AM
|
|
Yes. Both scripting languages like Ruby or Python and system programming languages like Java or C++ have plenty of features that can be used just fine to cook up domain-specific mini-languages without any need to build a translator - the standard compiler or interpreter can readily be used. I think this idea deserves to be much more widely known and teached.
These days there is much praise for XML-based configuration mechanisms. Standard XML tools and libraries make parsing simple, but IMHO re-using an established programming language's syntax and implementation instead is often the superior approach: First (at least with languages like Python or Ruby having concise syntax with little "clutter", and with creative use of the base language's features), the notation can be made more human-readable/writable. Second, the reuse effect extends far beyound the parser stage - somebody wants if/then/else in the mini-language? Fine, the construct is readily supported both on the syntactic and semantic level by the compiler or interpreter already used. Loops? Procedures? No problem. Depending on the base language, goodies like high-level collection datatypes or lambda abstraction can be offered at no cost as well. I wouldn't want to implement these things in a "homebrew" language/compiler, and if I did, let's rather not compare the quality of the result with the established implementations of Python, Ruby, C++ or Java.
This is not to say XML config files are a flawed concept altogether. If the context is such that XML's strength on interoperability is really needed and used, this is the way to go. But whenever there is a remote chance that what is conceived as a mini-language now will undergo substantial evolution later on and will approach Turing completeness one day, my suggestion is to consider using an established programming language from day one.
|
|