Safekipedia

Forth (programming language)

Adapted from Wikipedia ยท Adventurer experience

Forth is a special kind of programming language made by Charles H. "Chuck" Moore in 1970. It works in a unique way by using something called a stack to move information in a program. People can create and change parts of the program, called words, without stopping and starting again.

Forth is very small and simple. This made it useful for old computers that did not have much memory. Today, Forth is still used in places where it needs to work closely with hardware, like in space tools and computer start-up systems.

Many different versions of Forth were created for many uses. One famous use was in the 1986 video game Starflight made by Electronic Arts. Chuck Moore also made tiny computers that could run Forth, which helped him with projects like designing new chips.

Uses

Forth is used in special areas like space and astronomy, and in small computers and machines. The software that starts up Apple, IBM, Sun, and OLPC XO-1 includes a Forth system.

Forth helped prepare new computers for use. 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 show written in Forth to show the power of the Atari 8-bit computers in stores. Electronic Arts made 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 parts called words. These words work together to build bigger tasks, like building blocks. Programs in Forth are made by stacking these words, which makes the code easy to understand.

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 helps computers process the commands more easily. 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 computers were made to run Forth quickly, often turning common Forth actions into single steps.

Implementations

Forth is easy to use and has many different versions. These versions work on regular computers like POSIX, Microsoft Windows, and macOS, as well as on 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.