Imagine a constructor set that lets you use ready-made objects to create customized calculation applications--fast
Dick Pountain
Objects are the future of computing, we're told. But few of us can easily imagine how applications built from reusable components will look. However, after using CleanSheet from Working Title (Yarnton, U.K.), I have a pretty good picture, and I like what I see.
CleanSheet is hard to describe, although if I sat you in front of a PC screen, I could show you what it does in about 5 seconds. Basically, it's a constructor set for grown-ups; it allows you to combine ready-made objects by ``wiring'' them together visually on-screen. Without writing any code (not even the token number of lines that Visual Basic requires), you can create customized calculation applica
tions as varied as financial spreadsheets and visualizations of scientific data.
A few existing products use a visual programming metaphor; the most successful of them is probably National Instrument's (Austin, TX) LabView data-logging package. But CleanSheet is a more general-purpose package than any other system I've used. Currently, it is available only for Microsoft Windows 3.1.
Using CleanSheet
When you build a new application in CleanSheet, you literally start with a clean sheet--a blank screen onto which you drag objects from a palette that resembles Visual Basic's toolbox. The palette has 58 predefined objects that cover every aspect of data input, manipulation, storage, and display.
When dragged onto a sheet, CleanSheet objects appear as squares or rectangles with a very thick gray border, often with an identifying icon in the center. Scattered around the borders of these objects are small circles, which represent input ports, and squares, which represent outputs. To connec
t two objects, you simply click the mouse on, say, an output square and ``stretch a pipe'' to the desired input. If you try to do something silly like connecting an input to another input, the pipe refuses to take hold.
CleanSheet applications look like industrial process diagrams, with lots of boxes connected by pipes. Once you develop an application and get it working, you can hide the objects' thick borders. The program automatically aligns objects and reroutes pipes to produce a good-looking application.
Most CleanSheet applications rapidly expand beyond a single screen, and the program offers several ways for getting around large sheets. Obviously, you can scroll around to look at other parts of a sheet. You can also split each screen into two or four subwindows, each showing a different part of the same sheet, or open a new window on the same sheet. As with a drawing program, you can zoom and shrink your view of the application to various scales; the sheet remains editable at all scales. A
s a result, CleanSheet is an application that cries out to be run at a resolution of 1024 by 768 pixels or higher.
Like a drawing package, CleanSheet supports as many as 100 separate layers, which permits large-scale structuring of your application. You use a mouse to run pipes between layers, in the same way that you run pipes between objects. If you view all layers at once, the program uses a fading depth effect to help you distinguish among the layers.
You can also group several objects in a single higher-level object, which lets you produce hierarchically structured applications. You can lock such structured groups with a password, so they provide a handy format in which to distribute application templates. The program's system of style tagging lets you color or size a group of related objects in a single operation.
In most cases, when you click on a CleanSheet object, a dialog box appears, and you can set the object's vital parameters. For example, in a filter object, you might want
to set the filtering condition; for a calculator object, you could supply the expression the calculator will compute; and for an array-dissection object, you might define the areas it will work on. Clicking on any pipe opens a Pipe View window that shows you the source and destination types and current contents of the pipe. These views are updated dynamically at run time so that you can trace program execution.
After wiring up all the objects you need, including at least one that displays the final result, you switch CleanSheet from edit to run mode, and the sheet is recalculated. Actually, it is the pipes--the repositories of data--that get recalculated, rather than the objects themselves. You can choose manual recalculation or have automatic recalculation triggered whenever the data in an input object is changed. Another option permits circular references between objects, although you must specify a maximum number of iterations to avoid heap overflow.
Pass the Data
What makes CleanSheet
work so smoothly is the ingenious protocol it uses to pass data from one object into another. Variable-size, multidimensional arrays are the fundamental data structure. Object inputs and outputs (as well as internal function arguments) accept or return only a single value, but that value can be an array holding as many as 10 dimensions; its elements can be a mixture of any of CleanSheet's data types--integers, real numbers, strings, Boolean expressions, dates, times, complex numbers, equations, errors, and null objects. So an entire spreadsheet can travel around the system as a single object, while a stream of data (e.g., the first 1000 prime numbers) is passed as a one-dimensional vector. This avoids at a stroke the nasty synchronization issues that arise with variable-length data flow, and you can think of the recalculation of a sheet as a single clock tick in which single objects of varying sizes pass through the pipes.
For obvious reasons, spreadsheet-like 2-D arrays have special importance in Clea
nSheet. You input most data in this form, and many CleanSheet objects are concerned with 2-D array manipulation: dissecting them, sticking them back together, and merging, transposing, filtering, multiplying, and summing rows and columns. In fact, it is tempting to describe CleanSheet as a visual APL for the 1990s. It employs a bracketed array syntax that permits you to write, for example, a 2-D array constant such as {{1,2,3}{``cat'', dog'',''bat''}}. You often need to split an array into several parts and send them into different objects; CleanSheet always offers you the choice of specifying the subarrays by writing code or by interactively pointing and clicking on a grid.
Because it provides objects with different levels of generality, CleanSheet typically offers many ways to achieve a particular effect. For example, to process every element of a 2-D spreadsheet, you might use the Calculator object, which applies the same formula to an entire array; a COG (Corresponding Objects Grid) object, which c
ontains rules on how to process by rows and columns; or pairs of Announcer and Reporter objects, which split the array into its elements, pipe them to an intermediate calculating object, and recombine the results into a single array.
Using Objects
CleanSheet's 58 object types fall into three main groups: 13 for data input, 11 for data display, and over 30 for processing data. CleanSheet offers a handful of control objects, such as switches, junctions, and lookup tables.
The simplest input device is an input table, into which you enter data just as you would in a spreadsheet. You cannot enter formulas, however, so to build the equivalent of a spreadsheet, you have to pipe the data to a calculating object and then pipe it to a display table. An input table does have built-in computational ability. Each row and column total is available via an output square marked with a sigma. You output the entire spreadsheet by connecting to the square in the lower-right corner of the input table.
T
here are other simple input devices, such as a text box that lets you type in text without surrounding it with quotes. But CleanSheet also offers eye-catching gadgets, like button bars for entering restricted sets of values, tumblers (i.e., rotating knobs), and sliders for entering floating-point numbers or integers. Most advanced of all are the polar, x,y-scatter, and density-graph inputs, which let you interactively ``paint'' data onto a graph scale. For example, to complete a density graph, you fill a grid with blobs whose areas are proportional to the data value.
For output, CleanSheet provides tables (for creating a conventional spreadsheet display), bar charts, pie charts, 3-D graphs, segment charts, and polar, x,y-scatter, and density graphs. These objects give you sophisticated control over color and scaling, and the graph objects let you produce professional presentations by incorporating on surfaces and backgrounds elements like user-supplied bit maps (e.g., a map of the U.S.). The one featur
e I miss is a surface plot for mathematical visualizations.
You can also output to the Hard Copy object, which sends data to the printer in various forms, or to the Filing Clerk object, which writes data to a file. Input tables can import data files directly from applications such as Lotus 1-2-3 and dBase into a variety of formats, including comma-delimited, DIF, SYLK, and DBF.
Between input and output, you set up processing objects to do the work. As I mentioned earlier, CleanSheet provides a calculator object, into which you enter a mathematical expression relating the inputs (A through Z) to the output, and a COG object, into which you enter multiple expressions and the rules defining which area of the sheet they apply to. As with other operations, you can generate these rules by pointing and clicking.
The General, Financial, and Statistical Toolbox objects are more specialized calculators containing large numbers of preprogrammed functions useful in their respective domains. More spec
ialized still, the Savings and Loan object is devoted to compound-interest calculations. Other specialized objects include the Random Generator object, the Chi-Square object for statistics, and the Sum, Product, and Sum-Product objects for matrix manipulation.
Finally, if none of CleanSheet's other objects will do the trick, you can use the Computer object, into which you enter your own programs written in a C-like language called Cesk. I managed to translate the C source code for the old BYTE Sieve of Eratosthenes benchmark into Cesk in about 5 minutes. My efforts produced a handy new prime-numbers object, and the benchmark results that I got demonstrate that Cesk runs at around the speed of interpreted GWBASIC.
Cesk has subtle syntactic differences from C that may cause seasoned C programmers some grief at first. For example, function parameters must be surrounded by curly, rather than round, brackets (they are actually arrays), and the use of terminating semicolons is slightly different (see
the listing). I also found it too easy to provoke UAEs (unrecoverable applications errors) from misbehaved Cesk programs, often due to heap overflow.
When you need goal-seeking and solver functions like those provided in Excel, you can use CleanSheet's powerful Solution Search object. It can maximize or minimize a variable by repeatedly varying other selected parameters. It automatically deploys three alternative algorithms--Linear Programming, DFP (Davidson Fletcher Powell) unconstrained optimization, and Constrained Boundary Traversal--to find a reasonable solution.
CleanSheet's equation data type is the basis for other powerful objects. The Curve Fit object takes a table of x,y values and fits a curve to them--linear, exponential, square, or polynomial (up to the fourteenth order). The output is not a data array but an equation that you can feed into the Equation Evaluator object, which in turn applies the equation to a list of x values and outputs the y values.
You can feed equations
into x,y-scatter or polar-graph objects, which will plot them for you, as these polymorphic objects are equally happy with a table of points or an equation. This feature alone makes CleanSheet a wonderful mathematical teaching tool. Also, x,y-scatter and polar-graph objects let you draw a graph and output the corresponding equation, so you can design your own empirical functions by eye. I know audio and automotive engineers who'd kill for this feature.
It's hard to do justice in this short space to the ingenuity of many of CleanSheet's math functions. Consider one example, the Mag function, which returns the magnitude of an object. For a numeric object, Mag returns its absolute value; for a string object, its length; for Boolean operations, a 1 or 0. For a date object, it returns the number of days from January 1, 1900; for a time object, the number of seconds since midnight. For a complex number of the form a+bi, Mag returns sqrt(a*a+b*b); and when applied to a square 2-D array (a maximum of 16 by 16
elements is permitted), Mag returns its determinant. The equally polymorphic Extrapolate function can identify common series types (e.g., the third Monday of each month) and guess the next item in the sequence.
Vague logic, CleanSheet's implementation of fuzzy logic, is available within any object that makes comparisons. The syntax for vague comparisons involves duplicating the operator, so A
<
<
B means A is less than B by at least 5 percent, while A
<
<
<
B means a difference of less than 10 percent, A
<
<
<
<
B means a difference of less than 25 percent, and A
<
<
<
<
<
<
B means a difference of less than 50 percent. Similarly, A >==
<
B means A equals B with a 10 percent margin. In addition, CleanSheet offers several vague lookup functions, such as Nearest, that let you find the closest match in an array of numbers.
Advisor
As anyone who has studied Smalltalk or C++ knows, the downside of object-oriented systems is that you must learn the semantics of possibly hundreds of object classes. With just
58 object types, CleanSheet is modest in size compared to, say, MFC (Microsoft Foundation Classes), but its palette still looks somewhat intimidating when you start. To help you get acclimated quickly, Working Title provides a help system that goes beyond what Windows programs commonly offer.
You can get help on any object in the palette, or any instance of it in a sheet, by clicking the right mouse button on that object. This presents you with the reference manual page that defines the object's functions and interface.
The extra help, Advisor, is unusual (see the screen). This interactive system tells you which objects are suitable for a given task. Its opening window displays all object icons in dimmed form; above and below them is a multiple-choice questionnaire, which you answer by clicking on buttons. For example, the first four choices are as follows:
A I wish to present data to the user
B I wish to obtain data from the user
C I wish to process data within the sheet
D
None of the above matches any part of my requirements
When you click on one of these, the appropriate related icons light up, and a new set of choices appears. Advisor continues to guide you, helping you refine your requirements until only a few icons are lit. Then you can consult the normal help by clicking on each remaining object.
Advisor's search system is quite sophisticated; the Restart and Rethink buttons let you backtrack if you take a wrong turn. I used Advisor extensively when learning CleanSheet and found it excellent.
An Object Future
I've said that CleanSheet offers a glimpse of the object-oriented future, but I need to qualify this. Strictly speaking, CleanSheet is an ordinary Windows 3.1 application, and its world of objects extends no farther than its own screen window.
The real future of objects lies in operating-system support for object communication across different applications, and in the case of Microsoft's operating systems, this means that it lies in
OLE 2. The current version of CleanSheet, version 1.4, doesn't support OLE 2. Author Nigel Johnstone says he will support OLE 2 only when Chicago becomes available (perhaps in CleanSheet 2.5), and then only in the form of OLE input and output objects that will send or return arrays of data from the outside world. Unfortunately, CleanSheet's elegant object-communication protocol cannot be mixed with the baroque complexities of OLE Automation. Nevertheless, I stick by my judgment that the way CleanSheet works--by permitting end users to program visually--points to the way that future OOP (object-oriented programming) applications will work.
Of course, not every user wants to perform even this degree of programming. Johnstone says that version 2.0 will add a complete working spreadsheet object to flatten the learning curve for conventional spreadsheet users.
Even with this feature, CleanSheet will probably not displace Excel for totting up the petty cash in the accounts department. It is more like
ly that engineers, laboratory scientists, financial modelers, teachers, and mathematicians will be the first to appreciate the program, creating in minutes customized and highly interactive user interfaces that are tedious or impossible to achieve in a conventional spreadsheet. CleanSheet will undoubtedly have other devotees as well: people like me, who find it enormously entertaining to play with constructor sets.
For More Information
Working Title
129 Woodstock Rd.
Yarnton, Kidlington OX5 1PT
U.K.
+44 0865 370175
fax: +44 0865 370515
Listing: Cesk code for generating primes using the Sieve of Eratosthenes.
main { pmax := a; /* taken from input a */
width := 1;
pnum := 0; /* initialize prime counter */
flags := makearray{true,pmax}; /* set all flags true */
for (i := 0; i
<
= pmax; i+=1;)
{if (flags[i]) /* found a prime */
{prime := i + i + 3;
for (k := i + prime; k
<
= pmax; k += prime;)
flags[k] := false; /* kill multiples */
pr[pnum ? width][pnum / width] := prime;
pnum +=1; /* primes found */
};
};
return(pr)
};
Illustration: A typical CleanSheet application contains input objects (e.g., Sample Data), output objects (e.g., the x,y graph), and computing objects. This sample application derives an equation from the input data and then both plots it and uses it to transform a further data set (the tables with yellow backgrounds). I've opened a Pipe View window to show the actual cubic equation that was derived from the data contained in the magenta-colored pipe.
Illustration: For larger CleanSheet applications like this linear programming problem, you can place objects on separate layers to make the sheet more manageable. In this half-scale view, the grayness of certain objects indicates they are on l
ower layers. This example is based on the Solution Search object that appears at bottom center.
Illustration: Advisor, an interactive help system, guides you through the process of choosing the proper object, presenting you with all 58 choices and posing questions that help you narrow down your selection.
Dick Pountain is a BYTE contributing editor based in London. You can reach him on the Internet or BIX at
dickp@bix.com
.