little language

A little language is a particularly small domain-specific language designed to be used within the context of a larger system to perform a specific task. It's not exactly clear how one might quantify "particularly small". Part of the distinction may lie in being single-purpose rather than multi-purpose.

Further Reading

Little Languages , Programming Pearls, Jon Bentley, Communications of the ACM 29:8 (August 1986), pp. 711-721
The origin of the term "little language". Bentley points out that many programming tasks can be thought of as creating "little languages" that are suited to particular small tasks.
Little Languages , C2 wiki

See Also

A little math language
tcl-null
What would be the the semantics of Tcl without any little languages? tcl-null discusses Tcl stripped of all commands, as a beautiful but useless language - the process of adding back a minimal subset of Tcl built-in commands is launched as a game for the obsessive.

Decription

Examples of little languages outside of Tcl include awk, sed, troff, TeX, and shells like sh or cmd.exe in Windows. Markup languages like xml are also examples of another sort of little language.

DKF: It is the Tcl experience that little languages tend to grow. After all, that's what Tcl started out as: a common little language for John Ousterhout's EDA tools.

For a very good example see Solving cryptarithms, especially the examples at end! To prevent over-deep brace nesting, a custom language for such riddles is designed and put to fascinating use.

AM: The term "little language" is also used in a book by Kernighan and Pike: The practice of programming. That is a book I quite enjoyed reading and it uses examples in Awk, C, C++, Java, Perl and Tcl.

A little language may embed a language that is not little. expr and subst are examples of this. critcl might also be considered an example.

Tcl as a Little Language

The core of Tcl is a little language that defines only three primitives: script, command, and word, along with one directive: {*}. Even the substitutions and escape sequences of Tcl can be viewed as set of little languages that make up an inline prepocessor for a command.

The built-in commands of Tcl, however, make it far more than a little language, for this reason, the languages of expr and tcl::unsupported::assemble, although they are DSL's, are not little languages.

NEM commented in an earlier edit that syntax itself does not make a little language. That's true. A little language is in some sense "complete" in its own right. This makes it arguable whether Tcl substitutions and and escape sequences qualify as little languages.

The Little Languages in Tcl

The following little languages are found in the procedures built into Tcl:

clock format
Features a little language for specifting a time format.
glob
Features a little language for pattern matching.
exec
Features a little language for redirection.
expr
Features a little language that includes access to evaluation of arbitrary Tcl scripts. Also used in if, for, and while selectors.
format/scan/binary format/binary scan
Feature little languages for characterizing data.
lindex/lrange
Features a little language for indices.
list
Features a little language for representing lists.
open
Features a little language for creating command pipelines.
string match
Features a little language for pattern matching.
subst
Features a little language for making substitutions in a text.
Regular Expressions
Features a little language for pattern matching, used in regexp, regsub.

Little Lanaguages in Tk

bind
Features a little language for event types, % substitutions and the + command prefix.
canvas
Features a little language for procesing item ids.

All of these are comparatively small and self-contained, and do not have far-ranging effects on the rest of the Tcl system. In this way, Tcl can be understood in pieces; it's not necessary to know the whole language in order to be able to program in it.

These can all be considered particular domain specific languages.

Peter da Silva: I don't think the lindex index and other similar special cases really qualify as "languages" (and, really, some of them should be considered mistakes).

PYK 2022-03-30: Although the article "Little Languages" cites Fortran's F6.2 and COBOL's 999.99 as written in well-defined little languages.

AMG, in a perverse mood: Maybe calling every command a separate "little language" is just a nice way of saying that their interfaces are inconsistent. Certainly I recognize that it's good we have little languages as opposed to the rigid structure imposed by a language like C or (shudder) Java, but that doesn't mean we should abuse this power to avoid worrying about making the standard library of commands self-consistent. (Yeah, yeah, I know the idiosyncrasies from command to command are usually driven by historical reasons, but I'm just trying to make a point.)


An alternative to little languages is sometimes to have a great many parameters for the programmer to set. Tcl/Tk features with that kind of interface include:

Some problems lend themselves towards one approach, some rather to the other. As a matter of Tcl Advocacy it is however interesting to observe that most languages other than Tcl have a syntactical rigidity that makes it difficult to take the little language route.