CAL (programming language)

Last updated

CAL, short for Conversational Algebraic Language, was a programming language and system designed and developed by Butler Lampson at Berkeley in 1967 for the SDS 940 mainframe computer. CAL is a version of the seminal JOSS language with several cleanups and new features to take advantage of the SDS platform.

Contents

The Berkeley SDS was used for the development of the Tymshare commercial time-sharing platform and an improved version of CAL was offered as a programming environment to its customers in 1969. Although CAL saw "almost no use", it had a lasting impact by influencing the design of Tymshare SUPER BASIC which copied a number of its features. Some of those features, in turn, appeared in BASIC-PLUS on the PDP-11, which is the direct ancestor of Microsoft BASIC. [1]

Description

Basic concepts

JOSS had been designed to be used by non-programmers in the US Air Force and within Rand Corporation, and to aid with that, Rand designed to custom computer terminals that were easier to set up and use. These terminals, based on the IBM Selectric typewriter, also included a custom character set that implemented common mathematical symbols like and .

To a large degree, CAL was a version of JOSS that replaced these sorts of customizations with more common solutions like >= and # so they could run on common terminals. [2] The other noticeable differences were that CAL was all upper-case, as opposed to sentence casing in JOSS, and it did not require a period at the end of the line. [3] The commands were otherwise almost identical and the overall structure and syntax were the same.

As with JOSS, CAL had an interactive user interface that allowed the user to type in statements in "direct mode" or programs to be run in "indirect mode". In BASIC, the former is more commonly referred to as "immediate mode". Both CAL and JOSS used a two-part line number, known as the part and step, separated by a period, for instance, 1.100 for part 1 step 100. Parts were generally used to group related statements into subroutines. In CAL, the part number could be between 0 and 999999, and the step from 0 to 99999. [4]

There were two main versions of CAL, released in 1967 and 1969. The following description will be based primarily on the former version unless otherwise noted.

Jumps and subroutines

As in JOSS, CAL supported the TO command to branch to a provided part or step, as in TO PART 3 or TO STEP 4.5, and DO for subroutine calls, as in DO PART 9 to perform the entire part, or DO STEP 5.1 to run that single step and then return. The later syntax was useful when there were many small subroutines as they could be implemented on a single line without an associated RETURN or similar concept. [5]

Conditional branching and assignment

One of the more notable syntactic features of JOSS was the concept of "statement modifiers" which controlled the operation of other statements. JOSS used this for conditional branching.

In most languages, one would write something to the effect of "If this expression is true, then do this...". In JOSS, this order was reversed, and such statements took the form "do this if this is true", for instance, Type "HELLO" if X=5.. CAL added some syntactic sugar to this basic concept by adding the new modifier UNLESS, which, depending on the context, led to more obvious code; TYPE "IT IS NOT EQUAL TO FIVE" UNLESS X=5. [6]

In JOSS, to assign the value 5 to a variable A if the value of B was larger than 10, and 0 otherwise, the code would be:

Set A=5 if B>10. Set A=0 if B<=10.

CAL also supported conditional expressions: [7]

A=IF B>10 THEN 5 ELSE 0

A similar modification was the WHERE statement, used to set variables as part of an if or for. It was similar in concept to the if/then/else structure, but could have any number of items. For instance,=A*B WHERE A=B UNTIL A>20, WHERE A=1 UNTIL A>100. [8]

Loops

Looping in JOSS was also controlled by a modifier, the For. This used somewhat obscure syntax from FORTRAN; Type i for i=1(2)10. runs a loop from 1 to 10 stepping by 2, so it would print 1,3,5,7,9. One could also supply explicit values, Type i for i=1,5,6,7,10., or mix the two, Type i for i=1,5(1)7,10.

CAL improved on JOSS' syntax by introducing the BY and TO keywords, so the equivalent code in CAL would be TYPE I FOR I=1 BY 2 TO 10. In JOSS, the parenthesis around the step value was the separator for the two limits, so it could not be made optional. By separating out TO the limits became explicit and the BY was made optional as assumed to be 1; TYPE I FOR I=1 TO 10. As with JOSS, explicit values and ranges could be used; TYPE I FOR I=1,5 TO 7,10. CAL further modified the for loop by adding conditional exits, using WHILE and UNTIL. For instance, TYPE A FOR A=1 BY 1 WHILE A<=50 or TYPE B FOR B=1 UNTIL A=50. [9]

User-defined functions

JOSS allowed the user to define functions using the Let statement. The syntax allowed local variables to be named in the function signature; Let F(X,Y)=X+Y. Programs could then call these functions as if they were built-in, Set A=F(1,5).

CAL changed Let to DEFINE, which is much more obvious, and made a more minor change the parameters were passed in using braces instead of parenthesis, so the equivalent definition would be DEFINE F[X,Y]=X+Y and called in the same way, SET A=F[1,5]. [10]

A more important change to CAL's functions was the ability to call subroutines from the definitions using TO, as in DEFINE F(X,Y) : TO PART 5. [lower-alpha 1] This left the issue of assigning the resulting calculated value back to the function, which was addressed with the introduction of the RETURN Z statement at the end of the part, where Z is the final value to be returned. [10]

Other changes

CAL included the mathematical functions of JOSS but added several new ones including ABS, TAN, ATAN, and LOG10. [11] It added a new operator as well, MOD, which returned the remainder of a division of its two operands. [12]

Direct mode

CAL added a small number of direct mode commands and associated statements.

PAUSE, when encountered in a program, printed a message "PAUSED AT STEP 1.1" and then returned to direct mode. This was similar to the STOP command in BASIC. This allowed the user to type in values and continue execution with GO. [13] While in direct mode, the user could STEP by a single line at a time to trace the execution of the program. [13]

Improvements in CAL 1969

One minor change in the 1969 version was the elimination of the SET command for variable assignment. This had been optional in direct mode in JOSS but was required in program statements, and the 1967 version of CAL followed this rule. [14] The 1969 version made it optional in both cases.

Footnotes

  1. Given that DO is normally used to call subroutines, it is not obvious why they chose TO in this case.

Related Research Articles

<span class="mw-page-title-main">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

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.

<span class="mw-page-title-main">JOSS</span> Interactive programming language

JOSS was one of the first interactive, time-sharing programming languages. It pioneered many features that would become common in languages from the 1960s into the 1980s, including use of line numbers as both editing instructions and targets for branches, statements predicated by boolean decisions, and a built-in source-code editor that can perform instructions in direct or immediate mode, what they termed a conversational user interface.

<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 the Atari 8-bit family of 6502-based home 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, for example.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

Dartmouth BASIC is the original version of the BASIC programming language. It was designed by two professors at Dartmouth College, John G. Kemeny and Thomas E. Kurtz. With the underlying Dartmouth Time Sharing System (DTSS), it offered an interactive programming environment to all undergraduates as well as the larger university community.

In computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.

BASIC-PLUS is an extended dialect of the BASIC programming language that was developed by Digital Equipment Corporation (DEC) for use on its RSTS/E time-sharing operating system for the PDP-11 series of 16-bit minicomputers in the early 1970s through the 1980s.

FOCAL is an interactive interpreted programming language based on JOSS and mostly used on Digital Equipment Corporation (DEC) Programmed Data Processor (PDP) series machines.

<span class="mw-page-title-main">ASIC programming language</span>

ASIC is a compiler and integrated development environment for a subset of the BASIC programming language. It was released for MS-DOS and compatible systems as shareware. Written by Dave Visti of 80/20 Software, it was one of the few BASIC compilers legally available for download from BBSes. ASIC allows compiling to an EXE or COM file. A COM file for Hello world program is 360 bytes.

Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.

The SDS 940 was Scientific Data Systems' (SDS) first machine designed to directly support time-sharing. The 940 was based on the SDS 930's 24-bit CPU, with additional circuitry to provide protected memory and virtual memory.

The Berkeley Timesharing System was a pioneering time-sharing operating system implemented between 1964 and 1967 at the University of California, Berkeley. It was designed as part of Project Genie and marketed by Scientific Data Systems for the SDS 940 computer system. It was the first commercial time-sharing which allowed general-purpose user programming, including machine language.

The structure of the Perl programming language encompasses both the syntactical rules of the language and the general ways in which programs are organized. Perl's design philosophy is expressed in the commonly cited motto "there's more than one way to do it". As a multi-paradigm, dynamically typed language, Perl allows a great degree of flexibility in program design. Perl also encourages modularization; this has been attributed to the component-based design structure of its Unix roots, and is responsible for the size of the CPAN archive, a community-maintained repository of more than 100,000 modules.

<span class="mw-page-title-main">SDS 9 Series</span> Backward compatible line of transistorized computers

The SDS 9 Series computers are a backward compatible line of transistorized computers produced by Scientific Data Systems in the 1960s and 1970s. This line includes the SDS 910, SDS 920, SDS 925, SDS 930, SDS 940, and the SDS 945. The SDS 9300 is an extension of the 9xx architecture. The 1965 SDS 92 is an incompatible 12-bit system built using monolithic integrated circuits.

SUPER BASIC, sometimes SBASIC for short, is an advanced dialect of the BASIC programming language offered on Tymshare's SDS 940 systems starting in 1968 and available well into the 1970s.

RETRIEVE is a database management system (DBMS) offered on Tymshare's systems starting in August 1971. It was written in Tymshare's own SUPER FORTRAN on the SDS 940. It offered basic single-file, non-relational database functionality using an interactive programming language. It is one of the earliest examples of software as a service (SaaS).

SDS BASIC, also known as CP-V BASIC, Batch BASIC or Sigma BASIC depending on the version, is a BASIC programming language compiler for Scientific Data Systems's (SDS) Sigma series mainframe computers, originally released in 1967. Xerox purchased SDS in 1969 and began rebranding it as Xerox Data Systems, and finally just Xerox, at which time the language became known as Xerox BASIC.

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

BASIC-8, is a BASIC programming language for the Digital Equipment (DEC) PDP-8 series minicomputers. It was the first BASIC dialect released by the company, and its success led DEC to produce new BASICs for its future machines, notably BASIC-PLUS for the PDP-11 series. DEC's adoption of BASIC cemented the use of the language as the standard educational and utility programming language of its era, which combined with its small system requirements, made BASIC the major language during the launch of microcomputers in the mid-1970s.

References

Citations

  1. Lampson, "Systems", Research, Microsoft.
  2. Manual 1969, p. 7.
  3. Manual 1969, p. 23.
  4. Manual 1969, p. 11.
  5. Manual 1969, p. 15, 26.
  6. Manual 1969, p. 12.
  7. Manual 1969, p. 14.
  8. Manual 1969, p. 21.
  9. Manual 1969, p. 13.
  10. 1 2 Manual 1967, p. 27.
  11. Manual 1967, p. 9.
  12. Manual 1967, p. 10.
  13. 1 2 Manual 1967, p. 25.
  14. Manual 1967, p. 8.

Bibliography