FOCAL is notable as the language in which the original versions of the early video games Hamurabi and Lunar Lander were written.
JOHNNIAC was decommissioned in 1966 and JOSS was reimplemented on a newly purchased PDP-6, Digital Equipment Corporation's (DEC) first "big" machine.
Written by Richard Merrill, FOCAL removed features from JOSS as required in order to be able to run in the much more limited memory space of the PDP-8 and other 12-bit machines in the DEC lineup.
To achieve this, a major change was made to reduce the amount of temporary data, or state, needed to parse the statements.
This simplified the parser, which needed to read only the first letter of the command on a line of code, and could then skip forward to the next whitespace character.
Processor Technology also offered a version of 8k FOCAL, complete with Lunar Lander, for the Intel 8080-based Altair 8800 system.
By the late 1960s, several companies were making inroads in DEC's minicomputer stronghold, selling similar machines running time-sharing versions of BASIC.
[6] David H. Ahl had recently joined DEC's PDP-8 Group, just as the company became interested in selling the machine into educational settings.
FOCAL was fighting an uphill battle against BASIC, which was available on GE, Honeywell, HP, and other computers.I think it wound up with a situation like Sony and Betamax.
Combining his ports with submissions from outside programmers, he managed to collect enough material to have DEC publish 101 BASIC Computer Games in 1973.
FOCAL lacked this capability, so those instructions that needed to be loaded and saved became options on other program-mode commands like Type.
The original manual lists CONTINUE as a synonym of COMMENT, used to mark empty lines, but this has no internal difference.
[14] A sample FOR loop: The GOTO command (abbreviation G) jumps program execution to the specified line number.
For example, the following code sample from FOCAL: A New Conversational Language[25] refers to the same variable as DESTINATION and then DES.
The LIBRARY command (abbreviation L) had the following sub-commands: FOCAL-71 added: Since the interpreter lacked sufficient memory space to store error messages, or even a table of error numbers, FOCAL used a workaround by reporting the address of the error-detecting code as a fixed-point number.
FOCAL,1969 was largely identical to the original, but FOCAL,1971 was major update that added file handling, new mathematics, and a variety of other changes.
FOCAL is, for all intents, a cleaned-up version of JOSS with changes to make the syntax terser and easier to parse.
In contrast, FOCAL lacked the ability to compare values, and loops were applied by skipping to the next line when they completed.
This flexibility comes at a cost; in FOCAL the start, stop, and step can be written in a custom in-memory structure and easily updated as the loop is performed, whereas JOSS requires it to reevaluate an expression that may be, but often isn't, more complex.
Command keywords were also shortened where possible, so JOSS' Demand becomes FOCAL's ASK, both to make it shorter and to allow the letter D to be uniquely used for DO.
For example, to ask a user to input a value, in FOCAL one would: while in BASIC the equivalent is: With the exception of a few features that were missing from one or the other, and some relatively minor differences in syntax, the two languages are very similar.
One notable exception is the IF in BASIC, which allowed any statement to be placed after the THEN, making it more similar with JOSS' control structures.
Another major difference between the two is that FOCAL lacked inherent support for strings as data elements that could be assigned to variables.
For example, if one typed HELLO at an input statement, FOCAL would convert the H to "8", the numeric value of "H" in the PDP-8's six-bit character codes ("H" is the eighth letter).
It would then interpret the "E" as starting an exponent, then it would try to compute "8" to the "LLO" power, which would take several seconds of CPU time and result in a value of 0.76593020E+103, not a helpful response.
This high precision, and good choices for default decimal output formatting, meant that difficulties with binary-to-decimal rounding were not evident to beginning users.
On a typical machine of the day, often with 6 to 24 kilobytes of magnetic-core memory, FOCAL could handle larger and more complex programming tasks than BASIC.
There were even major enhanced offshoots of FOCAL, such as FOCAL-W, which added many features, including better mass storage file I/O and even virtual variable memory.
The original Lunar Lander makes an excellent example for examining FOCAL code, as it uses most of the features of the language.
Line 03.40 tests to see if the amount of fuel burned this period, S*K, will reduce the mass of the vehicle as a whole, S*K-M, beyond the empty weight, N. If not, it moves on, if it will, it instead sets the loop timer to the amount of time the remaining fuel will burn, thus ending the loop early.