Home > Previous Page >  Byte August 1980 Editorial
Archive Search  

Byte August 1980 Editorial

Byte August 1980 Editorial page 6
Advert removed!
Threads of a FORTH Tapestry
Editor's Note: This month's editorial is by BYTE Editor Gregg Williams. Gregg was responsible for the preparation of this month's special section devoted to the FORTH language. Carl Helmers returns next month with an editorial.... CM
hat do a portable heart monitor, the new Craig Language Translator, a peach-sorting machine, and a movie called Battle Beyond the Stars have in common? The answer is FORTH, a not-so-new language as comfortable in industrial machinery as it is in a personal computer. In fact, it was originally used by its inventor, Charles H Moore, to control the telescope and equipment at the Kitt Peak Observatory. Although I have known about FORTH for about a year, it was only during the preparation of this issue that I began to actively keep my ears open for mention of this unusual language. I have uncovered a lot of information (and some experience) about FORTH and its variations. The language is so unusual that no single line of thought could give you a picture of what the language is like. Instead, the following sections represent several threads from the rich tapestry called FORTH.

FORTH in the Real World
No language I know of is as comfortable in real-world situations as FORTH. Here are some examples of the breadth of applications that have been created using FORTH:
• Elicon Inc of Brea, California, is using FORTH software to drive the same kind of computer-controlled cameras that were used to film the sophisticated space-battle scenes in Star Wars. New World Productions of Venice, California, is using this camera system to film the spaceship sequences in the motion picture Battle Beyond the Stars. In a related development, Magicam Inc (which devised a number of the special effects for the recent movie Star Trek) is in the process of converting control of its master-slave camera pair from an analog computer to a digital computer running FORTH software. In the Magicam process, the master camera follows actors on a special blue stage while the computer guides the slave camera across a detailed model. Later, the two images are optically combined, producing the effect of the actors actually being in the landscape depicted on the model.
• Allen Test Products of Kalamazoo, Michigan, has developed an ignition analyzer for use in service stations and automobile repair shops that analyzes the behavior of automobile ignition systems and displays both diagnostic and corrective information. Formerly, the voltage waveform from a spark plug was displayed on an oscilloscope, after which a mechanic would attempt repairs based on his interpretation of the waveforms.
• Atari Inc is using FORTH in two of its divisions and is rumored to be contemplating other uses for the language. In its Coin-Operated Division,
Byte August 1980 Editorial page 8
which develops and markets the stand-alone games found in pinball arcades and restaurants, a 6502-based development system employs FORTH software to debug and test arcade circuit boards. In addition, Atari has developed its own custom version of the language, called game-FORTH, that is awaiting its first use to replace machine code as the language used to create arcade games. Someday soon, you may play a coin-operated game without knowing that you are actually running a FORTH program.
In the Consumer Group of Atari, a version of FORTH that has been extended to allow manipulation of the video screen and game peripherals has been developed for the Atari 800 computer. Although no definite plans have been made, Atari may market it as an option for the Atari 800, or, like the Coin-Operated Division, use it in a "transparent" mode to implement games and other programs.
• FORTH is used in a portable 1802-based computer that aids in the treatment of patients with infrequent heart flutter. The device, small enough to be worn comfortably by the patient  during
his or her daily activities, constantly updates a "snapshot" of the patient's heart activity every 7 seconds. In addition to recording this information in real time, the device analyzes the data for evidence of a heart murmur. When a murmur is detected, the device stores the data containing the evidence and signals the patient to return with the device to the doctor's office for analysis and diagnosis.
• In another medical application, FORTH is the sole language used in a computer at the Cedar-Sinai Medical Center in Los Angeles, California. Using FORTH, a Digital Equipment Corporation PDP-11/60 simultaneously performs, among others, the following tasks: manages 32 remote terminals; stores patient information from an optical reader into a large data base; runs a statistical package that analyzes the patient data base in search of trends in the physical makeup, treatment, and results of similar patients; and analyzes blood samples and heart behavior in real time while a patient is exercising on a treadmill machine. Spencer SooHoo, in  the pulmonary  medicine  section, is
also developing a portable 6800-based FORTH system to be used for monitoring intensive-care patients.
• A stripped-down version of FORTH was used to create the hand held Craig M100 Language Translator under time, size, and other design constraints. This same language also runs the software inside the translator unit. In a related product, a hand-held ASCII terminal manufactured by MSI Data Corporation of Costa Mesa, California, also uses FORTH internally.
• In what must be the most interesting FORTH application I have encountered, a central California fruit farming cooperative uses an 8080-based machine running FORTH to adaptively sort and grade peaches. Infrared sensors send information to the computer on the coloring and quality of pitted peach halves that pass the sensors on a conveyer belt. After analyzing this data, the FORTH program causes flippers to knock the peach halves into appropriately graded bins—extra fancy, fancy, etc. In addition, the program keeps track of the percentage of peaches in each bin and changes its selection criteria to maintain a certain fixed ratio among the various grades of peaches.
• Last but not least, FORTH is used in several aerospace applications. A FORTH-like language called IPS (running on an 1802-based system) is orbiting Earth in an amateur radio satellite called the OSCAR Phase III. Avco Inc is using another 1802-based system (again, for the small size and power consumption of the 1802 microprocessor) to monitor temperature and take care of ground-to-satellite and satellite-to-ground telemetry in a military satellite.

