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

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with the Apple II series of computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC because of the Apple DOS command used to invoke it, instead of INT for Integer BASIC.

Logo (programming language) 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.

troff, short for "typesetter roff", is the major component of a document processing system developed by AT&T Corporation for the Unix operating system. troff and the related nroff were both developed from the original roff.

L-system Rewriting system and type of formal grammar

An L-system or Lindenmayer system is a parallel rewriting system and a type of formal grammar. An L-system consists of an alphabet of symbols that can be used to make strings, a collection of production rules that expand each symbol into some larger string of symbols, an initial "axiom" string from which to begin construction, and a mechanism for translating the generated strings into geometric structures. L-systems were introduced and developed in 1968 by Aristid Lindenmayer, a Hungarian theoretical biologist and botanist at the University of Utrecht. Lindenmayer used L-systems to describe the behaviour of plant cells and to model the growth processes of plant development. L-systems have also been used to model the morphology of a variety of organisms and can be used to generate self-similar fractals.

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 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.

Li-Chen Wang 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).

Atari BASIC

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most 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, for example.

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.

Graphics BASIC is a third-party extension to the Commodore BASIC V2.0 programming language of the Commodore 64 computer. It was originally written in 1983 by Ron Gilbert and Tom McFarlane. The program was licensed to Hesware, who briefly sold the program in 1984 as part of their product line before going out of business. The program was later extended by Ken Rose and Jack Thornton, and repackaged and sold in 1985 by Epyx under the title Programmers BASIC Toolkit.

Simons BASIC

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.

Acorn MOS Computer operating system

The Machine Operating System (MOS) or OS is a discontinued computer operating system (OS) used in Acorn Computers' BBC computer range. It included support for four-channel sound, graphics, file system abstraction, and digital and analogue input/output (I/O) including a daisy-chained expansion bus. The system was single-tasking, monolithic and non-reentrant.

MicroWorlds JR is a computer program using a simplified version of the Logo programming language to teach non-readers or early readers to program in Logo. It was first launched in 2004 by Logo Computer Systems, Inc. (LCSI), and as in their original line of MicroWorlds programs, the object on the screen begins as a turtle and can be controlled with basic commands to make it move. Differing from the Logo syntax developed by Seymour Papert and teams at MIT, MicroWorlds JR uses images to replace the command names, which are selected by the child to create turtle graphics. The turtle object can be given a variety of shapes that act as a costume for the turtle, and therefore lends itself to a variety of animations and creative stories and projects for younger students.

PGF/Ti<i>k</i>Z Graphics languages

PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipses and polygons. PGF is a lower-level language, while TikZ is a set of higher-level macros that use PGF. The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost. Till Tantau is the designer of the PGF and TikZ languages. He is also the main developer of the only known interpreter for PGF and TikZ, which is written in TeX. PGF is an acronym for "Portable Graphics Format". TikZ was introduced in version 0.95 of PGF, and it is a recursive acronym for "TikZ ist kein Zeichenprogramm".

ReGIS, short for Remote Graphic Instruction Set, was a vector graphics markup language developed by Digital Equipment Corporation (DEC) for later models of their famous VT series of computer terminals. ReGIS supported rudimentary vector graphics consisting of lines, circular arcs, and similar shapes. Terminals supporting ReGIS generally allowed graphics and text to be mixed on-screen, which made construction of graphs and charts relatively easy.

Microsoft Small Basic

Microsoft Small Basic is a programming language, interpreter and associated IDE. Microsoft's simplified variant of BASIC, it is designed to help students who have learnt visual programming languages such as Scratch learn text-based programming. The associated IDE provides a simplified programming environment with functionality such as syntax highlighting, intelligent code completion, and in-editor documentation access. The language has only 14 keywords.

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

BASIC interpreter 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.

Secret Coders Series of graphic novels about coding

Secret Coders is a series of graphic novels that combines logic puzzles, basic programming instruction, and a story where a group of seventh graders uncover a secret coding school. The series is written by Gene Luen Yang, illustrated by Mike Holmes, and published by First Second Books.

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