Tuesday, March 14, 2006

 

The Rule of Least Power

Tim Berners-Lee recently wrote about the The Rule of Least Power. The abstract is: When designing computer systems, one is often faced with a choice between using a more or less powerful language for publishing information, for expressing constraints, or for solving some problem. This finding explores tradeoffs relating the choice of language to reusability of information. The "Rule of Least Power" suggests choosing the least powerful language suitable for a given purpose. In principle I agree with what is being said, but an alternative view is given in A Universal Scripting Framework or Lambda: the ultimate "little language". Now I love playing with Lex and YACC and creating little languages - it is a lot of fun - but I'm rapidly coming around to the viewpoint advocated by Olin Shivers in the above paper. Why reinvent mechanisms for basic control etc. when this is already a well developed area? Or more directly, reinventing this stuff is a waste of my time, and gets in the way of more interesting work. Embedding large language interpreters (e.g. Python, Perl, Rexx etc...) into an application strongly dictates the structure of the little language. Indeed, without extensive reworking of the language parser, any constructs specific to the little language will always be second-class citizens in the program. Others have advocated large code-generation frameworks for managing domain-specific languages, but this typically makes a lot of assumptions about the kinds of languages that can be generated. At worst there will be lots of arbitrary constraints on how data can be exchanged between tools, and it is not clear that this approach is structurally sound. But there is an alternative approach, and that is to use a language with minimal syntax and a minimal number of reserved words (e.g. Lisp, Scheme, TCL, Forth, XML). With such an approach it is possible to invent your own control structures, and integrate them into the language in a way that appears identical to the built-in primitives - the new domain-specific are no longer visually second-class. XML is an extreme example - as a declarative language it has no model for imperative actions, and to 'execute' XML requires an interpreter or compiler (i.e. a lot of work!). But it is ideal for modelling data, and often that is sufficient.

History note: the term little languages was (apparently) first used by Jon Bentley in this Programming Pearls column.

Update: This paper looks interesting - added to the 'to-read' list!




Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?