WSFN (programming language)

Last updated

WSFN (Which Stands for Nothing) [1] is an interpreted programming language for controlling robots created by Li-Chen Wang. It was designed to be as small as possible, a "tiny" language, [2] similar to Wang's earlier effort, Palo Alto Tiny BASIC. [3] [4] WSFN was first published in Dr. Dobb's Journal in September 1977.

Contents

The language consists primarily of single-letter commands to tell a robot to move in certain directions, while other commands perform tests or basic mathematical operations. These can be grouped into named macros to produce more complex programs. The original version also included code that simulated the robot as a cursor on the VDM-1 display, or graphically on a Cromemco Dazzler display. This is similar to the turtle graphics added to the Logo programming language in 1969.

Extended WSFN is an implementation created for the Atari 8-bit family of home computers written by Harry Stewart and published by the Atari Program Exchange [5] in 1981. In addition to supporting turtle graphics, it adds a number of commands to control the graphics and sound capabilities of that platform. It was offered as a "beginner's language with emphasis on graphics".[ citation needed ]

Syntax

WSFN consists of a number of single-letter commands to control the movement of a turtle or robot. Any of these commands can be repeated by prefixing it with a number. [2] For instance, F moves the turtle Forward one step, while 25F moves 25 steps. R and L make the turtle turn one unit to the Right or Left, respectively, and it can also be reset to point North. The step sizes and turn units are defined by the robot hardware, but are set to one pixel and 45 degrees in the turtle graphics versions. Missing in the robot versions, in the computer versions H returns the turtle Home in the center of the screen and C Clears any previous drawing. Thus, one can draw a square with the string: [6]

BCWHN25F2R25F2R25F2R25F

These instructions set the drawing color to Black, Clears the screen (which fills with the current color), sets the color to White, Homes the turtle, resets the turtle to point North, then draws a series of four lines 25 steps long, rotating 90 degrees to the Right between each line. The result is a white square with its lower-left corner in the center of the screen. [6]

Lists of commands can be surrounded with parentheses to create macros. For instance, the same square can be drawn by placing the code to draw one side of the square inside the parentheses, and then calling it four times: [6]

BCWHN4(25F2R)

Macros can be called within other macros. For instance, this code draws a series of eight squares, each offset by 45 degrees, rotating around the center of the screen: [6]

BCWHN8(4(25F2R)R)

Macros can be assigned a name using the Define command (Extended WSFN used = instead). This code defines a macro named "X" to clear the screen and reset the drawing, and another "Z" that draws a square. It then uses these to draw the same rotating square as the example above: [7]

DX(BCWHN) DZ4(25F2R) X8(ZR)

WSFN has rudimentary math capabilities consisting of a single accumulator A that can be incremented and decremented with + and -. The letter A can be placed anywhere a number could appear. One can make the series of squares grow larger by incrementing the accumulator 5 times between each step: [2]

DX(BCWHN) 25A DZ4(AF2R) X8(Z5+AR)

A side-effect of the syntax is that A- would set the accumulator to zero, because it performs the decrement instruction by the number in A. Likewise, A+ doubles the value in the accumulator. [2]

Program control is equally rudimentary, consisting of a number of commands that handled IF/THEN/ELSE structures. The most basic form is the Test command, which follows one of two paths if the accumulator was greater or equal to zero. For instance, this command causes the turtle to turn 90 degrees left if the accumulator is non-zero, or 45 to the right if it is zero: [2]

T(2L)R

Variations on the T branching construct include ?, which randomly jumps to the first or second branch 50% of the time, and Sensor, which tests if the contact sensor on the robot has been triggered. [8] Extended WSFN modified the S to return the color in front of the turtle, allowing hit detection on previous drawing, and added the Edge test, which jumps to the right side macro if the turtle hit the edge of the drawing area. [9] The original WSFN lacks an equivalent of E, and instead wraps the drawing area so the turtle re-appears on the opposite side of the screen. [2] Extended WSFN supports this style of playfield wrapping as an option. [10]

Because it uses one-letter commands and recursive syntax, WSFN code is exceedingly cryptic. For example, this is a WSFN program to draw Sierpiński curves: [11]

DIT(-I2FI5RG5RI2FI+)2R DG4F DY (HN63F2R61FRC4 (2FI))

Note that the definition of the macro "I" includes calls to I within it. This is a key aspect of the WSFN concept; the language is highly recursive in nature, which makes programming self-similar patterns like fractals easy to accomplish in a few lines of code. [11]

