[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13. Summary

Let us compare Ousterhout's design goals for Tcl in [Tcl], and see how Q fits them:

  1. The language is for commands. ... This suggests that the language should have a simple syntax so that it is easy to type commands.

    This has been a major goal in designing Q, and has motivated most of the decisions discussed in this paper.

  2. The language must be programmable.

    Q is a fully programmable very-high-level language.

  3. The language must permit a simple and efficient interpreter.

    This has not such a priority for Q. Compared to Tcl, Q is a big language. The interpreter is efficient enough for interactive use, and there is an (un-finished) compiler that translates Q into C++. However, the run-time is much bigger than Tcl (though much smaller than typical Lisp systems). On the other hand, much of the system size consists of the builtin types and routines, and the system is modular enough to be incrementally loadable (autoloading will soon be added).

  4. The language must permit a simple interface to C applications.

    Because Q has a rich hierarchical type system, it is more reasonable to support a simple interface to C++ applications. This Q does very well. Most of the primitive functions are written as Q stub routines that invoke a C++ primitive. For example:
    :(:x take :y~Numeric)=external DoTake
    declares that the take function takes two arguments, one of which must be numeric, and the body of the function is implemented by the C++ function DoTake.

    Writing DoTake is also easy:
    Object* DoTake(Object* x, Numeric* y) { ... }
    (Note that Numeric is a sub-class of Object.) The Q module containing take is compiled into a C++ program, whose object file is linked with that containing DoTake. Nothing more is needed. The linking can be dynamic or static. The C++ mechanism for static initializers is used to enter take into the appropriate tables.

It is practical to combine the features of a shell into a full-fledged programming languages. I hope I have shown that careful orthogonal design can give a moderate-sized very powerful multi-purpose language.

Using object-oriented programming (and C++ in particular) made it much easier to manage the many possible combinations in a rich language (such as different expression types and different output modes).

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Per Bothner on December, 4 2001 using texi2html