Who Should Try FORTH?
FORTH is an easy language: a high school student, Arnold Schaeffer, wrote an arcade-type game called BREAKFORTH. (See "Breakforth into FORTH," by A Richard Miller and Judy Miller, on page 150.)
FORTH is a difficult language: it easily beats APL as a "write-only language"; you can write a program in the language, but you can't easily read what you've written.
Given these two valid extremes, your initial reaction might be, "This doesn't make sense." True, learning
advert removed!
Byte August 1980 Editorial page 10
FORTH takes some time; it's some what like learning a foreign language. So far, my experiences with FORTH remind me of my attempts at learning a smattering of Russian; both languages are so different from any I've seen before French or Spanish, BASIC or FORTRAN that I have to mentally shift gears to work in the new language.
You should give FORTH a try if you are excited by what you see here. Especially important in this respect are the articles, "What is
FORTH? A Tutorial Introduction," by John James, and " A FORTH Glossary," pages 100 and 186, respectively. Your best bet is to get to a computer that can run a version of FORTH; or, better yet, get someone who knows the language to demonstrate it to you.
My first experience with FORTH was at the Fourth West Coast Computer Faire in May 1979. A. member of the FORTH Interest Group was demonstrating the language using an Apple II and an Advent television screen. First, he
defined a word called COUNT, like this:


Then he said { 6 COUNT } (note: the braces are not part of the expression; see the accompanying text box), the computer replied with { 0 1 2 3 4 5 OK }. I was instantly hooked on learning more about FORTH. What he had done closely paralleled the iota function in APL, and anything that even resembled APL was going to get my full attention.
If you are at all dissatisfied with the capabilities of your current computer, or if you feel that there should be more to computers than BASIC and assembly language, you should try FORTH. Once you get accustomed to its peculiar syntax, you can make it do nearly anything you want it to. In fact, you can even make it have features it did not previously have. Assembly language is like this to some extent, but FORTH is a higher-level language with the same abilities—only magnified. FORTH is what I call a "homebrew" language; its enthusiasts carry with themselves the same look-how-this-works enthusiasm as do most hardware hackers who build their own hardware. If we ever have a homebrew software issue, FORTH will certainly be included.
FORTH is the ultimate software hacker's language because, like a bag of components before a hardware hacker, you can do anything you want to with it. It can be argued that assembly language is the ultimate programming language; strictly speaking, this is true, but it takes so much more time to craft a piece of software in assembly language that it is practically ruled out in most cases.
However, this total freedom carries with it complete responsibility. Since, for example, the FORTH program you write is free to use an array subscript that is out of bounds, you must be responsible enough to either (a) put in error-checking routines (you can take them out later), or (b) build your program up from small tested modules to assure that your program will never execute an improper subscript. If you would rather have the language system do this kind of work for you, stick to BASIC or whatever you're running now.

