Jump to content

WSFN (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Maury Markowitz (talk | contribs) at 22:10, 25 April 2018 (Keywords). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

WSFN (Which Stands for Nothing) was a programming language for controlling robots created by Li-Chen Wang[1] The language consisted primarily of single-letter commands to tell the robot to move in certain directions, while others performed tests or basic mathematical operations. It was first published in Dr. Dobb's Journal in September 1977.[2] This version included code that simulated the robot as a cursor on the VDM-1 display, or graphically on a Cromemco Dazzler graphics display. Today these would be known as turtle graphics. It was later translated into Japanese and published by ASCII.[1]

Extended WSFN was an implementation created for the Atari 8-bit family of home computers written by Harry Stewart and published by the Atari Program Exchange[3] in 1981.[4] In addition to supporting turtle graphics, it added 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". In this respect, it is similar to the PILOT programming language, although with additional control constructs.

Basic syntax

WSFN consisted of a number of single-letter commands to control the movement of the turtle. F would move the turtle Forward one step, while 25F would move 25 steps forward. R and L made the turtle turn one unit to the Right or Left, respectively, while it could also be pointed North. The step sizes and turn units were defined by the hardware, but were set to one pixel and 45 degrees in the turtle graphics versions. H returned it Home in the center of the screen and C Cleared any previous drawing. Thus, one could draw a square on the screen with the string:

BCWHN25F2R25F2R25F2R25F

These instructions set the color to Black and Clears the screen (to black), 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 between each one.

Lists of commands could be surrounded in parenthesis to create macros. For instance, the same square could be drawn by placing the code to draw one side of the square inside parenthesis, and the calling it four times:

BCWHN4(25F2R)

Macros could 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:

BCWHN8(4(25F2R)R)

Macros could be assigned a name using the Define command (Extended WSFN used = instead). This code defines a macro with the name "Z" and then calls it as part of a loop:

DZ4(25F2R)
BCWHN8(ZR)

WSFN had an accumulator A that can be incremented and decremented with + and -. The letter A could be placed anywhere a number would appear. So, one could make the series of squares grow larger by incrementing the accumulator 5 times between each step:

25A
DZ4(AF2R)
BCWHN8(Z5+AR)

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

T(2L)(R)

Variations in the original version include the ? which randomly jumps to the first or second branch 50% of the time, and Sensor, which tested if the contact sensor on the robot had triggered (which was simulated in the Dr.Bobbs code). Extended WSFN added the Edge test, which jumped to the right side if the turtle hit the edge of the drawing area.

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

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

Keywords

References

  1. ^ a b Li-Chen Wang Talk page at USCS ECE Wiki
  2. ^ Wang, Li-Chen, "An Interactive Programming Language for Control of Robots", Dr. Dobb's Journal, vol. 2, no. 10
  3. ^ APX listing at atariarchives.org
  4. ^ Stanford University library "Games E" collection listing