A key concept of Extended WSFN is that the keyboard is always active, even while macros are running. This allows keyboard input to interrupt running programs. Using this technique, one can make macros for moving the turtle in certain ways, assign them to letters on the keyboard, and then perform these movements by pressing different keys in succession. This can be aided by adding the Wait command in places to give the user time to respond as the drawing takes place. [12]

Keywords

From the original Dr. Dobbs article. [13]

WSFN keywords
KeywordDescription
ALoops by the value of the accumulator (A- sets it to zero, A+ doubles it)
BSet the drawing color to black
CClear screen (fill with current color)
DDefine macro
FMove the turtle forward
HReturn the turtle to the home position
LRotate the turtle to the left
NPoint the turtle north (up)
RRotate the turtle to the right
STest contact sensor on the robot (IF/THEN/ELSE)
TTest for non-zero accumulator (IF/THEN/ELSE)
WSet the drawing color to white
=Define a macro name
 ?Random test, like T but follows each branch 50% of the time
+Increment accumulator
-Decrement accumulator

From the Extended WSFN manual. [14]

Additional/Redefined Extended WSFN keywords
KeywordDescription
BBeep
DPen down
ETests if the turtle is at the screen edge
PSet the pen color to the value in the accumulator
SSet the accumulator to the color in front of the turtle (Sense, as in the original version)
UPen up
WWait one jiffy (130 of a second)
=Define macro
=#Define variable
#Loops by the value in a variable
*Adding * to the directional commands, *L or *R, changed the angle to 22.5 degrees instead of 45
$Test joystick against selected direction (IF/THEN/ELSE)
 %Read value of paddle controller into accumulator
&Write value in accumulator to selected color register
 ;Read the direction of the turtle, 0 through 7, into the accumulator
@Set the accumulator to zero (same as A- in WSFN)

Related Research Articles

<span class="mw-page-title-main">Logo (programming language)</span> Computer programming language

Logo is an educational programming language, designed in 1967 by Wally Feurzeig, Seymour Papert, and Cynthia Solomon. Logo is not an acronym: the name was coined by Feurzeig while he was at Bolt, Beranek and Newman, and derives from the Greek logos, meaning word or thought.

Tiny BASIC is a family of dialects of the BASIC programming language that can fit into 4 or fewer KBs of memory. Tiny BASIC was designed by Dennis Allison and the People's Computer Company (PCC) in response to the open letter published by Bill Gates complaining about users pirating Altair BASIC, which sold for $150. Tiny BASIC was intended to be a completely free version of BASIC that would run on the same early microcomputers.

<span class="mw-page-title-main">Li-Chen Wang</span> American computer programmer (born 1935)

Li-Chen Wang is an American computer engineer, best known for his Palo Alto Tiny BASIC for Intel 8080-based microcomputers. He was a member of the Homebrew Computer Club and made significant contributions to the software for early microcomputer systems from Tandy Corporation and Cromemco. He made early use of the word copyleft, in Palo Alto Tiny BASIC's distribution notice "@COPYLEFT ALL WRONGS RESERVED" in June 1976.

GRASS is a programming language created to script 2D vector graphics animations. GRASS was similar to BASIC in syntax, but added numerous instructions for specifying 2D object animation, including scaling, translation and rotation over time. These functions were directly supported by the Vector General 3D graphics terminal GRASS was written for. It quickly became a hit with the artistic community who were experimenting with the new medium of computer graphics, and is most famous for its use by Larry Cuba to create the original "attacking the Death Star will not be easy" animation in Star Wars (1977).

<span class="mw-page-title-main">Bally Astrocade</span>

The Bally Astrocade is a second-generation home video game console and simple computer system designed by a team at Midway, at that time the videogame division of Bally. It was originally announced as the "Bally Home Library Computer" in October 1977 and initially made available for mail order in December 1977. But due to production delays, the units were first released to stores in April 1978 and its branding changed to "Bally Professional Arcade". It was marketed only for a limited time before Bally decided to exit the market. The rights were later picked up by a third-party company, who re-released it and sold it until around 1984. The Astrocade is particularly notable for its very powerful graphics capabilities for the time of release, and for the difficulty in accessing those capabilities.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with Atari 8-bit computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays.

Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first version of BASIC published by Microsoft as well as the first high-level programming language available for the Altair 8800 microcomputer.

