We have presented a stepwise development of a modular program for animating Conway's Game of Life, using CLEAN's GUI facilities. The major features of CLEAN have been introduced progressively during this development. Once accustomed to the novel style, programming in CLEAN is more rapid and error-free than in imperative languages. In particular, the elegant unique type mechanism ensures single-threading of input/output operations in a flexible way. Rewrite rules on constructors (as in section 10) help to simplify error-handling and thus make it easier to write single-threaded code. A disadvantage of CLEAN is that it only contains features common to both the Macintosh and Unix/X environments. As a result, there are no facilities for printing directly from within an application, for accessing Unix command-line arguments, or for accessing Macintosh resource forks. Some annoying but minor syntactic limitations of CLEAN derive from its earlier use as an intermediate language, and are likely to be resolved in future releases.
CLEAN's GUI facilities are somewhat less general than X or Motif. In particular, CLEAN inherits the Macintosh division between windows and dialog boxes. A window cannot contain buttons, although it is possible to mimic the effect by special handling of mouse events inside particular areas of the window. A dialog box cannot contain windows or other dialog boxes as components, although it may contain a user-defined control (which provides some of the facilities of a window, as we saw in section 12). However, the GUI features such as windows, menus, etc. provided by CLEAN have the advantage of cross-platform portability, and are very easy to define using list and algebraic data type (tree) structures. The definitions are first-class objects, so that we can write a function such as TextWindow (section 11) which returns a window definition. The method functions which respond to events are of course also first-class objects, and can be computed as was done with the look and feel functions in section section 12. The CLEAN language provides the ability to rapidly develop readable and correct programs, and so should become increasingly popular.
The Final GUI Animation Program