Unix Programming - Unix Interface Design Patterns - Language-Based Interface Patterns
In Chapter8 we
examined domain-specific minilanguages as a means of pushing program
specification up a level, gaining flexibility, and minimizing bugs.
These virtues make the language-based CLI an important style of Unix
interface — one exemplified by the Unix shell itself.
The strengths of this pattern are well illustrated by the case
study earlier in the chapter comparing
The advantages that we observed earlier (the gain in expressiveness
and scriptability) are typical of minilanguages; they generalize to
other situations in which you routinely have to sequence complex
operations in a specialized problem domain. Often, unlike the
calculator case, minilanguages also have a clear advantage in
One of the most potent Unix design patterns is the combination
of a GUI front end with a CLI minilanguage back end. Well-designed
examples of this type are necessarily rather complex, but often a
great deal simpler and more flexible than the amount of ad-hoc code
that would be necessary to cover even a fraction of what the
minilanguage can do.
This general pattern is not, of course, unique to Unix. Modern
database suites everywhere normally consist of one or more GUI
front ends and report generators, all of which talk to a common
back-end using a query language such as SQL. But this pattern
mainly evolved under Unix and is still much better understood and
more widely applied there than elsewhere.
When the front and back ends of a system fulfilling this design
pattern are combined in a single program, that program is often said
to have an ‘embedded scripting
language’. In the Unix world,
Emacs is one of the best-known exemplars of
this pattern; refer to our discussion of it in Chapter8 for some advantages.
The script-fu facility of
GIMP is another good
example. GIMP is a powerful open-source graphics editor. It has a GUI
resembling that of Adobe Photoshop. Script-fu allows GIMP to be
scripted using Scheme (a dialect of Lisp); scripting through
also available. Programs written in any of these languages can call
GIMP internals through its plugin interface. The demonstration
application for this facility is a Web page which allows people to
construct simple logos and graphic buttons through a CGI interface
that passes a generated Scheme program to an instance of GIMP, and
returns a finished image.
[an error occurred while processing this directive]