Safekipedia

Forth (programming language)

Adapted from Wikipedia ยท Discoverer experience

Forth is a special kind of programming language made by Charles H. "Chuck" Moore in 1970. It is different from many other languages because it works with something called a stack to move information between parts of a program. People can create, test, and change these parts, called words, without needing to restart the whole program.

This language is very small and simple, which made it useful for old computers that did not have much memory. Even today, Forth is used in places where it needs to talk directly to hardware, like in space tools such as the Philae spacecraft_ and in computer start-up systems.

Over time, many different versions of Forth were made for various uses. One famous use was in the popular 1986 video game Starflight made by Electronic Arts. Chuck Moore also made tiny computers that could run Forth directly, helping him with projects like designing new chips.

Uses

Forth is used in special areas like space and astronomy, as well as in small computers and machines. The boot-up software used by Apple, IBM, Sun, and OLPC XO-1 includes a Forth environment.

Forth was often used to get new computers ready to work. It was the first software inside the new Intel 8086 chip in 1978, and MacFORTH was the first development system for the Macintosh 128K in 1984.

Around 1982, Atari, Inc. used a fancy animated show written in Forth to display the power of the Atari 8-bit computers in stores. Electronic Arts made several video games in the 1980s using Forth, such as Worms?, Adventure Construction Set, Amnesia, Starflight, and Lords of Conquest. The robot coding game ChipWits (1984) was made in MacFORTH for the Macintosh 128K, and the version for the Commodore 64 was written with SuperForth 64.

Ashton-Tate's RapidFile (1986), a simple database program, and VP-Planner from Paperback Software International (1983), a spreadsheet program, were also written in Forth.

The Canon Cat (1987) used Forth for its system work.

Rockwell made single-chip computers with Forth built-in: the R65F11 and R65F12.

ASYST was a Forth tool for measuring and controlling on PCs.

History

Forth started as a personal programming system created by Charles H. Moore. It was first shown to other programmers in the early 1970s by Elizabeth Rather at the United States National Radio Astronomy Observatory. In 1973, Moore and Rather formed FORTH, Inc., and spent the next ten years improving and adapting Forth for many different computers.

Forth was designed to work well with early computers that had very little memory. It became popular in the 1980s because it was easy to use and could run on many types of machines. Two common versions, FORTH-79 and FORTH-83, helped make the language more consistent. In 1994, these versions were combined into a standard called ANS Forth.

Overview

Further information: Reverse Polish notation

Forth is a programming language that uses small, simple functions called words. These words work together to build bigger tasks, much like building blocks. Programs in Forth are made by stacking these words, which makes the code easy to understand and test.

Forth uses a special way of writing math problems called reverse Polish notation. In this method, the operation comes after the numbers, like writing "25 10 ร—" instead of "(25 ร— 10)". This makes it easier for computers to process the commands. For example, to calculate (25 ร— 10) + 50 in Forth, you would write:

25 10 * 50 + CR . 300 ok

This means: put 25 and 10 on the stack, multiply them, then add 50, and show the result, which is 300.

Forth can also print messages. For example, this code prints "Hello, World!" on a new line:

: FLOOR5 ( n -- n' ) DUP 6 Hello, World!

The word CR makes the next text start on a new line. You can type commands directly into Forth to see them work right away.

Forth engines

A processor made to work with a certain programming language is called a language "engine."

Forth engines are special hardware made just for creating and running programs written in Forth. The first chip you could buy that did this was the Rockwell R65F11. It had a basic part of Forth inside it, along with an enhanced 6502, memory space, and other parts that usually needed extra chips. Many other ready-to-buy and homemade computers were also made to run Forth quickly, often turning common Forth actions into single steps.

Implementations

Forth is easy to use and doesn't have one main version, so many different kinds of Forth exist. These versions work on regular computers like POSIX, Microsoft Windows, and macOS, as well as on special small systems used in machines and devices, known as embedded systems. Some of these versions follow the rules set in 1994 for ANS Forth.

Some of these systems include ASYST for collecting and studying data, Gforth from the GNU Project, noForth for small Flash microcontrollers, Open Firmware used to start up and manage computers, pForth written in the C language, and several others like SP-Forth, Swift Forth, VFX Forth, Firth, and Shi.

Related articles

This article is a child-friendly adaptation of the Wikipedia article on Forth (programming language), available under CC BY-SA 4.0.