Copyright 1984 by ABComputing May 15, 1984 ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Venture FORTH º º º º by º º º º Guy Kelly º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Introduction ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Hardware + Software = "Usefulware" If you are reading this, then very probably your hardware is an IBM-PC or compatible personal computer. I deduce from this that the hardware part of our equation is determined, and the item of interest is the software. The software component of "usefulware" comes from: (1) buying it, or (2), writing it. The other option, piracy, is NOT to be considered! If you can buy software, why are you reading this column? Still here? Good! Perhaps you are considering writing software. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Hidden Compromises ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ What environment are you going to use to write software? (Notice I said environment, not programming language.) Software developers traditionally select a language that is most suitable (read: most popular, most glamorous, most inexpensive, etc.) and, most importantly, one that is available for their hardware and operating system. The hidden problem with this approach is that you are stuck with design decisions as to the features supported by the language and the operating system. Your programming environment is totally predetermined. So what? Suppose you have a great idea for some "usefulware" but the operating system hampers your access to the hardware, and the programming language doesn't support the data structures that you require. This is not unusual! Try to develop the equivalent of the Microsoft Flight Simulator package using DOS calls and BASIC/Pascal/APL/LISP/Ada etc! What to do? How about C/FORTH/Assembly? Let's try developing an expert system, such as G.E. did, for diagnosing problems with diesel locomotives. A different sort of problem entirely, but would you want to use BASIC/Pascal/APL/Ada/C/Assembler? Probably not. What about PROLOG/LISP? FORTH was the choice G.E. made when they wrote this program, which runs on a PDP 11/23 system. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ The FORTH Environment ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ A traditional FORTH system is more than a language. It is a complete programming environment which is extensible both outwardly and inwardly! Outward extension is accomplished by building an application language on top of the FORTH system, and then using the new language to add application layers on top of the new environment. Inward extensibility is accomplished by modifying the structure/capability/features of the FORTH environment - a process called meta-compilation, i.e., letting FORTH re-compile a new version of itself. A not too difficult task, as most of FORTH is written in FORTH, with the remainder written using the FORTH assembler. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ The FORTH Environment is: ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³ ³ ³ an operating system, ³ ³ an editor, ³ ³ an assembler, ³ ³ an interpreter, ³ ³ a compiler, ³ ³ a high-level language, ³ ³ a set of development tools, ³ ³ a stack-oriented, traditionally 16-bit machine, and ³ ³ has simple virtual memory management. ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Design Decisions ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ As in other programming environments, FORTH is based on a series of design decisions concerning the interactions between the programmer and the computer. The unique set of decisions, made essentially by one man, have created the unique programming environment which is FORTH. Some of the guiding rules in the design of FORTH were: ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Rule 1. Keep it simple! º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ The whole environment is understandable and modifiable by one person. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Rule 2. Keep it small! º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ The whole environment can reside in under 16K of computer memory. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Rule 3. Keep it fast! º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Provide an integrated, structured, conditional macro assembler. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Rule 4. Make it transportable! º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ FORTH has been put on almost every piece of computer hardware known. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ FORTH Applications ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ FORTH is best known for its use at Astronomical Observatories, in process control, and in laboratory instrumentation. It has also been used as a systems implementation language by Atari for video games, and by a diverse group of companies for many applications. There is even a commercially available FORTH package that compares favorably with the better program-generating database languages. FORTH has been used to write BASIC, Pascal, LISP, LOGO, COBOL, and FORTH processors, database systems, expert systems and control systems. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Origins of the FORTH ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The best source of information on the origins of FORTH is contained in Vol. 1, No. 6 of "FORTH Dimensions," pp. 60-75. The article "FORTH The Last Ten Years And The Next Two Weeks --- " is a printed version of a speech given at the October 1979, FORTH Convention in San Francisco. The speech was given by Charles H. Moore, the inventor of FORTH. In brief, Mr. Moore, in the early 60's, became dissatisfied with the available programming systems and began experimenting with a variety of aspects of the programming environment. By about 1969 he had put together most of the elements of what is now FORTH. He states, on page 72: "My original goal was to write more than 40 programs in my life. I think that I have increased my throughput by a factor of 10. I don't think that throughput is program-language limited any longer, so I have accomplished what I set out to do." The name was chosen to indicate a "fourth" generation language running on the then "third" generation hardware. It was spelled FORTH because the file system would allow only five-character names, and because, as is true in most file systems, case is disregarded. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ History ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ FORTH has followed several paths to its present state. Path 1. Mr. Moore had completed the first version of FORTH at the National Radio Astronomy Observatory. From this observatory, FORTH spread to Kitt Peak Observatory, and from there throughout the world of Astronomy until, in 1976, it was made a standard language for the International Astronomical Union. Path 2. In approximately 1969, Charles Moore and Elizabeth Rather started FORTH, Inc., which produced miniFORTH, then microFORTH, and eventually polyFORTH and polyFORTH II. Path 3. Dr. Hans Nieuwenhuijzen, and others at the State University at Utrecht in the Netherlands, learned of FORTH. They produced a variety of enhancements and applications and helped organize the European FORTH Users Group. Path 4. Bill Ragsdale and others in the San Francisco Bay became involved with FORTH and formed the FORTH Interest Group (FIG). They produced a FORTH newsletter named FORTH Dimensions, and public domain versions of FORTH for five different microcomputers and the DEC PDP11. Vol. 5, No. 6, of FORTH Dimensions, pp. 20 - 25, details the formation and activities of FIG. Path 5. FORTH, Inc., the European group, and the Astronomical users joined to produce a 1977 set of standard FORTH words. (A word in FORTH corresponds to a procedure or subroutine in other languages.) FIG became involved in 1978 and an updated set of standard words was produced that year. The Astronomical users then left the standardization efforts. In 1979, a charter was proposed and the FORTH Standards Teams was formed. A 1979 Standard for FORTH was developed to include the "new" 8-bit machines. The European group then left the standards team and a group of FORTH vendors joined the efforts. This changed the makeup of the group from predominately users to a more equal mix of users and vendors. In 1982, meetings of the FORTH Standards Team were conducted to update the 1979 Standard. The updates were so comprehensive that in 1983 a new standard was released. The 1983 Standard is scheduled for update in 1988. Path 6. Around 1978, several vendors licensed microFORTH from FORTH, Inc., and started selling their own versions. Later, in about 1978-79 (after the release of the public domain figFORTH), a variety of vendors sold enhanced versions of figFORTH, then 79 Standard versions, and now the 83 Standard version. The conclusion to be drawn is that there are many FORTHs available today, some based on figFORTH, some meeting earlier standards, and some meeting the 83 standard. Compatibility between FORTH versions can be a problem but it is impossible to avoid in an evolving language. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Information Sources ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The best source of FORTH literature is Mountain View Press,Inc., P.O. Box 4656, Mountain View, CA 94040, (415)961-4103. Their advertisements in Byte magazine, Dr. Dobbs Journal, and FORTH Dimensions list at least fifteen books on FORTH, as well as a variety of conference proceedings and user manuals. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Books ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ One of the best books on FORTH is "Starting FORTH" by Leo Brodie, published by Prentice-Hall. It is well written, contains tutorial examples, and several useful mini-applications. The version of FORTH that it describes is a modified polyFORTH with references to figFORTH and to 79 Standard FORTH. Another contender for best FORTH book is "FORTH Tools" by Anita Anderson and Martin Tracy, published by MicroMotion, 12077 Wilshire Blvd., Los Angeles, CA 90025, (213)821-4340. It, too, is well written and has the advantage of describing an 83 Standard version of FORTH which is very similar to two of the 1983 Standard public domain FORTHs. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ FORTH Magazines ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ There are two magazines devoted exclusively to FORTH: "FORTH Dimensions," published by the FORTH Interest Group (P.O. Box 1105, San Carlos, CA 94070), and "The Journal of FORTH Applications and Research," published by the Institute for Applied FORTH Research, Inc., (P.O. Box 27686, Rochester, NY, 14627). A six-issue subscription to FORTH Dimensions is $15.00. Another magazine which publishes many articles on FORTH, and an annual issue devoted to FORTH, is Dr. Dobbs Journal. For those who are technically oriented, an excellent article to read is "An Architectural Trail to Threaded-Code Systems" by Peter M. Kogge, IBM Federal Systems Division. It was published in IEEE Computer, March 1982, pp. 22 - 32. This article builds a logical picture of a FORTH system, and contains only one minor understatement: "threaded-code systems should find a secure niche where small-to-moderate specialized interactive application packages, real-time control of external devices and sensors, and engineering-type throw-away code dominate." Companies such as G.E., with their expert system, Cubic Western Data with a 2000 screen Navigational package, Computer Software Design with the Data Ace (a comprehensive database development package), and several other companies with 5000 screens (5 Megabytes of source code) or larger business applications have exceeded the "small-to-moderate" size mentioned. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ FORTH Meetings ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ There are two annual FORTH meetings: (1) The FORML (FORTH Modification Laboratories) conference at the Asilomar Conference Center at Pacific Grove Ca., in November and (2) the Rochester FORTH Applications Conference in June at the University of Rochester, in Rochester, NY. There are also regional FIG meetings, usually held monthly, in 47 cities around the world. If you are interested in attending one of these meetings, call the FIG hot-line at (415) 962-8653 for information about the nearest one. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Other ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ You may have noticed that the word "FORTH" has been used as a proper name and as an acronym. I have tried to use the same form as used by the various vendors and publishers. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Until Next Time ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Having mentioned the glittering generalities, in our next column we discuss the specifics of the FORTH programming environment and provide examples of FORTH applications and code. So, as Henry Laxen says, "May the FORTH be with you." ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ File Name: ÛÛ forth1.txt ÛÛ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