In computer graphics, turtle graphics are vector graphics using a relative cursor upon a Cartesian plane. Turtle graphics is a key feature of the Logo programming language.

<span class="mw-page-title-main">ATASCII</span> Character encoding used by the Atari 8-bit home computers

The ATASCII character set, from ATARI Standard Code for Information Interchange, alternatively ATARI ASCII, is a character encoding used in the Atari 8-bit home computers. ATASCII is based on ASCII, but is not fully compatible with it.

<span class="mw-page-title-main">Vilnius BASIC</span> Dialect of the BASIC programming language

Vilnius BASIC, sometimes known as BK BASIC, is a dialect of the BASIC programming language running on the Elektronika BK-0010-01/BK-0011M and UKNC computers. It was developed at Vilnius University, located in Lithuania which was a republic of the Soviet Union at the time.

BASIC 8 – "The Enhanced Graphics System For The C128" – was an American-designed graphics system developed by Walrusoft of Gainesville, Florida and published in 1986 by Patech Software of Somerset, New Jersey. The system was an extension of Commodore's BASIC 7.0 for the Commodore 128 computer. BASIC 8.0 provided commands lacking in BASIC 7.0 to generate (color) graphics in the C128's high-resolution 80-column mode for RGB monitors.

Optimized Systems Software (OSS) was a company that produced disk operating systems, programming languages with integrated development environments, and applications primarily for Atari 8-bit computers. The founders of OSS previously developed Atari DOS, Atari BASIC, and the Atari Assembler Editor for Atari, Inc., and many OSS products are substantially improved versions. OS A+ and DOS XL are based on Atari DOS. BASIC A+, BASIC XL, and BASIC XE are based on Atari BASIC. EASMD and MAC/65 are modeled on the Atari Assembler Editor. Action! is an ALGOL-inspired compiled programming language with an integrated full-screen editor. OSS also sold some software for the Apple II.

Atari Assembler Editor is a ROM cartridge-based development system released by Atari, Inc. in 1981. It is used to edit, assemble, and debug 6502 programs for Atari 8-bit computers without the need for additional tools. It was programmed by Kathleen O'Brien of Shepardson Microsystems, the company which wrote Atari BASIC, and Assembler Editor shares many design concepts with that language implementation.

<span class="mw-page-title-main">Simons' BASIC</span>

Simons' BASIC is an extension to BASIC 2.0 for the Commodore 64 home computer. Written by British programmer David Simons in 1983, who was 16 years old at the time, it was distributed by Commodore as a cartridge.

<span class="mw-page-title-main">Atari 8-bit computer software</span>

Many games, utilities, and educational programs were available for Atari 8-bit computers. Atari, Inc. was primarily the publisher following the launch of the Atari 400/800 in 1979, then increasingly by third parties. Atari also distributed "user written" software through the Atari Program Exchange from 1981 to 1984. After APX folded, many titles were picked up by Antic Software.

Level I BASIC is a dialect of the BASIC programming language that shipped with the first TRS-80, the TRS-80 Model I.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

Wang BASIC is a series of BASIC programming languages for computers from Wang Laboratories. The term can be used to refer to the BASIC on any Wang machine, but is mostly associated with the versions on the Wang 2200 minicomputer series of the early 1970s. When these machines were updated to the VP series in 1976, BASIC-2 was introduced and remained the pattern for future machines in the 2200 series. A planned BASIC-3 was never released.

References

  1. The Blue Book for the Atari Computer. WIDL Video. 1983. ISBN   9780684179216.
  2. 1 2 3 4 5 6 Wang 1977, p. 334.
  3. Wang, Li-Chen (May 1976). "Palo Alto Tiny BASIC". Dr. Dobb's Journal. 1 (5): 12–25.
  4. Rauskolb, Robert (December 1976). "Dr. Wang's Palo Alto Tiny BASIC" (PDF). Interface Age. pp. 92–108.
  5. APX listing at atariarchives.org
  6. 1 2 3 4 Stewart 1982, p. 4.
  7. Wang 1977, p. 345.
  8. Wang 1977, p. 334,335.
  9. Stewart 1982, p. 10.
  10. Stewart 1982, p. 3.
  11. 1 2 Wang 1977, p. 336.
  12. Stewart 1982, p. 5.
  13. Wang 1977.
  14. Stewart 1982.

Bibliography