Version 12 of little language

Updated 2006-09-21 23:08:43

The term, little language, comes from Jon Bentley's column in Communications of the ACM 29:8 (August 1986), pp. 711-721. He points out that much of what we do as programmers can be thought of as creating "little languages" that are suited to particular small tasks.

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.

The Tcl language is itself "little:" its formal syntax is described completely in eleven short paragraphs on the Tcl manual page. Most of its power comes from the fact that it is easy to embed other little languages within it. Obvious examples include:

  • Regular expressions (regexp, regsub, and others).
  • glob-style pattern matching.
  • The switch command.
  • The string command.
  • The expr command (whose language is also used in if, for, while conditions).
  • The bind command adds specialties like %W substitution, + command prefix, break outside loops
  • The format/scan commands and their binary brethren.
  • clock format
  • lindex/lrange command indices - you can specify end-1 or (as of Tcl8.5) $var+1 or similar.
  • exec arguments permit redirection and variable substitution.
  • open file name argument treats leading | as special.

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.


Some little languages that are not part of the Tcl/Tk core are:


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.


See

Little Language http://c2.com/cgi/wiki?LittleLanguage

for other little languages.


[ Category concept - Arts and Crafts of Tcl-Tk Programming ]