Text continued on page 128
advert removed
Byte August 1980 Editorial page 128
Text continued from page 10:
You should also look at FORTH if you have limited computer or financial resources. FORTH is a big language in a small package, and you can buy a version of FORTH for as little as $20.(See "Selected FORTH Vendors," on page 98.) Unlike most new languages that gobble up more and more of the 64 K bytes allotted to an 8-bit microcomputer (some won't comfortably fit in 64 K bytes), there is plenty of room for very large FORTH programs even in a 16 K machine. FORTH takes up only about 8 K bytes, and this can be pared down; in an industrial application that will run only one program, the FORTH interpreter can be made as small as 800 bytes. Also, FORTH can be run on cassette-based systems due to its small size; although this is still more inconvenient than running FORTH on a disk system, most languages that use a disk are impractical or impossible on cassette-only systems.
Finally, you may want to consider FORTH for applications where speed is of the utmost importance. Since portions (or all) of a FORTH program can be written   in   the   assembly   lan-
guage of the host computer, FORTH programs can be written that compare favorably in speed with machine-language programs. And, again, productivity is higher using FORTH than it is with machine language.

What Is a Threaded Language?
Imagine a language that starts with a few fundamental subroutines written in the machine language of the host computer; eg: routines to put a character to the display device, to get a character from the keyboard, to multiply two fixed-point numbers. Then imagine that the only way to combine these subroutines is to string them together (with embedded data bytes) as a series of subroutine calls; eg: a routine to get a signed multi digit number from the keyboard is written as a controlled series of calls to the subroutine that gets a character. Then these routines are called by other routines that perform even bigger tasks. For example, a routine to sum a series of signed numbers entered from the keyboard is written as series of subroutine calls that includes
Special Notation Used in
This Issue

Because FORTH is such an unusual language (it uses punctuation marks by themselves and within words), a pair of braces, { } , is sometimes used to set apart FORTH words from the rest of the text. Braces are used under the following conditions:

  • When the material being quoted is a series of FORTH words; eg: { 26 LOAD } ;
  • When the FORTH word is or contains any of the following punctuation marks: period, comma, colon, question mark, exclamation point, single quote mark, or double quote mark. Two examples are { . } and (") }.
In addition, spaces are always used to separate FORTH words from other words or punctuation—even when this means doing something like "...the words BEGIN , WHILE , and REPEAT are all..." (spaces between FORTH words and the commas that follow them). There are two reasons for doing this: first, for clarity; and second, to emphasize that the FORTH word in question does not include the punctuation that follows. Some FORTH words do contain punctuation (eg: { IF, }), but such words will always be enclosed in braces (except within program listings).
the one mentioned just above. The final program in such a threaded language is a series of calls to lower and lower subroutines, dipping repeatedly into machine-language routines under the control of higher-level routines. The addresses in each subroutine that point to the subroutine or machine language under it make up a "thread" of control that runs through the entire program.
FORTH has so far been implemented as a threaded language. Threadedness is a language implementation technique, not an inherent quality of any language; SNOBOL and FORTRAN compilers have been written using threaded code.
advert removed
Byte August 1980 Editorial page 130
FORTH: Pro and Con
Pros: I have already mentioned most of the advantages of FORTH. The language is:
  • Compact;
  • Fast, although this is due to its implementation in threaded code, not its inherent qualities;
  • Structured: it has the major constructs of structured programming and, in fact, does not have any kind of goto statement, thus forcing it to be structured;
  • Extensible;
  • Highly portable.

These last two features deserve further description. The extensibility of FORTH is probably its most important feature. Never before in a high-level language has it been so easy to add new features, new data types, and new operators to a language. Unlike other languages, these new words (everything in FORTH is called a word) have the same priority and receive the same treatment as words defined in the standard FORTH vocabulary.  For
example, you can define a word 10+ that will add ten to any number it is given; or, in fact, you can even redefine the addition operator + . You can also define entirely new families of words in FORTH. This advanced topic is ably discussed in what I believe is the only written treatment of the subject anywhere in FORTH literature by Kim Harris in his article, "FORTH Extensibility," on page 164.
Most FORTH programs can be transferred from, say, a mainframe computer to a microcomputer without modification; therefore, FORTH is highly portable. Most of the FORTH words supplied in a given system have been defined to do the same operation regardless of the computer used. Although the vocabulary of words varies from supplier to supplier, most FORTH programs will run with minor or no modifications. A standard set of words, called FORTH-79, collectively developed by many of the major suppliers and users of FORTH, will help in this situation.
Cons: Here are some of the disadvantages of FORTH:
•   FORTH code is hard to read.
This is probably the most common complaint against the language. As a new user, I can say that you slowly get used to the odd syntax of the language. The stack architecture (see below) of the language contributes to the novice's initial disorientation, but this feeling is usually blamed on the unreadability of the language. In addition, the stack architecture encourages the storage of working values on the stack rather than in variables with names. Variable names, if chosen properly, give vital clues to the workings of a program; this scarcity of variable names makes most FORTH programs less readable. Adequate indentation and comments can help a FORTH program, but programmers of FORTH, like programmers of all other languages, often omit these aids to comprehension.
• The stack architecture of FORTH offers disadvantages as well as advantages. Remember the odd feeling you got the first time you used a Hewlett-Packard calculator and had to punch in " 5 ENTER 3 + " instead of the more understandable " 5 + 3 = " 7 FORTH uses the same reverse Polish notation (abbreviated RPN), where the objects being entered come before the operators that work on them. Not only does this take some getting used to (it takes even longer before you can fluently "think in FORTH"), it also encourages a scarcity of named variables, as mentioned above. In addition, stack-manipulating words like SWAP, DUP (for duplicating the top entry on the stack), ROT (for rotating the top three items on the stack), and others muddle the FORTH program and make it hard to tell just what variable is being operated on. This uncertainty is particularly evident during debugging; most of your time is spent finding out why what you thought was on the stack isn't there.
• FORTH encourages programming "tricks" in place of plain, easier to read programming. Although the examples to support this statement have already been mentioned, I think the statement as a generality is true. We must remember that, especially since lack of memory is usually not a problem in FORTH, FORTH programmers should name appropriate variables and, in general, worry less about fitting a program on one screen (a basic unit of FORTH programming) and
advert removed
Byte August 1980 Editorial page 132
more about making it readable.
However, drawing a comparison to APL, any language that compresses a lot of program into a small number of lines suffers from readability problems. Broad, powerful algorithms often represent complex processes; when they are described in a terse notation, they look like programming tricks. In this case, the only remedy is to use a lot of comments. The lack of such comments is solely the fault of the programmer, not of the computer language.
• FORTH lacks many of the programming constructs we are used to—strings, arrays, floating-point numbers—but that's not the whole story. Many applications, for example, can get by without floating-point numbers: look at the number of programs written in Integer BASIC for the Apple II. With a maximum absolute numeric value of 32,767, normal FORTH can handle many problems by simply assuming a decimal point. In addition, all versions of FORTH can add all these features and more, simply by defining new words. For example, MMSFORTH, a version of  FORTH for  the TRS-80
by Miller Microcomputer Services, has over ten screens (each screen is 16 lines of source code) that implement their version of words for double-precision math, arrays, strings, random numbers, and TRS-80 graphics. You compile a series of screens, thus adding to the size of your resident FORTH interpreter, only if you need these features. So you can have all these programming constructs and tools, but only if you write them yourself or get somebody else to write them for you.

Friends of FORTH
Almost everyone who is working in FORTH professionally is doing good work, but a few people or groups of people deserve special mention. Foremost in this group is Charles H Moore and, through him, the company FORTH Inc. Moore developed the language over a long period of time (see his article "The Evolution of FORTH, an Unusual Language," on page 76) and promoted it through his company FORTH Inc. Elizabeth Rather, who contributed significantly to the development of
the language and who is vice-president at FORTH Inc, should also be mentioned in this context.
Then there is the FORTH Interest Group (POB 1105, San Carlos CA 94070), without whose efforts low-cost versions of FORTH would not be available. Although many people in the group have contributed to its working, names that must be mentioned are Bill Ragsdale (coordinator), Dave Boulton, Kim Harris, John James, and George Maverick. Over the past two years, this group has collectively raised its membership from a few dozen people in northern California to over a thousand members worldwide. In the process, they have also publicized FORTH at numerous conventions and have distributed public-domain versions of FORTH (called fig-FORTH) for all the major microprocessors; ie: 8080, 6800, 6502, 9900, PACE, and LSI-11. Although they supply only listings and documentation, versions customized for various popular microcomputers are available inexpensively. In addition, they are working on standardizing certain extensions to FORTH (floating-point numbers, arrays, etc), and they publish a very professional-looking bimonthly magazine called FORTH Dimensions. The group has monthly meetings at the Liberty House Department Store in Hayward, California, on (what else?) the fourth Saturday of each month. Membership in the FORTH Interest Group (which includes a subscription to its magazine) is $12 per year, $15 overseas.
A final group that must be mentioned is Miller Microcomputer Services of Natick, Massachusetts, which sells and supports a version of FORTH, called MMSFORTH, and other related FORTH products for the Radio Shack TRS-80 Model I. Not only do they provide a fine version of FORTH with arrays, strings, graphics, and other extensions, they are the only microcomputer-FORTH vendor that supports its product with both information and new vocabularies of FORTH words. (For example, they have a set of FORTH words that add 6- and 15-digit floating-point arithmetic, complex numbers, and a full Z80 assembler, all for $29.95.) They also publish an MMSFORTH Newsletter that always has some goodies you'd expect to
advert removed
Byte August 1980 Editorial page 134
pay money for. The people at MMSFORTH are A Richard (Dick) Miller and Judy Miller, along with free-lance programmer Tom Dowling, who wrote MMSFORTH for the TRS-80.
In addition, the major vendors of FORTH should be commended for the way they have worked and are working together to help standardize the language. The people mentioned above, along with the European FORTH Users' Group (EFUG), have met as the International FORTH Standards Team to work out a standard set of FORTH words (with standard behavior) that can be used to increase the already high portability of FORTH programs. Once the proposed FORTH-79 standard is approved by this standards team, FORTH Inc, the FORTH Interest Group, and Miller Microcomputer Services have indicated that they will bring out new FORTH versions conforming to this standard.

Variants of FORTH
A few other FORTH-like languages should be mentioned here. URTH (University of Rochester Threaded language)
is simply FORTH by another name. I am told that CONVERS, an experimental language that was offered by the Digital Group, is a FORTH-like language.
STOIC is a language that is different from FORTH primarily in some small syntax rules, although its enthusiasts claim it is more powerful than FORTH. From reading the documentation, I have found that STOIC interacts differently and has more sophisticated disk access than FORTH. CP/M Users Group (1651 Third Ave, New York NY 10028) distributes STOIC on two 8-inch single-density CP/M floppy disks; the cost is $20, which includes postage, documentation (on CP/M DOC files), and group membership fees. STOIC was developed by Roger G Mark and Stephen K Burns in the Biomedical Engineering Center for Clinical Instrumentation, funded by the Harvard-MIT Program in Health Sciences and Technology in Cambridge, Massachusetts.
Also, I am very excited about a book nearing publication: Threaded Interpretive Languages by Ron Loeliger. This book, to be published soon by BYTE Books, delves deeper into the practical
aspects of designing and implementing a threaded language than any book I have seen. Not only does it demonstrate exactly how the machine code must work, it also details the specific implementation of ZIP (which looks like FORTH under another name) in Z80 assembly language. The book promises to be the definitive work on how threaded languages perform.

Final Notes
As we received more and more FORTH articles, I realized that we would soon have too many for this special August issue. I immediately scheduled for subsequent nontheme issues those extra articles we could not use at this time, a process known as "holding down the FORTH." In any case, we have several FORTH articles that will appear in upcoming issues of BYTE. These include an article on recursion in FORTH by George Flammer, a tutorial on string-manipulating FORTH words by John Cassady, a history of the FORTH Standards Team by Bill Ragsdale, and a detailed discussion of the different kinds of threaded codes by Terry Ritter and Gregory Walker.
We hope you will enjoy looking at the FORTH tapestry presented in this issue.

Articles Policy..

removed of no relevance today
advert removed
Byte August 1980 Cover    Byte August 1980 page 6    Byte August 1980 page

Byte August 1980 page 10    Byte August 1980 page 128    Byte August 1980 page 130

Byte August 1980 page 132    Byte August 1980 page 134