FOCAL programming language
Encyclopedia
FOCAL, is an interpreted
Interpreter (computing)
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

 programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 resembling JOSS.

Largely the creation of Richard Merrill
Richard Merrill
Richard Merrill was a Digital Equipment Corporation employee who invented the FOCAL programming language and programmed the first two interpreters for the language in 1968 and 1969, for the PDP-8...

, FOCAL was initially written for and had its largest impact on the Digital Equipment Corporation
Digital Equipment Corporation
Digital Equipment Corporation was a major American company in the computer industry and a leading vendor of computer systems, software and peripherals from the 1960s to the 1990s...

's (DEC's) PDP-8
PDP-8
The 12-bit PDP-8 was the first successful commercial minicomputer, produced by Digital Equipment Corporation in the 1960s. DEC introduced it on 22 March 1965, and sold more than 50,000 systems, the most of any computer up to that date. It was the first widely sold computer in the DEC PDP series of...

 computers. Merrill wrote the original (1968) and classic FOCAL-69
FOCAL-69
FOCAL-69 was the landmark version of the FOCAL programming language, more widely publicized than the original version of the language created in 1968...

 interpreters for the PDP-8. Digital itself described FOCAL as "a JOSS-like language."

Like early versions of BASIC
BASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....

, FOCAL was a complete programming environment in itself, requiring no operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

. As in MUMPS
MUMPS
MUMPS , or alternatively M, is a programming language created in the late 1960s, originally for use in the healthcare industry. It was designed for the production of multi-user database-driven applications...

, most commands could be, and in practice were, abbreviated to a single letter of the alphabet. Creative choices of words were used to make each command uniquely defined by its leading character. Digital made available several European-language versions in which the command words were translated into the target language.

Efficiency

FOCAL ran on very low-end PDP-8 systems, even systems with only 4K words of memory and lacking mass storage. The FOCAL interpreter was written in very tight assembly language and typically used only 3K 12-bit words, leaving a somewhat limiting 1K words to hold the user program, and variables.

If the system was upgraded by adding one or more extra 4K banks of memory, FOCAL could use that extra memory, either for a single user, or split the extra memory across several time-sharing users. FOCAL made extensive use of interrupt-driven terminal I/O, so it could keep four teleprinter
Teleprinter
A teleprinter is a electromechanical typewriter that can be used to communicate typed messages from point to point and point to multipoint over a variety of communication channels that range from a simple electrical connection, such as a pair of wires, to the use of radio and microwave as the...

s busily whirring with nary a pause.

Memory space was too precious for storing textual error messages, so FOCAL used a clever work-around: error messages instead displayed the start address of the error-managing routine as a floating-point number. For example, in the FOCAL-69 implementation the division by zero error was managed by code starting at memory address octal 4333; division by zero at a program line numbered 01.10 produced the error message ?28.73 @ 01.10, where 28.73 represents memory page 28 plus an offset of 73 words. Most FOCAL sites had an "error number to error message" listing taped up near the terminals.

Comparisons between FOCAL and BASIC were inevitable since both languages were common on smallish computers of the same era. FOCAL lacked inherent support for strings
String (computer science)
In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet....

 as data elements which could be assigned to variables. This is generally thought to be a serious deficiency as compared to the string capabilities in most BASICs. This deficiency, while serious, was not as utterly crippling as it might sound. A surprising amount of string usage in FOCAL programs is devoted to formatting user output. Since FOCAL output was character-stream-oriented, outputting two strings sequentially could sometimes substitute for concatenating them, and procedural tools could be written for performing complex formatted output.

A limited amount of string input could be done, so a program could ask simple Yes/No questions, but this was really a kludge
Kludge
A kludge is a workaround, a quick-and-dirty solution, a clumsy or inelegant, yet effective, solution to a problem, typically using parts that are cobbled together...

. For example, if you typed "HELLO" at an input statement, FOCAL would convert the H to "8", 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 particularly helpful response.

