Next: GUI Tools in AIPS++
Previous: The OPUS Pipeline Managers
Table of Contents --- Search ---
PS reprint
Darrell R. Schiebel
National Radio Astronomy Observatory,1 520 Edgemont Road,
Charlottesville, VA 22903
1The National Radio Astronomy Observatory is a facility of the National Science Foundation operated under cooperative agreement by Associated Universities, Inc.
Glish is an interpreted array oriented language. Whole array arithmetic is an important factor in simplifying users' interactions with data. In this respect, Glish's syntax and semantics are loosely based on ``S'' (Becker, Chambers, & Wilks 1988). To this data manipulation language, Glish also adds distributed clients. One of the key features of Glish's client interface is its ability to handle the events (messages) from multiple clients in an asynchronous manner. This allows a Glish script to start several clients and specify how events should flow between them irrespective of event ordering.
AIPS++ selected Glish after some explorations into creating an array oriented language and a distributed object system from scratch. It quickly became apparent that creating a distributed object system which is integrated into a language is not a simple task. Happily, however, Glish filled these gaps very nicely. As a result, Glish is a cornerstone of AIPS++.
Glish was primarily developed at the Lawrence Berkeley Laboratory (LBL) (Paxson & Saltmarsh 1993) and much of the initial development was funded by the Superconducting Super Collider project. Glish was designed with control systems in mind, and as a result, the event handling in Glish works well. Most of the AIPS++ extensions have been in the area of the data manipulation language.
With few exceptions, values in Glish are vectors. All numeric operations are performed on vectors. In fact, multidimensional arrays are implemented as vectors with extra information, i.e., the shape of the array. Functions which operate on vectors element by element, thus, work for both arrays and vectors.
Array oriented languages allow the user to operate on sub-arrays of a larger array, and for this, Glish has a flexible format for taking slices (contiguous sub-arrays) and picks (non-contiguous elements) of arrays and vectors. Figure 1 shows how array access within Glish works.
In this figure, vectors are created with the sequence operator, `` :''.
This operator creates a vector initialized to the specified sequence.
For example, 3:5 would create a vector containing
[3 4 5] , and 1:-1 would yield
[1 0 -1] . Arrays are created with the array function.
The first parameter to this function is the initialization values for the
array. This initialization vector is repeated if its length is less than
the length of the array. The final parameters to array are the lengths
of each of the array's dimensions. Figure 1 also has examples of
how boolean vectors can be used to mask portions of the array, e.g.,
a[a < 9] := 0.
Figure 1: Array and Vector Manipulations.
Distributed clients are useful to users and programmers because they permit distribution and localization. The usefulness of distribution is obvious; work can be selectively distributed across machines on a network. Localization, however, is perhaps the biggest win. By having clients which are loosely coupled to the interpreter, pieces of the system are localized and isolated. The only interaction among the pieces of the system is a defined protocol of events. The interaction between the interpreter and the clients must, however, be sufficiently rich. In the case of Glish, nearly all Glish values can be passed between the interpreter and its clients. All of this means that for programmers portions of the system can be developed with little regard for the rest of the system, and for users it means that portions of their environment can be updated without disturbing them and without recompiling the whole environment.
In Glish, the interpreter is the hub through which events flow, and a Glish script directs how the events flow from one client to others. In many ways, Glish clients and events correspond to objects and messages in some object oriented systems. Event flow in Glish is directed primarily with the whenever statement. Figure 2 shows how clients are created and how whenever statements are used. In this example, two clients are used--- timer, which sends an event periodically with a specified interval, and mosaic, which is a Glish script client (see Figure 3). The code in Figure 2 initializes a string array, pages, with the URLs which we want to loop through. It then creates the two clients with the client function. The whenever statement points mosaic at a new URL each time timer generates a ready event. The final line initializes timer to generate events 40 seconds apart. This simple example cycles mosaic through a series of URLs.
Figure 2: Slideshow with Glish and Mosaic.
Figure 3 shows the Glish script client mosaic.g. A ``script client'' is a Glish script which behaves like a client for another Glish interpreter. This client in particular handles moving Mosaic from one URL to another. In script clients, the script value is the source of events to the client and the sink for events generated by the client.
Figure 3: Steering Mosaic (mosaic.g).
This paper has only addressed the most interesting aspects of Glish. The aspects of Glish which one now expects from modern programming languages, e.g., functions, structures, control loops, conditionals, etc., have not been addressed. The implementation details were also not addressed. For this and other information, I refer you to the Glish home page found at the URL given at the beginning of this paper.
The topics which this paper does address, however, demonstrate some of the most interesting aspects of Glish. Indeed, it is primarily for these reasons that AIPS++ has adopted Glish. While we have continued to improve Glish, much gratitude is owed those who laid Glish's foundation at LBL.
The Glish additions which are currently being explored at the NRAO include a Tk binding for Glish which allows individual Tk widgets to behave like Glish clients, improved security for Glish clients, a module system for Glish, clients which look more like distributed objects, and the ability for clients to extend the Glish language itself.
Paxson, V., & Saltmarsh, C. 1993, Proceedings of the Winter Technical Conference (Berkeley: USENIX Assoc), 141
Glendenning, B. E. 1996, this volume
Garwood, R. W. 1996, this volume