Function Machines: Programming in Two Dimensions

Paul Horwitz

Bolt Beranek and Newman

150 CambridgePark Drive, Cambridge, MA 02140

Functional programming languages like Lisp and Scheme arepotentially powerful instruments for helping students developmathematical ways of thinking. However, helping students acquireproficiency in their use sufficient for the development of mathematicallyrich programs is a nontrivial task. Even Logo, the most accessiblefunctional language, poses significant conceptual barriers tothe acquisition of the requisite knowledge and skill. The principalones are an understanding of the mechanisms for passing data andtransferring control between functions. I will describe FunctionMachines, a visual programming language expressly designed formathematics and computer science education, and illustrate someof its uses in mathematics classroom work. The Function Machineslanguage employs two-dimensional visual representations-graphic icons-in contrast with the symbolic textual expressionsused for representing program structures in traditional (i.e.,one-dimensional) languages. In Function Machines the transmissionof data and the passage of control are shown in graphic animationin a fashion readily accessible to elementary school children.

Function Machines is based on a "function as machine" metaphori n which mathematical functions are viewed as machines that communicatewith other machines through data flow and control flow connections. The system provides as primitive constructs, machines correspondingto the standard mathematical, graphics, list processing, logic,and I/O operations found in one-dimensional languages. Thesemachines are used as building blocks to construct more complexmachines in a modular and extensible fashion. The explicit representationof data paths (by graphically animating the passage of data betweenmachines) and the explicit representation of control paths (byillumination of currently running machines and by graphicallyanimating the passage of control activation) makes the semanticsof functional operation transparently clear in Function Machines. The operation of recursion is made visually explicit by displayinga separate window for each instantiation of the procedure as itis created, and erasing it when it terminates. Function Machinesthus provides a natural starting point for the teaching of programmingas a prelude and complement to nontrivial work with functionallanguages like Logo and Scheme.

In the Function Machines environment, a machine runs wheneverits inputs are available. Since this can occur simultaneouslyfor several machines, the system naturally supports parallel operation. Thus, as well as facilitating the teaching of programming andmathematical inquiry, the system opens new opportunities for introducingthe study of parallel algorithms and models, an "advanced" topic, to beginning students of mathematics. Function Machineshas been piloted in several elementary and secondary mathematicsclassrooms. I will show several examples of teachers' and students'work.