It is generally agreed that FOCAL was more efficient in its use of resources than comparable BASIC systems. On a typical machine of the day (often with 6 to 24 kilobytes of core memory), FOCAL could handle larger and more complex programming tasks than BASIC.

FOCAL's PDP-8 implementation used a floating point
Floating point
In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...

 representation that represented numbers as four 12-bit words, with thirty-six bits of mantissa and twelve bits of exponent. This allowed for both significantly higher precision and a significantly wider range of values than most other low-end programming systems, and made it a reasonable choice for serious numerical work. 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.

Spinoffs

The Coca-Cola Corporation used a customized version of FOCAL called COKE.

FOCAL was later implemented on the PDP-7/9, PDP-11, PDP-12, PDP-5 and LINC-8.

The FOCAL manual showed how to add commands to the FOCAL parser, so many sites added specialized commands for operating custom hardware.

The DEC User Society collected many patches and enhancements for FOCAL. 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!

In Russia
Russia
Russia or , officially known as both Russia and the Russian Federation , is a country in northern Eurasia. It is a federal semi-presidential republic, comprising 83 federal subjects...

, it saw use as late as in early 1990s in mass-produced home computers of the Elektronika BK
Elektronika BK
The Elektronika BK was a series of 16-bit PDP-11-compatible Soviet home computers developed by NPO Scientific Center, the leading Soviet microcomputer design team at the time. It was also responsible for the more powerful UKNC and DVK micros...

 series.

One cause of FOCAL's decline may have been intellectual-property issues; FOCAL's IP heritage was sufficiently clouded that Digital could not be certain who "owned" it, and this was probably a factor leading to Digital's de-emphasis of the language and failure to continue its development.

Sample session with Focal on a PDP15

FOCAL15 V6B
*01.10 ASK "IN WHAT YEAR WERE YOU BORN?", YEAR
*01.20 SET YEAROFFOCAL=YEAR-1969+1
*01.30 IF (YEAROFFOCAL) 02.10,02.10,01.40
*01.40 TYPE "YOU WERE BORN IN THE YEAR ",YEAROFFOCAL," OF FOCAL!",!
*01.50 GOTO 01.10
*02.10 TYPE "YOU ARE TOO OLD FOR FOCAL, POPS",!
*02.20 GOTO 01.10
*GO
IN WHAT YEAR WERE YOU BORN?:1969
YOU WERE BORN IN THE YEAR 1.0000 OF FOCAL!
IN WHAT YEAR WERE YOU BORN?:1950
YOU ARE TOO OLD FOR FOCAL, POPS
IN WHAT YEAR WERE YOU BORN?:

This program takes your year of birth and calculates what year A.F. (after Focal) you were born in.

Program lines in a Focal program are grouped into linegroups and line numbers within that group. The first line of the program line 01.10 is line 10 of group 01. The line numbers are the targets of the GOTO and the IF statements.

The ASK statement prompts on the attached teleprinter
Teleprinter
A teleprinter is a electromechanical typewriter that can be used to communicate typed messages from point to point and point to multipoint over a variety of communication channels that range from a simple electrical connection, such as a pair of wires, to the use of radio and microwave as the...

 for input, while the TYPE statement outputs text on the teleprinter. Multiple items can be output to the teleprinter by appending each item after a comma. An exclamation mark (!) causes a linefeed and carriage return to be sent.

The SET statement assigns a value to a variable. This value can be the result of an expression.

The conditional IF statement can receive up to three line numbers as parameters (so-called Arithmetic IF
Arithmetic IF
The arithmetic IF statement has been for several decades a three-way arithmetic conditional statement, starting from the very early version of Fortran, and including FORTRAN IV, FORTRAN 66 and FORTRAN 77...

). The program branches to the first linenumber if the result of the expression in parentheses is less than zero, to the second if the result is zero and to the third if the result is above zero.

On the GO command, Focal begins to run the program.

Focal prompts with a single asterisk (*) at the beginning of the line when it is expecting input.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK