Here's part of "The Secret Guide to Computers," copyright by Russ Walter, 30th edition. For newer info, read the 33rd edition at www.SecretFun.com.

Exotic languages

You’ve already learned the most popular computer languages: QBasic, Visual Basic, JavaScript, Java, C, and C++. But those 6 languages are just the tip of the iceberg. Programmers have invented thousands of others.

Here’s a multilingual dictionary that lets you translate 19 languages. For example, it shows that QBasic says “DIM x(4)” but Fortran says “DIMENSION X(4)” instead.

┌────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────┐

│QBasic      │DIM x(4)                    FOR i = 5 TO 17                                  fred           GOTO 50      │

│Visual Basic│Dim x(4)                    For i = 5 To 17                                  fred           GoTo gail    │

│Fortran     │DIMENSION X(4)              DO 10 I=5,17                                     CALL FRED      GO TO 50     │

│PL/I        │DECLARE X(4)                DO I = 5 TO 17                                   CALL FRED      GO TO GAIL   │

│            │                                                                                                         │

│Algol       │REAL ARRAY X[1:4]           FOR I := 5 STEP 1 UNTIL 17 DO                    FRED           GO TO GAIL   │

│Pascal      │X: ARRAY[1..4] OF REAL      FOR I := 5 TO 17 DO                              FRED           GOTO 50      │

│Modula      │X: ARRAY[1..4] OF REAL      FOR I := 5 TO 17 DO                              FRED           not available│

│Ada         │X: ARRAY(1..4) OF FLOAT     FOR I IN 5..17 LOOP                              FRED           GO TO GAIL   │

│            │                                                                                                         │

│C           │float x[4]                  for (i=5; i<=17; ++i)                            fred()         goto gail    │

│C++         │float x[4]                  for (int i=5; i<=17; ++i)                        fred()         goto gail    │

│Java        │float[] x=new float x[4]    for (int i=5; i<=17; ++i)                        fred()         not available│

│JavaScript  │x=Array(4)                  for (int i=5; i<=17; ++i)                        fred()         not available│

│            │                                                                                                         │

│Easy        │PREPARE X(4)                LOOP I FROM 5 TO 17                              FRED           SKIP TO GAIL │

│DBase       │DECLARE X[4]                not available                                    DO FRED        not available│

│Cobol       │X OCCURS 4 TIMES            PERFORM SAM VARYING I FROM 5 BY 1 UNTIL I > 17   PERFORM FRED   GO TO GAIL   │

│            │                                                                                                         │

│Logo        │DEFAR "X 4 1                not available                                    FRED           GO "GAIL     │

│Lisp        │(ARRAY ((X (4) LIST)))      not available                                    (FRED)         (GO GAIL)    │

│Snobol      │X = ARRAY(4)                not available                                    FRED()         :(GAIL)      │

│Pilot       │DIM:#X(4)                   not available                                    U:FRED         J:*GAIL      │

└────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────┘

┌────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────┐

│QBasic      │IF x = 4.3 THEN      INPUT k               j = k + 2           PRINT k               'silly stuff        │

│Visual Basic│If x = 4.3 Then      k = Val(InputBox("")) j = k + 2           Print k               'silly stuff        │

│Fortran     │IF (X .EQ. 4.3)      READ *, K             J=K+2               PRINT *, K            C  SILLY STUFF      │

│PL/I        │IF X=4.3 THEN        GET LIST(K)           J=K+2               PUT LIST(K)           /* SILLY STUFF */   │

│            │                                                                                                         │

│Algol       │IF X=4.3 THEN        READ(K)               J:=K+2              PRINT(K)              COMMENT  SILLY STUFF│

│Pascal      │IF X=4.3 THEN        READ(K)               J:=K+2              WRITELN(K)            {SILLY STUFF}       │

│Modula      │IF X=4.3 THEN        READINTEGER(K)        J:=K+2              WRITEINTEGER(K,6)     (*SILLY STUFF*)     │

│Ada         │IF X=4.3 THEN        GET(K)                J:=K+2              PUT(K)                --SILLY STUFF       │

│            │                                                                                                         │

│C           │if (x==4.3)          scanf("%d",&k)        j=k+2               printf("%d",k)        /* silly stuff */   │

│C++         │if (x==4.3)          cin >>k               j=k+2               cout <<k              //silly stuff       │

│Java        │if (x==4.3)          k=Integer.parseInt(s) j=k+2               System.out.println(k) //silly stuff       │

│JavaScript  │if (x==4.3)          k=prompt("","")       j=k+2               document.write(k)     //silly stuff       │

│            │                                                                                                         │

│Easy        │IF X=4.3             GET K                 LET J=K+2           SAY K                 'SILLY STUFF        │

│DBase       │IF X=4.3             INPUT TO K            J=K+2               ? K                   &&SILLY STUFF       │

│Cobol       │IF X = 4.3           ACCEPT K              COMPUTE J = K + 2   DISPLAY K             *SILLY STUFF        │

│            │                                                                                                         │

│Logo        │IF :X=4.3            MAKE "K READWORD      MAKE "J :K+2        PRINT :K              !SILLY STUFF        │

│Lisp        │(COND ((EQUAL X 4.3) (SETQ K (READ))       (SETQ J (PLUS K 2)) K                     ;SILLY STUFF        │

│Snobol      │EQ(X,4.3) :S(        K = INPUT             J = K + 2           OUTPUT = K            *SILLY STUFF        │

│Pilot       │(#X=4.3)             A:#K                  C:#J=#K+2           T:#K                  R:SILLY STUFF       │

└────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────┘

The dictionary clumps the languages into groups. For example, look at the languages in the second group: Algol, Pascal, Modula, and Ada. hose 4 languages are almost identical to each other. For example, in each of them you say “J:=K+2”.

The bottom group (Logo, Lisp, Snobol, and Pilot) differs wildly from the others. For example, look at how those 4 languages translate “IF x = 4.3 THEN” and “j = k + 2”. They’re called radical languages; the other 15 languages are called mainstream.

Two other radical languages are APL and Forth. They’re so weird they won’t fit in that chart!

Here’s how to make the computer do 2+2 and print the answer (4), using each of those languages:

QBasic           Logo           Easy        DBase     APL   JavaScript                       Lisp                Forth         Snobol                       Pilot       x

PRINT 2 + 2 PRINT 2+2 SAY 2+2   ? 2+2  2+2 document.write(2+2)  (PLUS 2 2) 2 2 + .     OUTPUT = 2 + 2   C:#N=2+2

END            T:#N

Algol              Pascal             Visual Basic                            Fortran        PL/I                                                       Ada                         x

BEGIN      BEGIN        Private Sub Form_Load() N=2+2      HARRY:  PROCEDURE OPTIONS(MAIN); PROCEDURE HARRY IS

PRINT(2+2); WRITELN(2+2); Print 2 + 2            PRINT *, N           PUT LIST(2+2);           BEGIN

END          END.         End Sub                END                  END;                    PUT(2+2);

END;

C++                               C                           Modula                          Java                                                            Cobol                          x

#include <iostream.h> #include <stdio.h>  MODULE HARRY;       public class Class1                  IDENTIFICATION DIVISION.

void main()        void main()     FROM INOUT        {                                DATA DIVISION.

{                {                 IMPORT WRITEINTEGER;   public static void main (String[] args) WORKING-STORAGE SECTION.

cout <<2+2;         printf("%d",2+2); BEGIN                 {                                 01     N PIC 9.

}                }             WRITEINTEGER(2+2,6);       System.out.println(2+2);         PROCEDURE DIVISION.

END HARRY.            }                                 MAIN-ROUTINE.

}                                        ADD 2 2 GIVING N.

DISPLAY N.

STOP RUN.

Notice that APL’s the briefest (just say 2+2), and Cobol’s the most verbose (it requires 9 lines of typing).

Each of those 20 languages is flexible enough to program anything. Which language you choose is mainly a matter of personal taste.

Other languages are more specialized. For example, a language called GPSS is designed specifically to analyze how many employees to hire, to save your customers from waiting in long lines for service. Dynamo analyzes social interactions inside your company and city and throughout the world; then it graphs your future. SPSS analyzes tables of numbers, by computing their averages, maxima, minima, standard deviations, and hundreds of other measurements used by statisticians. Apt helps you run a factory by controlling “robots” that cut metal. Prolog lets you store answers to your questions and act as an expert system. RPG spits out long business reports for executives who don’t have enough time to program in Cobol.

The following table reveals more details about all those languages. Within each category (“mainstream”, “radical”, and “specialized”), the table lists the languages in chronological order. QBasic and Visual Basic are considered variants of Basic.

Name      What the name stands for              Original use           Version 1 arose at         When         Names of new versions

Mainstream languages

Fortran     Formula Translating                                   sciences                        IBM                                    1954-1957   Fortran, Lahey Fortran

Algol        Algorithmic Language                                 sciences                         international                           1957-1958   Algol W, Algol 68, Balgol

Basic         Beginners All-purp. Symbolic Instruc. Code   sciences                        Dartmouth College           1963-1964   QBasic, Visual Basic

PL/I          Programming Language One                       general                          IBM                                    1963-1966   PL/I Optimizer, PL/C, Ansi PL/I

Pascal       Blaise Pascal                                              general                          Switzerland                          1968-1970   Turbo Pascal, Delphi

Modula     Modular programming                                systems programming   Switzerland                          1975            Modula-2, Oberon

C              beyond B                                                    systems programming   Bell Labs                             1971-1973   Ansi C

DBase       Data Base                                                      database management   Jet Prop’n Lab & Ashton-T.   1978-1980   DBase Plus 2, Visual FoxPro 9

Easy         Easy                                                           general                          Secret Guide                     1972-1982   Easy

C++          C increased                                                 systems programming   Bell Labs                             1979-1983   Visual C++, Borland C++, ISO C++, C#

Java          as stimulating as Java coffee                      Web-page animation     Sun Microsystems                1990-1995   Java 2, J2EE, Visual J++, JBuilder, J#

JavaScript Java for creating simple scripts              Web-page calculations   Netscape                             1996            JScript

Lisp          List Processing                                           artificial intelligence     MIT                                    1958-1960   Common Lisp

Snobol      String-Oriented symbolic Language         string processing        Bell Labs                             1962-1963   Snobol 4B

APL         A Programming Language                           sciences                        Harvard & IBM                   1956-1966   APLSV, APL Plus, APL 2, J

Logo         Logo                                                           general                          Bolt Beranek Newman         1967            Terrapin Logo, LCSI MicroWorlds Pro

Forth        Fourth-generation language                     business & astronomy   Stanford Univ. & Mohasco  1963-1968   Forth 83, Fig-Forth, MMS Forth

Pilot         Programmed Inquiry, Learning, Or Teaching  tutoring kids              U. of Cal. at San Francisco  1968            Atari Pilot

Specialized languages

APT         Automatically Programmed Tools              cutting metal                MIT                                    1952-1957   APT 77

Dynamo   Dynamic Models                                     simulation                     MIT                                    1959            Dynamo 3, Stella

GPSS         General-Purpose Simulation System        simulation                     IBM                                    1961           GPSS 5

RPG          Report Program Generator                         business                     IBM                                    1964            RPG 3

SPSS         Statistical Package for the Social Sciences  statistics                       Stanford University             1965-1967   SPSS 10

Prolog      Programming in Logic                                artificial intelligence     France                                 1972            Arity Prolog, Turbo Prolog

Of those 26 languages, 5 were invented in Europe (Algol, Pascal, Modula, Ada, and Prolog). The rest were invented in the U.S.

5 were invented at IBM’s research facilities (Fortran, PL/I, APL, GPSS, and RPG), 3 at MIT (Lisp, Apt, and Dynamo), 3 at Bell Labs (C, C++, and Snobol), 2 at Stanford University (Forth and SPSS), and 2 by Professor Niklaus Wirth in Switzerland (Pascal and Modula). The rest were invented by geniuses elsewhere.

Mainstream languages

The first mainstream languages were Fortran, Algol, and Cobol. They were the big 3.

IBM invented Fortran, which appealed to engineers.

An international committee invented Algol, which appealed to logicians.

A committee based at the Pentagon invented Cobol, which appealed to government bureaucrats and business managers.

Beyond the big 3

Other mainstream languages came after the big 3 and were just slight improvements of the big 3. This family tree shows how the mainstream languages influenced each other:

Fortran (1957)

PL/I (1966)     Algol (1958)                                                                                            Cobol (1960)

Pascal (1970)                                   C (1973)         Basic (1964)

Modula (1975)       Ada (1980)         C++ (1983)     Easy (1982)    DBase (1980)

Java (1995)

JavaScript (1996)

In that tree, a vertical line means “a direct influence” (like a parent); a slanted line means “an indirect influence” (like an aunt or uncle). For each language, I show the year when the language’s first version was complete. As each language grew, it stole features from other languages (just like English stole the word “restaurant” from French); the tree shows just history’s main thrust. Now let’s dig into the details.…

Why Basic? Two professors at Dartmouth College combined Fortran with Algol, to form Basic. It was designed for students, not professionals: it included just the easiest parts of Fortran and Algol. Students liked it because it was easy to learn, but professionals complained it lacked advanced features.

Why PL/I? After inventing Fortran and further improvements (called Fortran II, Fortran III, Fortran IV, and Fortran V), IBM decided to invent the “ultimate” improvement: a language that would include all the important words of Fortran V and Algol and Cobol. At first, IBM called it “Fortran VI”; but since it included the best of everything and was the first complete language ever invented, IBM changed its name to Programming Language One (written as PL/I). IBM bragged about how PL/I was so eclectic, but most programmers considered it a confusing mishmash and continued using the original 3 languages (Fortran, Algol, and Cobol), which were pure and simple.

Why Pascal and Modula? Among the folks who disliked PL/I was Niklaus Wirth, who preferred Algol. At a Swiss university, he invented an improved Algol and called it Pascal. Then he invented a further improvement, called Modula. Algol, Pascal, and Modula are all very similar to each other. He thinks Modula’s the best of the trio, but critics disagree. Today, Pascal is still the most popular of that trio; hardly anybody uses the original Algol anymore, and Modula is considered a controversial experiment.

While Wirth was developing and improving Modula, other researchers were developing 4 competitors: C, Ada, DBase, and Easy. Here’s why.…

Why C? Fancy languages, such as PL/I and Modula, require lots of RAM. At Bell Labs, researchers needed a language small enough to fit in the tiny RAM of a minicomputer or microcomputer. They developed the ideal tiny language and called it C. Like PL/I, it borrows from Fortran, Algol, and Cobol; but it lacks PL/I’s frills. It’s “lean and mean” and runs very quickly. Later, Bell Telephone Labs invented an improved C, called C++, which includes extra commands. Then Sun invented a C++ variant, called Java, to handle animation on Web pages.

Why Ada? The Department of Defense, which was happily using Cobol to run the military’s bureaucracy, needed to invent a second kind of language, to control missiles and other military equipment. The Department held a contest to develop such a language and said it wanted the language to resemble PL/I, Algol, and Pascal. (It didn’t know about Modula, which was still being developed.) The winner was a French company. The Department adopted that company’s language and called it Ada. It resembled Modula but included more commands — and therefore consumed more RAM and was more expensive. Critics complain that Ada like PL/I, is too large and complex.

Why DBase? Inspired by languages such as Basic and PL/I, Wayne Ratliff invented DBase. Like Basic, DBase is easy; like PL/I and Pascal, DBase creates loops by saying WHILE instead of GO TO. What makes DBASE unique is its new commands for manipulating databases.

Why Easy? My own attempt to create the ideal language is called Easy. It’s even easier to learn than Basic, yet includes the power of languages such as Pascal. But since I don’t have the time to put Easy onto a computer, Easy’s remained just an idea whose time should have come.

Dig in! Here are the inside secrets about all those mainstream languages.…

Fortran

During the early 1950’s, the only available computer languages were specialized or awkward. Fortran was the first computer language good enough to be considered mainstream. Algol and Cobol came shortly afterwards. Fortran, Algol, and Cobol were so good that they made all earlier languages obsolete.

Fortran’s nature On pages 370-438, I explained how to program in QBasic. Fortran resembles QBasic but is weirder — because Fortran was invented before programmers learned how to make programming languages pleasant.

For example, suppose you want to add 2+2. In QBasic, you can say just:

PRINT 2+2

In Fortran, you must lengthen the program, so it looks like this instead:

N=2+2

PRINT *, N

END

Here’s why:

Fortran requires the program’s bottom line to say END.

Fortran requires each line to be indented 6 spaces.

Fortran is too stupid to do math in the middle of a PRINT statement, so you must do the math first, in a separate line (N=2+2).

Fortran expects you to comment about how to print the answer. If you have no comment on that topic, put an asterisk and comma in the PRINT statement. The asterisk and comma mean: no comment.

That’s how the typical version of Fortran works. Some versions are different. For example, some versions require you to say STOP above END, like this:

N=2+2

PRINT *, N

STOP

END

Some versions want you to say TYPE instead of PRINT.

Some old versions won’t accept “no comment” about printing. They require you to say:

N=2+2

PRINT 10, N

10    FORMAT (1X,I1)

END

That PRINT line means: PRINT, using the FORMAT in line 10, the value of N. In line 10, the 1X means “normal”; the I1 means “an integer that’s just one digit”. Those details drive beginners nuts, but experienced Fortran programmers are used to such headaches and take them in stride, just like Frenchmen are used to conjugating French verbs and Germans are used to conjugating German adjectives (yuck!).

Like QBasic, Fortran lets you do math by using these symbols:

+   -   *   /

But Fortran is harder to learn than QBasic:

In QBasic, if you want to divide 399 by 100, requesting 399/100 makes the computer gives you the correct answer, 3.99. But in Fortran, requesting 399/100 makes the computer assume you don’t care about decimal points (since you didn’t mention any), so it says just 3; if you want it to say 3.99 instead, you must insert a decimal point into the original problem, by asking for 399.0/100.0 (or at least asking for 399./100, if you’re lazy).

In QBasic, you can use the symbol < to mean “less than”. Fortran is afraid to use fancy symbols (since ancient computers didn’t understand them), so Fortran wants you to write .LT. instead, like this:

QBasic:     IF x < 4.3 THEN

Fortran:    IF (X .LT. 4.3) THEN

Likewise, Fortran requires you to say .GT. instead of > for “greater than”, say .LE. for “less than or equal to”, say .GE. for “greater than or equal to”. To be consistent, Fortran also requires you to say .EQ. instead of “equal to” (in an IF statement):

QBasic:     IF x = 4.3 THEN

Fortran     IF (X .EQ. 4.3) THEN

In QBasic, the symbol ^ means exponents (for example,
4.7 ^ 3 means “4.7 times 4.7 times 4.7”). Since Fortran’s afraid of fancy symbols, Fortran uses ** instead of ^ (like this: 4.7 ** 3).

In QBasic, a variable can be any letter of the alphabet (such as n) or a longer name (up to 40 characters long). In Fortran, each variable’s name must be short (no longer than 6 characters), because Fortran is supposed to run even on primitive old computers that have very little memory.

QBasic can handle 5 kinds of variables: single-precision real, double-precision real, short integer, long integer, or string. QBasic assumes each variable is single-precision real, unless you specifically indicate otherwise (such as by putting a \$ at the end of the variable’s name, to indicate the variable’s a string).

In QBasic, every variable stands for a single-precision real number, unless you specifically say otherwise. For example, putting \$ after the variable’s name makes the variable become a string instead. QBasic can handle 5 kinds of variables: single-precision real number, string, double-precision real number, short integer, and long integer.

Mathematicians (and engineers) often use the letters i, j, k, m, and n to stand for integers. Fortran therefore assumes that any variable whose name begins with I, J, K, L, M, or N is an integer, and all other variables are single-precision real, unless you specifically say otherwise.

Fortran can handle 4 kinds of variables: single-precision real (which Fortran calls REAL), double-precision real (which Fortran calls DOUBLE PRECISION), long integer (which Fortran calls INTEGER), and complex numbers (which Fortran calls COMPLEX and include numbers such as the square root of -1). Fortran’s ability to handle COMPLEX numbers make it better for advanced math & engineering than QBasic.

Since Fortran assumes that variables beginning with I, J, K, L, M, or N are integers, Fortran programmers purposely misspell variable names. For example, if a Fortran variable’s purpose is to count, call it KOUNT (rather than COUNT) to make it an INTEGER. If you want a Fortran variable to be an integer that measures a position, call it LOCATN (rather than POSITN) to make it an INTEGER. If a Fortran variable measures an object’s mass as a real number, call it AMASS (rather than MASS) to make it a REAL.

Since Fortran’s purpose was just to do math, Fortran’s original version didn’t include any string variables. Later, many manufacturers tried to “fix” Fortran by adding string commands, but those commands are awkward and pathetic, much worse than what QBasic offers.

Fortran did a good job of handling math functions (such as SQR) and subroutines (for handling statistics, calculus computations, and other math challenges). Many programmers created libraries full of math functions and subroutines and sold them to other programmers. A whole culture developed of programmers writing Fortran routines. If you didn’t know Fortran, you weren’t part of the “in” crowd.

How Fortran arose In 1954, an IBM committee said it was planning a new computer language that would help engineers make the computer handle math formulas. The committee called the language Fortran, to emphasize that the language would be particularly good for translating formulas into computer notation.

Those original plans for Fortran were modest:

They did not allow long variable names, subroutines, long function definitions, double precision, complex numbers, or apostrophes. A variable’s name had to be short: just two letters. A function’s definition had to fit on a single line. To print ‘PLEASE KISS ME’, the programmers had to write that string as 14HPLEASE KISS ME instead of ‘PLEASE KISS ME’; the 14H warned the computer that a 14-character string was coming.

Then came improvements:

Fortran’s first working version (1957) allowed longer variable names: 6 characters.

Fortran II (1958) allowed subroutines and long function definitions.

IBM experimented with Fortran III but never released it to the public.

Fortran IV (1962) allowed double precision and complex numbers.

Apostrophes around strings weren’t allowed until later.

The original plans said you’d be able to add an integer to a real. That didn’t work in Fortran I, Fortran II, and Fortran IV, but it works today.

The original plans said an IF statement would compare any two numbers. Fortran I and Fortran II required the second number no be zero, but Fortran IV removed that restriction.

IBM waged a campaign to convince everyone that Fortran was easier than previous methods of programming. IBM succeeded: Fortran became immediately popular. Fortran was easy enough so that, for the first time, engineers who weren’t computer specialists could write programs.

Other manufacturers sold imitations of IBM’s Fortran, but with modifications. The variety of modifications from all the manufacturers annoyed engineers, who wished manufacturers would all use a single, common version of Fortran. So the engineers turned to the American National Standards Institute (Ansi), which is a non-profit group of engineers that sets standards.

“Ansi” is pronounced “an see”. It sets standards for practically all equipment in your life. For example, Ansi sets the standard for screws: to tighten a screw, you turn it clockwise, not counterclockwise.

In 1966, Ansi decided on a single version of Fortran IV to be used by all manufacturers. Thereafter, each manufacturer adhered to the Ansi standard but also added extra commands, to try to outclass the other manufacturers.

After several years had gone by, enough extra commands had been added by manufacturers so engineers asked Ansi to meet again and develop a common standard for those extras. Ansi finished developing the standard in 1977 and called it Fortran 77.

Now each major manufacturer adheres to the standard for Fortran 77, so you can run Fortran 77 programs on most maxicomputers, minicomputers, and microcomputers. Each manufacturer adds extra commands beyond Fortran 77.

In 1984, an Ansi committee developed a “Fortran 88”. 40 members of the committee approved it, but the other 2 members — IBM and DEC — refused to endorse it. In 1991, a variant called Fortran 90 was finally approved by all.

Fortran’s popularity Fortran became popular immediately because it didn’t have any serious competitors. Throughout the 1960’s and 1970’s, Fortran remained the most popular computer language among engineers, scientists, mathematicians, and college students. Colleges required all freshman computer-science majors to take Fortran.

But at the end of the 1970’s, Fortran’s popularity began to drop.

Engineers switched to newer languages, such as Basic (which is easier), Pascal (more logical), and C (faster and more economical of RAM). Although Fortran 77 included extra commands to make Fortran resemble Basic and Pascal, those commands were “too little, too late”: Fortran’s new string commands weren’t quite as good as Basic’s, and Fortran’s new IF command wasn’t quite as good as Pascal’s.

Now high-school kids are required to study Basic or Pascal, college kids are required to study C++, and hardly anybody studies Fortran. People who still program in Fortran are called “old-fashioned” by their colleagues.

But in some ways, Fortran’s still better for engineering that Basic, Pascal, or C++. Here’s why:

Fortran includes more commands for handling “complex numbers”.

Fortran programmers have developed libraries containing thousands of Fortran subroutines, which you can use in your own Fortran programs. Such large libraries haven’t been developed for Basic, Pascal, or C++ yet.

Though Basic, Pascal, and C++ work well on microcomputers and minicomputers, no good versions of those languages have been invented for IBM maxicomputers. The only language that lets you unleash an IBM maxicomputer’s full power to solve engineering problems is Fortran.

Algol

In 1955, a committee in Germany began inventing a computer language. Though the committee spoke German, it decided the computer language should use English words instead, since English was the international language for science.

In 1957 those Germans invited Americans to join them. In 1958 other European countries joined also, to form an international committee, which proposed a new computer language, called “IAL” (International Algebraic Language).

The committee eventually changed the language’s name to Algol 58 (the Algorithmic language invented in 1958), then created an improved version called Algol 60, then created a further revision called Algol 60 Revised, and disbanded. Today, programmers who mention “Algol” usually mean the committee’s last report, Algol 60 Revised.

Algol differs from Fortran in many little ways.…

How to end a statement At the end of each statement, Fortran requires you to press the Enter key. Algol requires you to type a semicolon instead.

Algol’s advantage: you can type many statements on the same line, by putting semicolons between the statements. Algol’s disadvantage: those ugly semicolons are a nuisance to type and make your program look cluttered.

Integer variables To tell the computer that a person’s AGE is an integer (instead of a real number), Fortran requires you to put the letter I, J, K, L, M, or N before the variable’s name, like this: IAGE. Algol requires you to insert a note saying “INTEGER AGE” at the top of your program instead.

Algol’s advantage: you don’t have to write unpronounceable gobbledygook such as “IAGE”. Algol’s disadvantage: whenever you create a new variable, Algol forces you to go back up to the top of your program and insert a line saying “INTEGER” or “REAL”.

Assignment statements In Fortran, you can say J=7. In Algol, you must insert a colon and say J:=7 instead. To increase K by 1 in Fortran, you say K=K+1. In Algol, you say K:=K+1.

Algol’s disadvantage: the colon is a nuisance to type. Fortran’s disadvantage: according to the rules of algebra, it’s impossible for K to equal K+1, and so the Fortran command K=K+1 looks like an impossibility.

Algol’s beauty Here’s how Algol avoids Fortran’s ugliness:

In Algol, a variable’s name can be practically as long as you like. In Fortran, a variable’s name must be short: no more than 6 characters.

Algol lets you write 2 instead of 2.0, without affecting the computer’s answer. In Fortran, if you write 1/2 instead of 1/2.0, you get 0 instead of .5; and if you write SQRT (9) instead of SQRT (9.0), you get nonsense.

Algol’s IF statement is very flexible: it can include the words ELSE, BEGIN, and END, and it lets you insert as many statements as you want between BEGIN and END. Algol even lets you put an IF statement in the middle of an equation, like this: X:=2+(IF Y<5 THEN 8 ELSE 9). The IF statement in Fortran I, II, III, and IV was very limited; the IF statement in Fortran 77 copies some of Algol’s power, but not yet all.

Algol’s FOR statement is very flexible. To make X be 3.7, then be Y+6.2, then go from SQRT(Z) down to 5 in steps of .3, you can say “FOR X:=3.7, Y+6.2, SQRT(Z) STEP -.3 UNTIL 5 DO”. Fortran’s DO is more restrictive; some versions of Fortran even insist that the DO statement contain no reals, no negatives, and no arithmetic operations.

At the beginning of a Fortran program, you can say DIMENSION X(20) but not DIMENSION X(N). Algol permits the “DIMENSION X(N)” concept; in Algol you say ARRAY X[1:N].

Algol’s popularity When Algol was invented, programmers loved it. Europeans began using Algol more than Fortran. The American computer association (called the Association for Computing Machinery, ACM) said all programs in its magazine would be in Algol.

But since IBM refused to put Algol on its computers, most American programmers couldn’t use Algol.

That created a ridiculous situation: American programmers programmed in Fortran but submitted Algol translations to the ACM’s magazine, which published the programs in Algol, which the magazine’s readers had to translate back to Fortran to run on IBM computers. IBM computers eventually swept over Europe, so even Europeans had to use Fortran instead of Algol. In 1966 the ACM gave in and agreed to publish programs in Fortran; but since Algol was prettier, everybody continued to submit Algol versions anyway. IBM gave in also and put Algol on its computers; but IBM’s version of Algol was so limited and awkward that nobody took it seriously, and IBM stopped selling it. In 1972 Stanford University invented Algol W (a better Algol for IBM computers), but Algol W came too late: universities and businessmen had already tired of waiting for a good IBM Algol and had committed themselves to Fortran.

Critics blamed IBM for Algol’s demise. But here’s IBM’s side of the story:

IBM had invested 25 man-years to develop the first version of Fortran. By the time the Algol committee finished the report on Algol 60 Revised, IBM had also developed Fortran II and Fortran III and made plans for Fortran IV. IBM was proud of its Fortrans and wanted to elaborate on them. Moreover, IBM realized that computers run Fortran programs faster than Algol.

When asked why it didn’t support Algol, IBM replied that the committee’s description of Algol was incomplete. IBM was right; the Algol 60 Revised Report had 3 loopholes:

The report didn’t say what words to use for input and output, because the committee couldn’t agree. So computers differ. If you want to transfer an Algol program from one computer to another, you must change all the input and output instructions.

The report uses symbols such as ¸ and Ù, which most keyboards lack. The report underlines keywords; most keyboards can’t underline. To type Algol programs on a typical keyboard, you must substitute other symbols for ¸, Ù, and underlining. Manufacturers differ in what to substitute. To transfer an Algol program to different manufacturer, you must change symbols.

Some features of Algol are hard to teach to a computer. Even now, no computer understands all of Algol. When a manufacturer says its computer “understands Algol”, you must ask, “Which features of Algol?”

Attempts to improve Algol Long after the original Algol committee wrote the Algol 60 Revised Report, two other Algol committees were formed.

One committee developed suggestions on how to do input and output, but its suggestions were largely ignored.

The other committee tried to invent a much fancier Algol. That committee wrote its preliminary report in 1968 and revised it in 1975. Called Algol 68 Revised, that weird report requires you to spell words backwards: to mark the end of the IF statement, you say FI; to mark the end of the DO statement, you say OD. The committee’s decision was far from unanimous: several members refused to endorse the report.

Algol today Few programmers still use Algol, but many use Pascal (which is very similar to Algol 60 Revised) and Basic (which is a compromise between Algol and Fortran).

Cobol

If you’re a student who’s going to give a speech or write a paper, teachers recommend that you organize your thinking by creating an outline. Back in the 1950’s, managers of computer departments got together and decided programmers should organize programs in the same way, by creating an outline before writing the program, especially since a well-organized program is easier to analyze and improve if the original programmer gets fired.

Those managers invented a computer language that lets the programmer just fill in an outline and feed the outline to the computer. The outline itself acts as the program. No further programming is necessary.

That outline-oriented computer language is used especially for handling tough programming problems in business accounting (such as payroll, inventory, accounts payable, and accounts receivable), so it was named the Common Business-Oriented Language (whose abbreviation is Cobol, which is pronounced “koe ball”). But cynics complain that “Cobol” also stands for Completely Obsolete Business-Oriented Language and Compiles Only Because Of Luck.

4 parts To write a program in Cobol, just fill in an outline that has 4 parts:

In the first part, called the IDENTIFICATION DIVISION, you give your name (so your boss knows who to fire when the program doesn’t work) and make extra comments about when you wrote the program, the program’s name, and security (who’s allowed to see this program). The computer ignores everything you say in the IDENTIFICATION DIVISION, but writing that stuff makes your boss happy.

In the second part, called the ENVIRONMENT DIVISION, you say what kind of environment you wrote the program for: which computer it runs on, which devices the program’s files use (disks? tapes? printers? punched cards?), and whether decimal points should be printed as commas instead (since people in France, Italy, and Germany want you to do that).

In the third part, called the DATA DIVISION, you list all the program’s variables. For each numeric variable, you must say how many digits it should store (to the left and right of the decimal point) and how to format the number (for example, say whether to print a dollar sign before the number). For example, if you want N to be a simple 3-digit integer (from 000 to 999), with no special formatting, say N PICTURE IS 999 (which means N is a variable whose picture is at most the number 999). If you want N to be a simple 7-digit integer (from 0000000 to 9999999), say N PICTURE IS 9999999. If you want N to be a simple 7-character string, say N PICTURE IS XXXXXXX. You can abbreviate: you can say just PIC instead of PICTURE IS, and you can say X(7) instead of XXXXXXX.

In the fourth and final part, called the PROCEDURE DIVISION, you finally write the procedures that you want to the computer to perform, using commands such as READ, WRITE, DISPLAY, ACCEPT, IF, GO TO, SORT, MERGE, and PERFORM. Each command is an English sentence that includes a verb and ends in a period. You organize the PROCEDURE DIVISION into paragraphs, invent a name for each paragraph, treat each paragraph as a separate procedure/subroutine, and tell the computer in what order to PERFORM the paragraphs. One line in the PROCEDURE DIVISION must say “STOP RUN”: when the computer encounters that line, the computer stops running the program.

Unfortunately, that idea of dividing a program into 4 divisions is wrong-headed: when you write or read a Cobol program, your eye must keep hopping between the PROCEDURE DIVISION (where the action is) and the DATA DIVISION (which tells what the variables mean), while taking an occasional peek at the ENVIRONMENT DIVISION (which tells what devices are involved). Other programming languages, developed later, use better methods for organizing thoughts.

How Cobol arose During the 1950’s, several organizations developed languages to solve problems in business. The most popular business languages were IBM’s Commercial Translator (developed from 1957-1959), Honeywell’s Fact (1959-1960), Sperry Rand’s Flow-matic (1954-1958), and the Air Force’s Aimaco (1958).

In April 1959, a group of programmers and manufacturers met at the University of Pennsylvania, decided to develop a single business language for all computers, and asked the Department of Defense to help sponsor the research.

The Department agreed. In a follow-up meeting held at the Pentagon in May, the group tentatively decided to call the new language “CBL” (for “Common Business Language”) and created 3 committees.

The Short-Range Committee would meet immediately to develop a temporary language. A Medium-Range Committee would meet later to develop a more thoroughly thought-out language. Then a Long-Range Committee would develop the ultimate language.

The Short-Range Committee met immediately and created a language nice enough so the Medium-Range and Long-Range Committees never bothered to meet.

The Short-Range Committee wanted a more pronounceable name for the language than “CBL”. At a meeting in September 1969, the committee members proposed 6 names:

“INFOSYL” (INFOrmation SYstem Language)

“DATASYL” (DATA SYstem Language)

“COSYL” (COmmon SYstem Language)

“COCOSYL” (COmmon COmputer SYstem Language)

The next day, a member of the committee suggested “Cobol” (Common Business-Oriented Language), and the rest of the committee agreed.

I wish they’d have kept the name “BUSY”, because it’s easier to pronounce and remember than “Cobol”. Today, Cobol programmers are still known as “BUSY bodies”.

From Sperry Rand’s Flow-matic, the new language (called “Cobol”) borrowed 2 rules:

Begin each statement with an English verb.

Put data descriptions in a different program division than procedures.

From IBM’s Commercial Translator, Cobol borrowed group items (01 and 02), PICTURE symbols, fancy IF statements, and COMPUTE formulas.

Compromises On some issues, the members of the committee couldn’t agree, so they compromised.

For example, some members wanted Cobol to let programmers write mathematical formulas by using these symbols:

+       -       *       /       =       (       )

But other members of the committee disagreed: they argued that since Cobol is for stupid businessmen who fear formulas, Cobol should use the words ADD, SUBTRACT, MULTIPLY, and DIVIDE instead. The committee compromised: when you write a Cobol program, you can use the words ADD, SUBTRACT, MULTIPLY, and DIVIDE; you can use a formula instead but just if you warn the computer by putting the word COMPUTE before the formula.

Can Cobol handle long numbers? How long? The committee decided that Cobol would handle any number up to 18 digits long and handle any variable name up to 30 characters long. So the limits of Cobol are “18 and 30”.

Why did the committee pick the numbers “18 and 30” instead of “16 and 32”? Answer: some manufacturers wanted “16 and 32” (because their computers were based on the numbers 16 and 32), but other manufacturers wanted other combinations (such as “24 and 36”); the committee, hunting for a compromise, chose “18 and 30”, because nobody wanted it, and so it would give no manufacturer an unfair advantage over competitors. In other words, Cobol was designed to be equally terrible for everybody! That’s politics!

Cobol’s popularity In 1960, the Defense Department announced it would buy just computers that understand Cobol, unless a manufacturer can demonstrate why Cobol isn’t helpful. In 1961, Westinghouse Electric Corp. made a similar announcement. Other companies followed. Cobol became the most popular computer language.

Today it’s still the most popular computer language for maxicomputers, though programmers on minicomputers and microcomputers have switched to newer languages.

Improvements The original version of Cobol was finished in 1960 and called Cobol 60. Then came an improvement, called Cobol 61. The verb SORT and a “Report Writer” feature were added in 1962. Then came Cobol 65, Cobol 68, Cobol 74, and Cobol 85.

Cobol’s most obvious flaw To write a Cobol program, you must put info about file labeling into the data division’s FD command. Since file labeling describes the environment, not the data, Cobol should have been changed, to put the labeling in the environment division instead.

Jean Sammet, who headed some of the Short-Term Committee’s subcommittees, admits her group goofed when it decided to put labeling in the data division. But Cobol’s too old to change now.

Basic

The first version of Basic was developed in 1963 and 1964 by a genius (John Kemeny) and his friend (Tom Kurtz).

How the genius grew up John Kemeny was a Jew born in Hungary in 1926. In 1940 he and his parents fled from the Nazis and came to America. Though he knew hardly any English when he began high school in New York, he learned enough so he graduated as the top student in the class. Four years later, he graduated from Princeton summa cum laude even though he had to spend 1½ of those years in the Army, where he helped solve equations for the atomic bomb.

Two years after his B.A., Princeton gave him a Ph.D. in mathematics and philosophy, because his thesis on symbolic logic combined both fields.

While working for the Ph.D., he was Einstein’s youngest assistant. He told Einstein he wanted to quit math and instead hand out leaflets for world peace, but Einstein said leafleting would waste his talents; the best way for him to help world peace would be to become a famous mathematician, so people would listen to him, as they had to Einstein. He took Einstein’s advice and stayed with math.

After getting his Ph.D., he taught symbolic logic in Princeton’s philosophy department. In 1953, most of Dartmouth College’s math professors were retiring, so Dartmouth asked him to come to Dartmouth, chair the department, and bring his friends. He accepted the offer and brought his friends. That’s how Dartmouth stole Princeton’s math department.

At Dartmouth, Kemeny invented several new branches of math. Then Kemeny’s department got General Electric to sell Dartmouth a computer at a 90% discount, in return for which his department had to invent programs for that computer and let General Electric use them. To write the programs, Kemeny invented his own little computer language in 1963 and showed it to his colleague Tom Kurtz, who knew less about philosophy but more about computers. Kurtz added features from Algol and Fortran and called the combination Basic.

After inventing Basic, Kemeny got bored and thought of quitting Dartmouth. Then Dartmouth asked him to become the college’s president. He accepted.

Later, when the Three-Mile Island nuclear power plant almost exploded, President Jimmy Carter told Kemeny to head the investigation, because of Kemeny’s reputation for philosophical and scientific impartiality. Kemeny’s report was impartial — and sharply critical of the nuclear industry.

Basic versus Algol & Fortran Basic is simpler than both Algol and Fortran in two ways:

In Algol and Fortran, you must tell the computer which variables are integers and which are reals. In Algol, you do that by saying INTEGER or REAL. In Fortran, you do that by choosing an appropriate first letter for the variable’s name. In Basic, the computer assumes all variables are real, unless you specifically say otherwise.

In Algol and Fortran, output is a hassle. In Fortran, you have to worry about FORMATs. In Algol, each computer handles output differently — and in most cases strangely. Basic’s PRINT statement automatically invents a good format.

Is Basic closer to Algol than to Fortran? On the one hand, Basic uses the Algol words FOR, STEP, and THEN and the Algol symbol (or ^). On the other hand, Basic uses the Fortran words RETURN and DIMENSION (abbreviated DIM); and Basic’s “FOR I = 1 TO 9 STEP 2” puts the step size at the end of the statement, like FORTRAN’s “DO 30 I = 1,9,2” and unlike Algol’s “FOR I:=1 STEP 2 UNTIL 9”.

Basic versus Joss Basic is not the simplest computer language. Joss, which was developed a year earlier by the Rand Corporation, is simpler to learn. But Joss runs slower, requires more memory, lacks string variables, and doesn’t let you name your programs (you must give each program a number instead, and remember what the number was).

A few programmers still use Joss and 3 of its variants, called Aid, Focal, and Mumps. Aid appeals to high-school kids; Focal appeals to scientists; Mumps appeals to doctors designing databases of patient records. Though Mumps does have string variables and other modern features, it’s being replaced by newer database languages such as DBase.

6 versions Kemeny & Kurtz finished the original version of Basic in May 1964. It included just these statements:

PRINT, GO TO, IF...THEN, FOR...NEXT, DATA...READ, GOSUB...RETURN, DIM, LET (for commands such as LET X=3), REM (for REMarks and comments), DEF (to DEFine your own functions), and END

In that version, the only punctuation allowed in the PRINT statement was the comma.

The 2nd version of Basic (October 1964) added the semicolon.

The 3rd version (1966) added the words INPUT, RESTORE, and MAT. (The word MAT helps you manipulate a “MATrix”, which means an “array”. Today, most versions of Basic omit the word MAT because its definition consumes too much RAM.)

In all those versions, you could use variables. For example, you could say LET X=3. A variable was a letter that stood for a number. The 4th version (1967) added a new concept: string variables (such as A\$). That version also added TAB (to improve the printing), RANDOMIZE (to improve RND), and ON...GO TO.

The 5th version (1970) added data files (sequential access and random access).

The 6th version (1971) added PRINT USING and a sophisticated way to handle subroutines.

How Basic became popular During the 1960’s and 1970’s, Kemeny & Kurtz worked on Basic with a fervor that was almost religious.

They believed every college graduate should know how to program a computer, and be as literate in Basic as in English.

They convinced Dartmouth to spend as much on its computer as on the college library. They put computer terminals in most college buildings (even the dorms) and let all children in the town come onto the campus and join the fun. Altogether, the campus had about 300 terminals. Over 90% of all Dartmouth students used Basic before they graduated.

Dartmouth trained high-school teachers how to use Basic. Soon many colleges, high schools, and prep schools throughout New England had terminals connected to Dartmouth’s computer by phone.

Dartmouth’s computer was built by General Electric, which quit making computers and sold its computer factory to Honeywell. So Dartmouth’s computer became called a “Honeywell”.

Since Dartmouth’s research on Basic was partially funded by the National Science Foundation, Basic was in the public domain. Other computer manufacturers could use it without worrying about copyrights or patents.

DEC The first company to copy Dartmouth’s ideas was Digital Equipment Corporation (DEC, pronounced “deck”).

DEC put Basic and Focal on DEC’s first popular minicomputer, the PDP-8. When DEC saw that programmers preferred Basic, DEC stopped developing Focal and devoted all its energies to improving Basic further.

DEC invented fancier minicomputers (the PDP-11 and Vax) and maxicomputers (the DECsystem-10 and DECsystem-20) and put Basic on all of them. DEC’s versions of Basic were similar to Dartmouth’s. Though the versions put on the PDP-8 were primitive (almost as bad as Dartmouth’s first edition), the versions put on DEC’s fancier computers were sophisticated. Eventually, DEC put decent versions of Basic even on the PDP-8.

DEC’s best version of Basic is Vax Basic, which works just on Vax computers. DEC’s second-best version of Basic is Basic-Plus-2, which works on the Vax, the PDP-11, and the DECsystem-20. DEC’s third-best version of Basic is Basic-Plus, which works only on the PDP-11. DEC’s other versions of Basic aren’t as fancy.

HP Soon after DEC started putting Basic on its computers, Hewlett-Packard (HP) did likewise.

HP put Basic on the HP-2000 computer then put a better version of Basic on the HP-300 computer.

Unfortunately, HP’s Basic was more awkward than DEC’s. On HP computers, each time you used a string you had to write a “DIM statement” that warned the computer how long the string would be: the DIM statement had to say how many characters the string would contain.

How Microsoft Basic arose The first popular microcomputer was the Altair 8800, which used a version of Basic invented by a 20-year-old kid named Bill Gates. His version imitated DEC’s.

The Altair computer was manufactured by a company called Mits, which didn’t treat Bill Gates fairly, so he broke away from Mits and formed his own company, called Microsoft.

Bill Gates and his company, Microsoft, invented many versions of Basic.

The first was called 4K Basic because it consumed just 4K of memory chips (RAM or ROM). Then came 8K Basic (which included a bigger vocabulary) then came Extended Basic (which included an even bigger vocabulary and consumed 14K). All those versions were intended for primitive microcomputers that used tapes instead of disks. Finally came Disk Basic, which came on a disk and included all commands for handling disks.

All those versions of Basic were written for computers that contained an 8080 or Z-80 CPU. Simultaneously, he wrote 6502 Basic, for computers containing a 6502 CPU.

The Apple 2 version of 6502 Basic is called Applesoft BASIC.

Commodore’s version of 6502 Basic is called Commodore BASIC.

Unfortunately, 6502 Basic is primitive: it resembles his 8K Basic.

After writing 6502 Basic, Bill wrote an improved version of it, called 6809 Basic, just for Radio Shack’s Color Computer. Radio Shack calls it Extended Color Basic.

Texas Instruments (TI) asked Bill to write a version of Basic for TI computers. Bill said “yes”; but when TI told Bill what kind of Basic it wanted, Bill’s company (Microsoft) found 90 ways that TI’s desires would contradict Microsoft’s traditions. Microsoft convinced TI to change its mind and remove 80 of those 90 contradictions, but TI stood firm on the other 10.

So TI Basic (which is on the TI-990 and TI-99/4A computers) contradicts all other versions of Microsoft Basic in 10 ways. For example, in TI Basic, the INPUT statement uses a colon instead of a semicolon, and a multi-statement line uses a double colon (::) instead of a single colon.

Because of those differences, TI’s computers became unpopular, and TI stopped making them. Moral: if you contradict Bill, you die!

Later, Bill invented an amazingly wonderful version of Basic, better than all earlier versions. He called it Gee-Whiz Basic (GW Basic). It runs just on the IBM PC and clones. When you buy PC-DOS from IBM, you typically get GW Basic at no extra charge. (IBM calls it BasicA.) When you buy MS-DOS for an IBM clone, the typical dealer includes GW Basic at no extra charge.

Beyond GW Basic GW Basic was the last version of Basic that Bill developed personally. All Microsoft’s later improvements were done by his assistants. They created Microsoft Basic for the Mac, Amiga Microsoft Basic (for the Commodore’s Amiga computer), Quick Basic (for the IBM PC and clones), QBasic (which you get instead of GWBasic when you buy MS-DOS version 5 or 6), and Visual Basic (which lets you create Windows programs, so the human can use a mouse and pull-down menus). Those Basics are harder to learn how to use than GW Basic but have advantages: they run faster and include a better editor, more words from Algol and Pascal, and fancier output.

While developing those versions of Basic, Microsoft added 3 exciting new commands: SAY, END IF, and SUB.

The SAY command makes the computer talk, by using a voice synthesizer. For example, to make the computer’s voice say “I love you”, type this command:

SAY TRANSLATE\$("I LOVE YOU")

That makes the computer translate “I love you” into phonetics and then say the phonetics. That command works just on Amiga computers.

The END IF and SUB commands give Basic some of Pascal’s power. By using the END IF command, you can make the IF statement include many lines, like this:

IF AGE<18 THEN

PRINT "YOU ARE STILL A MINOR."

PRINT "AH, THE JOYS OF YOUTH!"

PRINT "I WISH I COULD BE AS YOUNG AS YOU!"

END IF

By using the SUB command, you can give a subroutine a name.

Divergences Microsoft’s versions of Basic are wonderful.

Over the years, several microcomputer manufacturers tried to invent their own versions of Basic, to avoid paying royalties to Bill Gates. They were sorry!

For example, Radio Shack tried hiring somebody else to write Radio Shack’s Basic. That person quit in the middle of the job; Radio Shack’s original Basic was never finished. Nicknamed “Level 1 Basic”, it was a half-done mess. Radio Shack, like an obedient puppy dog, then went to Bill, who finally wrote a decent version of Basic for Radio Shack; Bill’s version was called “Level 2”.

Apple’s original attempt at Basic was called “Apple Integer Basic”. It was written by Steve Wozniak and was terrible: it couldn’t handle decimals, and it made the mistake of imitating HP instead of DEC (because he’d worked at HP). Eventually, he wised up and hired Bill, who wrote Apple’s better Basic, called Applesoft (which means “Apple Basic by Microsoft”). Applesoft was intended for tapes, not disks. Later, when Steve Wozniak wanted to add disks to the Apple 2 computer, he made the mistake of not rehiring Bill — which is why the Apple 2’s disk system is worse than Radio Shack’s.

At Atari, an executive who didn’t want to hire Bill made the mistake of hiring the inventor of Apple’s disastrous DOS. That guy’s Basic, called Atari Basic, resembles HP’s Basic. Like Apple’s DOS, it looks pleasant at first glance but turns into a nightmare when you try to do any advanced programming. As a result, Atari’s computers didn’t become as popular as Atari hoped, and the executive who “didn’t want to hire Bill” was fired. Atari finally hired Bill’s company, Microsoft, which wrote Atari Microsoft Basic version 2.

Two other microcomputer manufacturers — North Star Computers and APF — tried developing their own versions of Basic to avoid paying royalties to Bill. Since their versions of Basic were lousy, they went out of business.

While DEC, HP, Microsoft, and other companies were developing their own versions of Basic, professors back at Dartmouth College were still tinkering with Dartmouth Basic version 6. In 1976, Professor Steve Garland added more commands from Algol, PL/I, and Pascal to Dartmouth Basic. He called his version Structured Basic (SBasic).

One of Basic’s inventors, Professor Tom Kurtz, became chairman of an Ansi committee to standardize Basic. His committee published two reports:

The 1977 report defined Ansi Standard Minimal Basic, a minimal standard that all advertised versions of “Basic” should live up to. That report was reasonable; everybody agreed to abide by it. (Microsoft’s old versions of Basic were written before that report came out. Microsoft Disk Basic version 5 was Microsoft’s first version to obey that standard.)

In 1985, Ansi created a more ambitious report, to standardize Basic’s most advanced features. The report said Basic’s advanced features should closely follow SBasic. But Bill Gates, who invented Microsoft Basic and was also on the committee, disliked some aspects of SBasic and quit the committee. (He was particularly annoyed by the committee’s desire to include Dartmouth’s MAT commands, which consume lots of RAM and used rarely.) He refused to follow the committee’s recommendations.

That left two standards for advanced Basic: the “official” standard ( defined by the Ansi committee) and the “de facto” standard (Bill Gates’ Microsoft Basics, such as GW Basic).

Those two standards differ from each other. For example, in GW Basic you say:

10 INPUT "WHAT IS YOUR NAME"; A\$

In Ansi Basic, you say this instead:

10 INPUT PROMPT "WHAT IS YOUR NAME? ": A\$

Notice that in Ansi Basic, you must insert the word PROMPT after INPUT, type a colon instead of a semicolon, and insert a question mark and blank space before the second quotation mark.

Tom Kurtz (who chaired the Ansi committee) and John Kemeny (who invented Basic with Tom Kurtz) put Ansi Basic onto Dartmouth’s computer. So Ansi Basic became Dartmouth’s 7th official version of Basic. Then Kurtz & Kemeny left Dartmouth and formed their own company, which invented True Basic (an Ansi Basic version for the IBM PC & Mac).

Since Microsoft’s Basic versions have become the de facto standard and since True Basic isn’t much better, hardly anybody bother switching from Microsoft Basic to True Basic.

Comparison chart Here are 9 commands in advanced Basic:

USING, LINE, CIRCLE, SOUND, PLAY, SAY, ELSE, END IF, SUB

Here’s what they accomplish:

“USING” lets you control how many digits print after the decimal point.

“LINE” makes the computer draw a diagonal line across the screen.

“CIRCLE” makes the computer draw a circle as big as you wish.

“SOUND” and “PLAY” make the computer create music.

“SAY” makes the computer talk.

“ELSE” and “END IF” let you create fancy IF statements.

“SUB” lets you name subroutines.

This chart shows which versions of Basic understand those 9 commands:

IBM PC with QBasic (or Visual Basic’s version 2 or later)

understands 8 of the commands (all except SAY)

Commodore Amiga with Microsoft Basic

understands 8 of the commands (all except PLAY)

Apple Mac with Quick Basic

understands 7 of the commands (all except SAY and PLAY)

IBM PC (with GW Basic), Commodore 128, or Radio Shack TRS-80 Color

understands 6 of the commands (all except SAY, END IF, and SUB)

Atari ST

understands 5 of the commands (all except PLAY, SAY, END IF, and SUB)

Atari XE (or XL) with Microsoft Basic

understands just 4 commands (USING, LINE, SOUND, and ELSE)

Radio Shack TRS-80 Model 3, 4, 4P, or 4D

understands just 2 commands (USING and ELSE)

Apple 2, 2+, 2e, 2c, 2c+, or 2GS understands just 1 command (LINE)

Commodore 64 or Vic-20 understands no commands

Notice that the Commodore 128 and Radio Shack TRS-80 Color Computer understand 6 of the commands, while the more expensive Apple 2c understands just 1 command. If schools would have bought Commodore 128 and Radio Shack TRS-80 Color Computers instead of Apple 2c’s, students would have become better programmers!

PL/I

During the early 1960’s, IBM sold two kinds of computers: one kind for scientists, the other kind was for business bookkeepers. For the scientific kind of computer, the most popular language was Fortran. For the business kind of computer, the most popular language was Cobol.

In 1962, IBM secretly began working on a project to create a single, big computer that could be used by everybody: scientists and businesses. IBM called it the IBM 360, because it could handle the full circle of applications. What language should the IBM 360 be programmed in? IBM decided to invent a single language that could be used for both science and business.

IBM’s first attempt at such a language was “Fortran V”. It ran all the Fortran IV programs but added commands for handling strings and fields in data files. Instead of announcing Fortran V, IBM began working in 1963 on an even more powerful language called “Fortran VI”, which would resemble Fortran but be much more powerful and modern (and hence incompatible). It would also include all important features of Cobol and Algol.

As work on Fortran VI progressed, IBM realized it would be so different from traditional Fortran that it should have a different name. In 1964, IBM changed the name to “NPL” (New Programming Language), since the language was intended to go with the IBM 360 and the rest of IBM’s New Product Line. But IBM discovered the letters “NPL” already stood for the National Physics Laboratory in England, so IBM changed the language’s name to Programming Language One (PL/I), to brag it was the first good programming language and all predecessors were worth zero by comparison.

Troubles The committee that invented PL/I had a hard time.

The committee included just 6 official members (3 from IBM and 3 from a Fortran user group). A few friends of the committee attended also. The committee could meet only on weekends and just in hotel rooms in New York State and California. The first meeting was in October 1963 (at the Motel-on-the-Mountain on the New York Thruway). IBM wanted the entire language design to be finished in 2 months (a rush job!), but the committee took 4 months, finishing in February 1964.

After the design was finished, the language still had to be put on the computer. Since that took 2½ more years of programming and polishing, the language wasn’t available for sale to IBM’s customers until August 1966.

That was too late. It was after IBM had already begun shipping the IBM 360. The 360’s customers continued using Fortran and Cobol, since PL/I wasn’t available initially. After those customers bought, installed, and learned how to use Fortran and Cobol on the 360, they refused to take the trouble to switch to PL/I, especially since PL/I was expensive (requiring twice as much RAM as Cobol, 4 times as much RAM as Fortran) and ran slowly (1½ times as long to compile as Cobol, twice as long as Fortran). Most programmers already knew Fortran or Cobol, were satisfied with those languages, and weren’t willing to spend the time to learn something new.

Some programmers praised PL/I for being amazingly powerful, but others called it just a scheme to get people to buy more RAM. Critics call it a disorganized mess, an “ugly kitchen sink of a language”, thrown together by a committee that was too rushed.

Since PL/I is so big, hardly anybody understands it all. As a PL/I programmer, you study just the part of the language you plan to use. But if you make a mistake, the computer might not gripe: instead, it might think you’re trying to give a different PL/I command from a language part you never studied. Instead of griping, the computer will perform an instruction that wasn’t what you meant.

Stripped versions In 1972, Cornell University developed a stripped-down version of PL/I for students. That version, called PL/C, is a compromise between PL/I’s power and Algol’s pure simplicity.

In 1975, The University of Toronto developed an even more stripped-down version of PL/I, and called it SP/k: it ran faster and printed messages that were more helpful. SP/k came in several sizes: the tiniest was SP/1; the largest was SP/8.

Stripped-down versions of PL/I stayed popular in universities until about 1980, when universities switched to Pascal.

Digital Research invented a tiny version of PL/I for microcomputers and called it PL/M. It couldn’t handle decimals. Most PL/M programmers eventually switched to C.

The full PL/I is still used on big IBM computers, because full PL/I is the only language that includes enough commands to let programmers unleash IBM’s full power.

Statements PL/I uses many statements for input and output. The statement’s meaning depends mainly on the statement’s first word:

First word What the computer will do

GET       input from a terminal or simple file

PUT       print on a terminal or simple file

OPEN        start using a file

CLOSE     stop using a file

READ        input from a file whose picture is unedited

WRITE     print on a file whose picture is unedited

DELETE    delete an item from a file

REWRITE      replace an item in a file

LOCATE    print a "based" variable onto a file

UNLOCK    let other programs use the file

FORMAT    use a certain form for spacing the input and output

DISPLAY    chat with operator who sits at computer’s main terminal

These statements interrupt:

First word What the computer will do

STOP      stop the program

HALT        interrupt the program; free the terminal to do other tasks

DELAY     pause for a certain number of milliseconds

WAIT      pause until other simultaneous routines finish their tasks

These statements handle conditions:

First word What the computer will do

IF        if a certain condition occurs now, do certain statements

ON        if a certain condition occurs later, do certain statements

SIGNAL    pretend a condition such as OVERFLOW occurs

REVERT    cancel the ON statements

These statements handle variables:

First word What the computer will do

DECLARE      make some variables be integers, other be reals, etc.

DEFAULT      assume all variables are integers, or a similar assumption

ALLOCATE    create a temporary variable

FREE      destroy a temporary variable and use its RAM otherwise

These statements handle general logic:

First word What the computer will do

GO        go to a different line

CALL        go to a subroutine

RETURN    return from a subroutine to the main routine

ENTRY     skip the subroutine’s previous lines; begin here instead

PROCEDURE  begin a program or subprogram

DO        begin a loop or compound statement

BEGIN     begin a block of statements

END       end program, subprogram., loop, compound statement, or block

Half of those statements are borrowed from Fortran, Algol, and Cobol.

from Fortran: FORMAT, STOP, CALL, RETURN, DO

from Algol:        IF, GO, PROCEDURE, BEGIN, END

from Cobol:    OPEN, CLOSE, READ, WRITE, DISPLAY, EXIT

Like Algol, PL/I requires a semicolon at the end of each statement. Besides the statements listed above, you can also give an assignment statement (such as “N=5;”), a null statement (which consists of just a semicolon), and a preprocessor statement (which tells the computer how to create its own program).

Pascal

In 1968, a European committee invented “Algol 68,” which was strange: it even required you to spell some commands backwards. Some members of the committee disagreed with the majority and thought Algol 68 was nuts. One of those dissidents, Niklaus Wirth, quit the committee and created his own Algol version, which he called Pascal. Today, most computerists feel he was right: Pascal is better than Algol 68.

He wrote Pascal in Switzerland, on a CDC maxicomputer that used punched cards. His version of Pascal couldn’t handle video screens, couldn’t handle random-access data files, and couldn’t handle strings well. Those 3 limitations were corrected in later Pascal versions, especially the one invented at the University of California at San Diego (UCSD), which also includes Logo-style commands that move a turtle.

Apple’s Pascal Apple Computer Company got permission to sell an Apple version of UCSD Pascal. Apple ran full-page ads bragging that the Apple 2 was the only popular microcomputer that could handle Pascal.

Apple Computer Company sold an Apple 2 add-on called the Apple Language System, whose \$495 price included disks for Pascal & advanced Basic, plus 16K of extra RAM. Many people bought that system were disappointed, when they discovered that Pascal is harder to learn than Basic.

Pascal is helpful just if the program you’re writing is long. Pascal helps you organize and dissect long programs more easily than Basic. But the average Apple 2 owner never wrote long programs and never needed Pascal. Many of Apple’s customers felt “ripped off”, since they spent \$495 uselessly.

Pascal’s rise Many programmers who’d written big Fortran programs for big computers switched to Pascal, because Pascal helps organize large programs, and because Fortran is archaic. Many programmers who’d been using PL/I switched to Pascal, because Pascal consumes less RAM than PL/I and fits in smaller computers.

Pascal became popular. Many colleges required freshman computer-science majors to take Pascal, so the College Entrance Examination Board’s Advanced Placement Test in Computer Science required knowing Pascal. Many high-school students studied Pascal to pass that test and prepare for college.

Pascal’s fall Basic has improved (by incorporating many features from Pascal), so Pascal no longer has much advantage over Basic. Now students skip Pascal: after learning Basic, they skip past Pascal to tougher languages: Java and C++. Now the Advanced Placement Test in Computer Science requires knowing Java instead of Pascal.

Pascal is ignored.

Modula

After Niklaus Wirth invented Pascal, he designed a more ambitious language, called Modula. He designed the Modula’s first version in 1975, then Modula-2 in 1979. When today’s programmers discuss “Modula”, they mean Modula-2.

Modula-2 resembles Pascal. Like Pascal, Modula-2 requires each program’s main routing to begin with the word BEGIN; but Modula-2 does not require you to say BEGIN after DO WHILE or IF THEN:

Pascal                                                                Modula-2

IF AGE<18 THEN                    IF AGE<18 THEN

BEGIN                             WRITESTRING("YOU ARE STILL A MINOR");

WRITELN('YOU ARE STILL A MINOR');    WRITESTRING("AH, THE JOYS OF YOUTH");

WRITELN('AH, THE JOYS OF YOUTH'); ELSE

ELSE                                WRITESTRING("WE CAN HAVE ADULT FUN")

BEGIN                          END;

END;

That example shows 4 ways that Modula-2 differs from Pascal: Modula-2 says WRITESTRING instead of WRITELN, uses regular quotation marks (") instead of apostrophes, lets you omit the word BEGIN after IF ELSE (and WHILE DO), and lets you omit the word END before ELSE.

Advanced programmers like Modula-2 better than Pascal because Modula-2 includes extra commands for handling subroutines.

C

Many programmers use C.

How C arose In 1963 at England’s Cambridge University and the University of London, researchers developed a “practical” version of Algol and called it the Combined Programming Language (CPL). In 1967 at Cambridge University, Martin Richards invented a simpler, stripped-down version of CPL and called it Basic CPL (BCPL). In 1970 at Bell Labs, Ken Thompson developed a version that was even more stripped-down and simpler; since it included just the most critical part of BCPL, he called it B.

Ken had stripped down the language too much. It no longer contained enough commands to do practical programming. In 1971, his colleague Dennis Ritchie added a few commands to B, to form a more extensive language, which he called New B. Then he added even more commands and called the result C, because it came after B.

Most of C was invented in 1972. In 1973, it was improved enough so that it was used for something practical: developing a new version of the Unix operating system. (The original version of Unix had been created at Bell Labs by using B. Beginning in 1973, Unix versions were created by using C.)

So C is a souped-up version of New B, which is a souped-up version of B, which is a stripped-down version of BCPL, which is a stripped-down version of CPL, which is a “practical” version of Algol.

C’s peculiarities Like B, C is a tiny language.

C doesn’t even include any words for input or output. When you buy C, you also get a library of routines that can be added to C. The library includes words for output (such as printf), input (such as scanf), math functions (such as sqrt), and other goodies.

When you write a program in C, you can choose whichever parts of the library you need: the other parts of the library don’t bother to stay in RAM. So if your program uses just a few of the library’s functions, running it will consume very little RAM. It will consume less RAM than if the program were written in Basic or Pascal.

In Basic, if you reserve 20 RAM locations for X (by saying DIM X(20)) and then say X(21)=3.7, the computer will gripe, because you haven’t reserved a RAM location for X(21). If you use C instead, the computer will not gripe about that kind of error; instead, the computer will store the number 3.7 in the RAM location immediately after X(20), even if that location’s already being used by another variable, such as Y. As a result, Y will get messed up. Moral: C programs run quickly and dangerously, because in C the computer never bothers to check your program’s reasonableness.

In your program, which variables are integers, and which are real?

Basic assumes all variables are real.

Fortran & PL/I assume all variables beginning with I, J, K, L, M, and N are integers and the rest are real.

Algol & Pascal make no assumptions; they require you to declare “integer” or “real” for each variable.

C assumes all variables are integers, unless you specifically say otherwise.

In 1975, the U.S. Department of Defense decided it wanted a better kind of computer language and wrote a list of requirements the language would have to meet.

The original list of requirements was called the Strawman Requirements (1975). Then came improved versions, called Woodenman (1975), Tinman (1976), Ironman (1978), and finally Steelman (1979).

While the Department was moving from Strawman to Steelman, it checked whether any existing computer language could meet such requirements. The Department decided that no existing computer language came even close to meeting the requirements, so a new language would have to be invented. The Department required the new language to resemble Pascal, Algol 68, or PL/I but be better.

Contest In 1977, the Department held a contest, to see which software company could invent a language meeting such specifications (which were in the process of changing from Tinman to Ironman).

16 companies entered the contest.

The Department selected 4 semifinalists and paid them to continue their research for 6 more months. The semifinalists were CII-Honeywell-Bull (which is French and owned partly by Honeywell), Intermetrics (in Cambridge, Massachusetts), SRI International, and Softech.

In 1978, the semifinalists submitted improved designs, which were all souped-up versions of Pascal (instead of Algol 68 or PL/I). To make the contest fair and prevent bribery, the judges weren’t told which design belonged to which company. The 4 designs were called “Green”, “Red”, “Yellow”, and “Blue”.

Yellow and Blue lost. The winning designs were Green (designed by CII-Honeywell-Bull) and Red (designed by Intermetrics).

The Department paid the two winning companies to continue their research for one more year. In 1979, the winning companies submitted their improved versions.

The winner was the Green language, designed by CII-Honeywell-Bull.

The Department decided that the Green language would be called Ada to honor Ada Lovelace, the woman who was the world’s first programmer.

So Ada is a Pascal-like language developed by a French company (CII-Honeywell-Bull) under contract to the U.S. Department of Defense.

Ada is too big to be practical. Researchers made computers understand part of Ada but had difficulty making computers understand the whole language.

DBase

DBase was invented by Wayne Ratliff because he wanted to bet on which football teams would win the 1978 season.

To bet wisely, he needed to know how each team scored in previous games, so every Monday he clipped pages of football scores from newspapers. Soon his whole room was covered with newspaper clippings. To reduce the clutter, he decided to write a data-management program to keep track of all the statistics.

He worked at the Jet Propulsion Laboratory (JPL). His coworkers had invented a data-management system called the JPL Display and Information System (JPLDIS), which imitated IBM’s Retrieve. Unfortunately, Retrieve and JPLDIS both required maxicomputers. Working at home, he invented Vulcan, a stripped-down version of JPLDIS small enough to run on the CP/M microcomputer in his house and good enough to let him compile football statistics — though by then he’d lost interest in football and was more interested in the theory of data management and business applications.

In 1979, he advertised his Vulcan data-management system in Byte Magazine. The mailman delivered so many orders to his house that he didn’t have time to fill them all — especially since he still had a full-time job at JPL. He stopped advertising, to give himself a chance to catch up filling the orders.

In 1980, the owners of Discount Software phoned him, visited his home, examined Vulcan, and offered to market it for him. He agreed.

Since “Discount Software” was the wrong name to market Vulcan under, Discount Software’s owners — Hal Lashlee and George Tate — thought of marketing Vulcan under the name “Lashlee-Tate Software”. But since “Lashlee” sounded wimpy, they changed the name to Ashton-Tate Software.

Instead of selling Vulcan’s original version, Ashton-Tate Software decided to sell Wayne’s further improvement, called DBase 2. It ran faster, looked prettier on the screen, and was easier to use.

At Ashton-Tate, George Tate did the managing. Hal Lashlee was a silent partner who just contributed capital.

Ad George Tate hired Hal Pawluck to write an ad for DBase 2. Hal’s clever ad showed a photo of a bilge pump (the kind of pump that removes water from a ship’s bilge). The ad’s headline said: “DBase versus the Bilge Pump”. The ad went on to say that most database systems are like bilge pumps: they suck!

That explicit ad appeared in Infoworld, a weekly newspaper read all computer experts. Suddenly, all experts knew that DBase was the database-management system that claimed not to suck.

The ad generated just one big complaint — from the company that manufactured the bilge pump!

George Tate offered to add a footnote saying “This bilge pump does not suck”. The pump manufacturer didn’t like that either but stopped complaining.

Beyond DBase 2 The original DBase 2 ran on computers using the CP/M operating system. It worked well. When IBM began selling the IBM PC, Wayne invented an IBM PC version of DBase 2, but it was buggy.

He created those early versions of DBase by using assembly language. By using C instead, he finally created an IBM PC version that worked reliably and included extra commands. He called it DBase 3.

DBase 2 and DBase 3 were sold as programming languages, but many people who wanted to use databases didn’t want to learn programming or hire a programmer. So Ashton-Tate created a new version, called DBase 3 Plus, which you can control by using menus instead of typing programming commands; but those menus are hard to learn how to use and incomplete: they don’t let you tap DBase 3 Plus’s full power, which requires you to learn programming.

In 1988, Ashton-Tate began shipping DBase 4, which includes extra programming commands.

Some DBase 4 commands were copied from a database language called Structured Query Language (SQL), which IBM invented for mainframes. DBase 4 also boasted better menus than DBase 3 Plus. Unfortunately, Ashton-Tate priced DBase 4 high: \$795 for the plain version, \$1295 for the “developer’s” version.

Over the years, Ashton-Tate became a stodgy bureaucracy. George Tate died, Wayne Ratliff quit, the company’s list price for DBase grew ridiculously high, and the company was callous to DBase users.

In 1991, Borland bought Ashton-Tate. In 1994, Borland began selling DBase 5, then further improvements. In 1999, Borland gave up trying to sell DBase; Borland transferred all DBase rights to KSoft, which sold Visual DBase 7.5 and tried to develop DBase 2000 (DB2K). The newest version of DBase is DBase Plus 2, published by from DataBased Intelligence (2548 Vestal Parkway East, Vestal NY 13850, phone 607-729-0234 or toll-free 877-322-7340, www.dbase.com).

Other companies make Dbase clones that work better than DBase itself! The most popular clone is Visual FoxPro 9: it runs faster than DBase, includes extra commands, and is marketed by Microsoft.

Easy

Easy is a language I developed several years ago. It combines the best features of all other languages. It’s easy to learn, because it uses just these 12 keywords:

SAY & GET     LET

REPEAT & SKIP HERE

IF & PICK     LOOP

PREPARE & DATA HOW

Here’s how to use them.…

SAY Easy uses the word SAY instead of Basic’s word PRINT, because SAY is briefer. If you want the computer to say the answer to 2+2, give this command:

SAY 2+2

The computer will say the answer:

4

Whenever the computer prints, it automatically prints a blank space afterwards but does not press the Enter key. So if you run this program —

SAY "LOVE"

SAY "HATE"

the computer will say:

LOVE HATE

Here’s a fancier example:

SAY "LOVE" AS 3 AT 20 15 TRIM !

The “AS 3” is a format: it makes the computer print just the first 3 letters of LOVE. The “AT 20 15” makes the computer begin printing LOVE at the screen’s pixel whose X coordinate is 20 and whose Y coordinate is 15. The computer usually prints a blank space after everything, but the word TRIM suppresses that blank space. The exclamation point makes the computer press the Enter key afterwards.

Here’s another example:

SAY TO SCREEN PRINTER HARRY

It means that henceforth, whenever you give a SAY command, the computer will print the answer simultaneously onto your screen, onto your printer, and onto a disk file named HARRY. If you ever want to cancel that “SAY TO” command, give a “SAY TO” command that contradicts it.

GET Easy uses the word GET instead of Basic’s word INPUT, because GET is briefer. The command GET X makes the computer wait for you to input the value of X. Above the GET command, you typically put a SAY command that makes the computer ask a question.

You can make the GET command fancy, like this:

GET X AS 3 AT 20 15 WAIT 5

The “AS 3” tells the computer that X will be just 3 characters; the computer waits for you to type just 3 characters and doesn’t require you to press the Enter key afterwards. The “AT 20 15” makes the computer move to pixel 20 15 before your typing begins, so your input appears at that part of the screen. The “WAIT 5” makes the computer wait just 5 seconds for your response. If you reply within 5 seconds, the computer sets TIME equal to how many seconds you took. If you do not reply within the 5 seconds, the computer sets TIME equal to -1.

LET The LET statement resembles Basic’s. For example, you can say:

LET R=4

To let R be a random decimal, type:

LET R=RANDOM

To let R be a random integer from 1 to 6, type:

LET R=RANDOM TO 6

To let R be a random integer from -3 to 5, type:

LET R=RANDOM FROM -3 TO 5

REPEAT If you put the word REPEAT at the bottom of your program, the computer will repeat the entire program again and again, forming an infinite loop.

SKIP If you put the word SKIP in the middle of your program, the computer will skip the bottom part of the program. SKIP is like BASIC’s END or STOP.

HERE In the middle of your program, you can say:

HERE IS FRED

An earlier line can say SKIP TO FRED. A later line can say REPEAT FROM FRED. The SKIP TO and REPEAT FROM are like Basic’s GO TO.

IF In your program, a line can say:

IF X<3

Underneath that line, you must put some indented lines, which the computer will do if X<3.

Suppose you give a student a test on which the score can be between 0 and 100. If the student’s score is 100, let’s make the computer say “PERFECT”; if the score is below 100 but at least 70, let’s make the computer say the score and also say “OKAY THOUGH NOT PERFECT”; if the score is below 70, let’s make the computer say “YOU FAILED”. Here’s how:

IF SCORE=100

SAY "PERFECT"

IF SCORE<100 AND SCORE>=70

SAY SCORE

SAY "OKAY THOUGH NOT PERFECT"

IF SCORE<70

SAY "YOU FAILED"

To shorten the program, use the words NOT and BUT:

IF SCORE=100

SAY "PERFECT"

IF NOT BUT SCORE>=70

SAY SCORE

SAY "OKAY THOUGH NOT PERFECT"

IF NOT

SAY "YOU FAILED"

The phrase “IF NOT” is like Basic’s ELSE. The phrase “IF NOT BUT” is like Basic’s ELSE IF.

PICK You can shorten that example even further, by telling the computer to pick just the first IF that’s true:

PICK SCORE

IF 100

SAY "PERFECT"

IF >=70

SAY SCORE

SAY "OKAY THOUGH NOT PERFECT"

IF NOT

SAY "YOU FAILED"

LOOP If you put the word LOOP above indented lines, the computer will do those lines repeatedly. For example, this program makes the computer say the words CAT and DOG repeatedly:

LOOP

SAY "CAT"

SAY "DOG"

This program makes the computer say 5, 8, 11, 14, and 17:

LOOP I FROM 5 BY 3 TO 17

SAY I

That LOOP statement is like Basic’s “FOR I = 5 TO 17 STEP 3”. If you omit the “BY 3”, the computer will assume “BY 1”. If you omit the “FROM 5”, the computer will assume “FROM 1”. If you omit the “TO 17”, the computer will assume “to infinity”.

To make the computer count down instead of up, insert the word DOWN, like this:

LOOP I FROM 17 DOWN BY 3 TO 5

PREPARE To do an unusual activity, you should PREPARE the computer for it. For example, if you want to use subscripted variables such as X(100), you should tell the computer:

PREPARE X(100)

In that example, PREPARE is like Basic’s DIM.

DATA Easy’s DATA statement resembles Basic’s. But instead of saying READ X, say:

LET X=NEXT

HOW In Easy, you can give any command you wish, such as:

PRETEND YOU ARE HUMAN

If you give that command, you must also give an explanation that begins with the words:

HOW TO PRETEND YOU ARE HUMAN

Interrelated features In the middle of a loop, you can abort the loop. To skip out of the loop (and progress to the rest of the program), say SKIP LOOP. To hop back to the beginning of the loop (to do the next iteration of loop), say REPEAT LOOP.

Similarly, you can say SKIP IF (which makes the computer skip out of an IF) and REPEAT IF (which makes the computer repeat the IF statement, and thereby imitate Pascal’s WHILE).

Apostrophe Like Basic, Easy uses an apostrophe to begin a comment. The computer ignores everything to the right of an apostrophe, unless the apostrophe is between quotation marks or in a DATA statement.

Comma If two statements begin with the same word, you can combine them into a single statement, by using a comma.

For example, instead of saying —

LET X=4

LET Y=7

you can say:

LET X=4, Y=7

PRETEND YOU ARE HUMAN

you can say:

PRETEND YOU ARE HUMAN, GOD IS DEAD

More info I stopped working on Easy in 1982 but expect to continue development again. To get on my mailing list of people who want details and updated info about Easy, phone me at 603-666-6644 or send me a postcard.

C++

Most C programmers have switched to an improved C, called C++.

Java

Java is a variant of C++ that runs slower but can be easier to learn.

While you’re using the Internet’s World Wide Web, you often see ads that are animated cartoons. Those ads are created by using Java. That’s Java’s main purpose: to create ads that are annoyingly eye-catching.

JavaScript

JavaScript is easier to learn than Java but lacks advanced commands.

Let’s examine the radical languages, beginning with the oldest radical — the oldest hippie — Lisp.

Lisp

Lisp is the only language made specifically to handle lists of concepts. It’s the most popular language for research into artificial intelligence.

It’s the father of Logo, which is “oversimplified Lisp” and the most popular language for young children. It inspired Prolog, which is a Lisp-like language that lets you make the computer imitate a wise expert and become an expert system.

Beginners in artificial intelligence love to play with Logo and Prolog, which are easier and more fun than Lisp. But most professionals continue to use Lisp because it’s more powerful than its children.

The original version of Lisp was called Lisp 1. Then came an improvement, called Lisp 1.5 (because it wasn’t different enough from LISP 1 to rate the title “LISP 2”). Then came a slight improvement on LISP 1.5, called Lisp 1.6. The newest version of LISP is called Common Lisp; it runs on maxicomputers, minicomputers, and microcomputers.

I’ll explain “typical” Lisp, which is halfway between Lisp 1.6 and Common Lisp.

Typical Lisp uses these symbols:

Basic       Lisp

5+2    (PLUS 5 2)

5-2    (DIFFERENCE 5 2)

5*2    (TIMES 5 2)

5/2    (QUOTIENT 5 2)

5^2    (EXPT 5 2)

"LOVE" 'LOVE old versions say (QUOTE LOVE)

If you want the computer to add 5 and 2, just type:

(PLUS 5 2)

When you press the Enter key at the end of that line, the computer will print the answer. (You do not have to say PRINT or any other special word.) The computer will print:

7

If you type —

(PLUS 1 3 1 1)

the computer will add 1, 3, 1, and 1 and print:

6

If you type —

(DIFFERENCE 7 (TIMES 2 3))

the computer will find the difference between 7 and 2*3 and print:

1

If you type —

'LOVE

the computer will print:

LOVE

Note you must type an apostrophe before LOVE but must not type an apostrophe afterwards. The apostrophe is called a single quotation mark (or a quote).

You can put a quote in front of a word (such as ‘LOVE) or in front of a parenthesized list of words, such as:

'(LAUGH LOUDLY)

That makes the computer print:

(LAUGH LOUDLY)

Lisp 1, Lisp 1.5, and Lisp 1.6 don’t understand the apostrophe. On those old versions of Lisp, say (QUOTE LOVE) instead of ‘LOVE, and say (QUOTE (LAUGH LOUDLY)) instead of ‘(LAUGH LOUDLY).

The theory of lists Lisp can handle lists. Each list must begin and end with a parenthesis.

Here’s a list of numbers: (5 7 4 2).

Here’s a list of words: (LOVE HATE WAR PEACE DEATH).

Here’s a list of numbers and words: (2 WOMEN KISS 7 MEN).

That list has five items: 2, WOMEN, KISS, 7, and MEN.

Here’s a list of four items: (HARRY LEMON (TICKLE MY TUBA TOMORROW AT TEN) RUSSIA). The first item is HARRY; the second is LEMON; the third is a list; the fourth is RUSSIA.

In a list, the first item is called the CAR, and the rest of the list is called the CDR (pronounced “could er” or “cudder” or “coo der”). For example, the CAR of (SAILORS DRINK WHISKEY) is SAILORS, and the CDR is (DRINK WHISKEY).

To make the computer find the CAR of (SAILORS DRINK WHISKEY), type this:

(CAR '(SAILORS DRINK WHISKEY))

The computer will print:

SAILORS

If you type —

(CDR '(SAILORS DRINK WHISKEY))

the computer will print:

(DRINK WHISKEY)

If you type —

(CAR (CDR '(SAILORS DRINK WHISKEY)))

the computer will find the CAR of the CDR of (SAILORS DRINK WHISKEY). Since the CDR of (SAILORS DRINK WHISKEY) is (DRINK WHISKEY), whose CAR is DRINK, the computer will print:

DRINK

You can insert an extra item at the beginning of a list, to form a longer list. For example, you can insert MANY at the beginning of (SAILORS DRINK WHISKEY), to form (MANY SAILORS DRINK WHISKEY). To do that, tell the computer to CONStruct the longer list, by typing:

(CONS 'MANY '(SAILORS DRINK WHISKEY))

The computer will print:

(MANY SAILORS DRINK WHISKEY)

Notice that CONS is the opposite of CAR and CDR. The CONS combines MANY with (SAILORS DRINK WHISKEY) to form (MANY SAILORS DRINK WHISKEY). The CAR and CDR break down (MANY SAILORS DRINK WHISKEY), to form MANY and (SAILORS DRINK WHISKEY).

Variables To make X stand for the number 7, say:

(SETQ X 7)

Then if you say —

(PLUS X 2)

the computer will print 9.

To make Y stand for the word LOVE, say:

(SETQ Y 'LOVE)

Then if you say —

Y

the computer will say:

LOVE

To make STOOGES stand for the list (MOE LARRY CURLEY), say:

(SETQ STOOGES '(MOE LARRY CURLEY))

Then if you say —

STOOGES

the computer will say:

(MOE LARRY CURLEY)

To find the first of the STOOGES, say:

(CAR STOOGES)

The computer will say:

MOE

Your own functions You can define your own functions. For example, you can define (DOUBLE X) to be 2*X, by typing this:

(DEFUN DOUBLE (X)

(TIMES 2 X)

)

Then if you say —

(DOUBLE 3)

the computer will print:

6

REPEAT Let’s define REPEAT to be a function, so that (REPEAT ‘LOVE 5) is (LOVE LOVE LOVE LOVE LOVE), and (REPEAT ‘KISS 3) is (KISS KISS KISS), and (REPEAT ‘KISS 0) is ().

If N is 0, we want (REPEAT X N) to be ().

If N is larger than 0, we want (REPEAT X N) to be a list of N X’s.

That’s X followed by N-1 more X’s.

That’s the CONS of X with a list of N-1 more X’s.

That’s the CONS of X with (REPEAT X (DIFFERENCE N 1)).

That’s (CONS X (REPEAT X (DIFFERENCE N 1))).

That’s (CONS X (REPEAT X (SUB1 N))), since (SUB1 N) means N-1 in LISP.

You can define the answer to (REPEAT X N) as follows: if N is 0, the answer is (); if N is not 0, the answer is (CONS X (REPEAT X (SUB 1 N))). Here’s how to type that definition:

(DEFUN REPEAT (X N)

(COND

((ZEROP N) ())

(T (CONS X (REPEAT X (SUB1 N))))

)

)

The top line says you’re going to DEfine a FUNction called REPEAT (X N). The next line says the answer depends on CONDitions. The next line gives one of those conditions: if N is ZERO, the answer is (). The next line says: otherwise, the value is (CONS X (REPEAT X (SUB1 N))). The next line closes the parentheses opened in the second line. The bottom line closes the parentheses opened in the top line.

Then if you type —

(REPEAT 'LOVE 5)

the computer will print:

(LOVE LOVE LOVE LOVE LOVE)

The definition is almost circular: the definition of REPEAT assumes you already know what REPEAT is. For example:

(REPEAT ‘KISS 3) is defined as the CONS of KISS with the following:

(REPEAT ‘KISS 2), which is defined as the CONS of KISS with the following:

(REPEAT ‘KISS 1), which is defined as the CONS of KISS with the following:

(REPEAT ‘KISS 1), which is defined as the CONS of KISS with the following:

(REPEAT ‘KISS 0), which is defined as ().

That kind of definition, which is almost circular, is called recursive.

You can say “The definition of REPEAT is recursive”, or “REPEAT is defined recursively”, or “REPEAT is defined by recursion”, or “REPEAT is defined by induction”, or “REPEAT is a recursive function”.

Lisp was the first popular language that allowed recursive definitions.

When the computer uses a recursive definition, the computer refers to the definition repeatedly before getting out of the circle. Since the computer repeats, it’s performing a loop. In traditional Basic and Fortran, the only way to make the computer perform a loop is to say GO TO or FOR or DO. Although Lisp contains a go-to command, Lisp programmers avoid it and write recursive definitions instead.

ITEM As another example of recursion, let’s define the function ITEM so (ITEM N X) is the Nth item in list X, and so (ITEM 3 ‘(MANY SAILORS DRINK WHISKEY)) is the 3rd item of (MANY SAILORS DRINK WHISKEY), which is DRINK.

If N is 1, (ITEM N X) is the first item in X, which is the CAR of X, which is (CAR X).

If N is larger than 1, (ITEM N X) is the Nth item in X. That’s the (N-1)th item in the CDR of X. That’s (ITEM (SUB1 N) (CDR X)).

So define (ITEM N X) as follows:

If N is 1, the answer is (CAR X).

If N is not 1, the answer is (ITEM (SUB 1 N) (CDR X)).

Here’s what to type:

(DEFUN ITEM (N X)

(COND

((ONEP N) (CAR X))

(T (ITEM (SUB1 N) (CDR X)))

)

)

If your computer doesn’t understand (ONEP N), say (EQUAL 1 N) instead.

Snobol

Snobol lets you analyze strings more easily than any other language. It can handle numbers also.

Simple example Here’s a simple Snobol program:

A = -2

B = A + 10.6

C = "BODY TEMPERATURE IS 9" B

OUTPUT = "MY " C

END

When you type the program, indent each line except END. Indent at least one space; you can indent more spaces if you wish. Put spaces around the symbols = and + and other operations.

The first line says A is the integer -2. The next line says B is the real number 8.6. The next line says C is the string “BODY TEMPERATURE IS 98.6”. The next line makes the computer print:

BODY TEMPERATURE IS 98.6

In Snobol, a variable’s name can be short (like A or B or C) or as long as you wish. The variable’s name can even contain periods, like this:

NUMBER.OF.BULLIES.I.SQUIRTED

Loop This program’s a loop:

FRED    OUTPUT = "CAT"

OUTPUT = "DOG" :(FRED)

END

The first line (whose name is FRED) makes the computer print:

CAT

The next line makes the computer print —

DOG

and then go to FRED. Altogether the computer will print:

CAT

DOG

CAT

DOG

CAT

DOG

etc.

Replace Snobol lets you replace a phrase easily.

X = "SIN ON A PIN WITH A DIN"

X "IN" = "UCK"

OUTPUT = X

END

The first line says X is the string “SIN ON A PIN WITH A DIN”. The next line says: in X, replace the first “IN” by “UCK”. So X becomes “SUCK ON A PIN WITH A DIN”. The next line says the output is X, so the computer will print:

SUCK ON A PIN WITH A DIN

That program changed the first “IN” to “UCK”. Here’s how to change every “IN” to “UCK”:

X = "SIN ON A PIN WITH A DIN"

X "IN" = "UCK"

X "IN" = "UCK"

X "IN" = "UCK"

OUTPUT = X

END

The first line says X is “SIN ON A PIN WITH A DIN”. The second line replaces an “IN” by “UCK”, so X becomes “SUCK ON A PIN WITH A DIN”. The next line replaces another “IN” by “UCK”, so X becomes “SUCK ON A PUCK WITH A DIN”. The next line replaces another “IN”, so X becomes “SUCK ON A PUCK WITH A DUCK”, which the next line prints.

This program does the same thing:

X = "SIN ON A PIN WITH A DIN"

LOOP    X "IN" = "UCK" :S(LOOP)

OUTPUT = X

END

Here’s how it works:

The first line says X is “SIN ON A PIN WITH A DIN”. The next line replaces “IN” successfully, so X becomes “SUCK ON A PIN WITH A DIN”. At the end of the line, the :S(LOOP) means: if Successful, go to LOOP. So the computer goes back to LOOP. The computer replaces “IN” successfully again, so X becomes “SUCK ON A PUCK WITH A DIN”, and the computer goes back to LOOP. The computer replaces “IN” successfully again, so X becomes “SUCK ON A PUCK WITH A DUCK”, and the computer goes back to LOOP. The computer does not succeed. So the computer ignores the :S(LOOP) and proceeds instead to the next line, which prints:

SUCK ON A PUCK WITH A DUCK

Delete This program deletes the first “IN”:

X = "SIN ON A PIN WITH A DIN"

X "IN" =

OUTPUT = X

END

The second line says to replace an “IN” by nothing, so the “IN” gets deleted. X becomes “S ON A PIN WITH A DIN”, which the computer will print.

This program deletes every “IN”:

X = "SIN ON A PIN WITH A DIN"

LOOP    X "IN" = :S(LOOP)

OUTPUT = X

END

The computer will print:

S ON A P WITH A D

Count Let’s count how often “IN” appears in “SIN ON A PIN WITH A DIN”. To do that, delete each “IN”; but each time you delete one, increase the COUNT by 1:

X = "SIN ON A PIN WITH A DIN"

COUNT = 0

LOOP    X "IN" = :F(ENDING)

COUNT = COUNT + 1 :(LOOP)

ENDING  OUTPUT = COUNT

END

The third line tries to delete an “IN”: if successful, the computer proceeds to the next line, which increases the COUNT and goes back to LOOP; if failing (because no “IN” remains), the computer goes to ENDING, which prints the COUNT. The computer will print:

3

How Snobol developed At MIT during the 1950’s, Noam Chomsky invented a notation called transformational-generative grammar, which helps linguists analyze English and translate between English and other languages. His notation was nicknamed “linguist’s algebra”, because it helped linguists just as algebra helped scientists. (A decade later, he became famous for also starting the rebellion against the Vietnam War.)

Chomsky’s notation was for pencil and paper. In 1957 and 1958, his colleague Victor Yngve developed a computerized version of Chomsky’s notation: the computerized version was a language called Comit. It was nicknamed “linguist’s Fortran”, because it helped linguists just as Fortran helped engineers.

Comit manipulated strings of words. In 1962 at Bell Telephone Laboratories (Bell Labs), Chester Lee invented a variant called Symbolic Communication Language (SCL), which manipulated strings of math symbols instead of words and helped mathematicians do abstract math.

A team at Bell Labs decided to invent a simplified SCL that would also include features from Comit. The team started to call their new language “SCL7” then renamed it “Sexi” (which stands for String Expression Interpreter); but Bell Labs’ management didn’t like sex. Then, as a joke, the team named it Snobol, using the flimsy excuse that Snobol stands for String-Oriented symbolic Language. Though cynics said Snobol didn’t have “a snowball’s chance in hell,” it became popular. It was used mainly to write programs that translate between computer languages. (For example, you could write a Snobol program that translates Fortran to Basic.)

Which is better: Comit or Snobol?

People who like Chomsky’s notation (such as linguists) prefer Comit. People who like algebra (such as scientists) prefer Snobol.

Snobol’s supporters were more active than Comit’s: they produced Snobol 2, Snobol 3, Snobol 4, and Snobol 4B, put Snobol on newer computers, wrote books about Snobol, and emphasized that Snobol can solve any problem about strings, even if the problem has nothing to do with linguistics. They won: more people use Snobol than Comit.

Most new versions of Snobol are named after baseball pitching methods — such as Fasbol, Slobol, and Spitbol. (Spitbol stands for Speedy Implementation of Snobol.)

APL

APL lets you manipulate lists of numbers more easily than any other language.

APL uses special characters that aren’t on a normal keyboard.

To compute 8+9, type this:

8+9

Notice the line is indented. Whenever it’s your turn to type, the computer automatically indents the line for you.

When you press the Return key at the end of that line, the computer will print the answer. (You don’t have to say PRINT or any other special word.) The computer will print:

17

Scalar operators APL uses these scalar operators:

APL name   Symbol    Meaning

identity           +B   same as just B

MINUS            A-B   subtract

negative              -B   negative

TIMES            A×B    multiply

signum             ×B   1 if B>0; -1 if B<0; 0 if B=0

DIVIDE       A÷B    divide

reciprocal        ÷B   1 divided by B

POWER          A*B    A raised to the Bth power; AB

exponential     *e raised to the Bth power, where e is 2.718281828459045

LOG                A*oB    logarithm, base A, of B

natural log       *ologarithm, base e, of B

CEILING         é   B rounded up to an integer

maximum        AéB       A or B, whichever is larger

FLOOR           ë   B rounded down to an integer

minimum         AëB       A or B, whichever is smaller

MAGNITUDE |B   the absolute value of B

residue             A|B   the remainder when you divide A into B; so 4|19 is 3

FACTORIAL   !B   1 times 2 times 3 times 4 times… times B

combinations   A!B   how many A-element subsets you can form from a set of B

ROLL              ?B   a random integer from 1 to B

deal                 A?B    list of A random integers, each from 1 to B, no duplicates

PI TIMES       op times B

circular            Aosin  B if A=1         arcsin    B if A=-1

cos  B if A=2         arccos    B if A=-2

tan  B if A=3         arctan       B if A=-3

sinh    B if A=5         arcsinh  B if A=-5

cosh   B if A=6         arccosh  B if A=-6

tanh   B if A=7         arctanh  B if A=-7

square root of 1+B2     if A= 4

square root of 1-B2 if A= 0

square root of B2-1 if A=-4

EQUAL       A=B    1 if A equals B;                                 otherwise 0

not equal         A=B      1 if A is not equal to B;                 otherwise 0

LESS               A<B    1 if A is less than B;                         otherwise 0

less or equal     A<B    1 if A is less than or equal to B;        otherwise 0

GREATER       A>B    1 if A is greater than B;                    otherwise 0

greater or equal   A>B    1 if A is greater than or equal to B;   otherwise 0

AND               A^B    1 if A and B are both 1;                    otherwise 0

nand                A^~B      1 if A and B are not both 1;              otherwise 0

OR                  AvB    1 if A or B is 1;                                otherwise 0

nor                  Av~B      1 if neither A nor B is 1;                  otherwise 0

NOT               ~B   1 if B is 0;                                         otherwise 0

To make the symbol *o, type the symbol *, then press the BACKSPACE key, then type the symbol o.

Order of operations Unlike all other popular languages, APL makes the computer do all calculations from right to left. For example, if you type —

2×3+5

the computer will start with 5, add 3 (to get 8), and then multiply by 2 (to get 16). The computer will print:

16

In Basic and most other languages, the answer would be 11 instead.

If you type —

9-4-3

the computer will start with 3, subtract it from 4 (to get 1), and then subtract from 9 (to get 8). The computer will print:

8

You can use parentheses. Although 9-4-3 is 8, (9-4)-3 is 2.

Compare these examples:

-4+6 is -10

-4+6 is 2

In both examples, the 4 is preceded by a negative sign; but in the second example, the negative sign is raised, to be as high as the 4. (To make the raised negative, tap the 2 key while holding down the Shift key. To make a regular negative, tap the + key while holding down the Shift key.) The first example makes the computer start with 6, add 4 (to get 10), and then negate it (to get -10). The second example makes the computer start with 6 and add -4, to get 2.

Double precision APL is super-accurate. It does all calculations by using double precision.

Variables You can use variables:

X3

X+2

The first line says X is 3. The second line makes the computer print X+2. The computer will print:

5

A variable’s name can be long: up to 77 letters and digits. The name must begin with a letter.

Vectors A variable can stand for a list of numbers:

Y5 2 8

Y+1

The first line says Y is the vector 5 2 8. The next line makes the computer add 1 to each item and print:

6  3  9

This program prints the same answer:

5 2 8+1

The computer will print:

6  3  9

This program prints the same answer:

1+5 2 8

You can add a vector to another vector:

A5 2.1 6

B3 2.8 -7

A+B

The computer will add 5 to 3, and 2.1 to 2.8, and 6 to - 7, and print:

8  4.9  -1

This program prints the same answer:

5 2.1 6+3 2.8 -7

This program prints the same answer:

A5 2.1 6

B3 2.8 -7

CA+B

C

Here’s something different:

X4 2 3

+/X

The first line says X is the vector 4 2 3. The next line makes the computer print the sum, 9.

This program prints the same answer:

Y+/4 2 3

Y

You can combine many ideas on the same line, but remember that the computer goes from right to left:

219-1 4 3+6×+/5 1 3×2 4 7

The computer will start with 2 4 7, multiply it by 5 1 3 (to get 10 4 21), find the sum (which is 35), multiply by 6 (to get 210), add 1 4 3 (to get 211 214 213), and then subtract from 219 (to get 8 5 6). The computer will print:

8  5  6

Each of APL’s scalar operators works like addition. Here are examples:

2 4 10×3 7 9  is 6 28 90

÷2 4 10         is .5 .25 .1

-2 4 10         is -2 -4 -10

×/2 4 10        is 2×4×10, which is 80

-/9 5 3         is 9-5-3, which is 7 (since the computer works from right to left)

ë/6.1 2.7 4.9    is 6.1ë2.7ë4.9, which is 2.7 (since ë means minimum)

ë6.1 2.7 4.9    is ë6.1 then ë2.7 then ë4.9, which is 6 2 4 (since ë means floor)

Vector operators Here are vector operators; the examples assume V is 8 5 6:

APL name     Symbol               Value         Reason

SHAPE            ρV           3                  V has 3 items

reshape            7ρV           8 5 6 8 5 6 8   make 7 items from V

REVERSE    |oV          6 5 8            reverse V

rotate              1|oV          5 6 8            rotate V, by beginning after the 1st item

GENERATE i3            1 2 3            count up to 3

index of           Vi5            2                  in V, find 5; it’s the 2nd item

TAKE             2­V           8 5               the first 2 items from V

drop                2¯V           6                  omit the first two items from V

SUBSCRIPT V[2]        5                  V’s 2nd item

catenate              V,9 4       8 5 6 9 4      V followed by 9 4

COMPRESS 1 0 1/V       8 6               take part of V, using this pattern: take, omit, take

expand            1 0 0 1 1\V    8 0 0 5 6      insert zeros into V, using this pattern: item, 0, 0, item, item

GRADE UP     |DV          2 3 1            here are V’s numbers in increasing order:

5 (V’s 2nd number), 6 (V’s 3rd), 8 (V’s 1st)

grade down      |ÑV         1 3 2           here are V’s numbers in decreasing order:

8 (V’s 1st number), 6 (V’s 3rd), 5 (V’s 2nd)

DECODE        10V          856             8, times 10, plus 5, times 10, plus 6

encode             10856         8 5 6           opposite of decode

MEMBER    5εV           1                 search for 5 in V (1=found, 0=missing)

Love or hate? Some programmers love APL, because its notation is brief. Other programmers hate it, because its notation is hard for a human to read. The haters are winning, and the percentage of programmers using APL is decreasing.

Logo

Logo began in 1967, during an evening at Dan Bobrow’s home in Belmont, Massachusetts. He’d gotten his Ph.D. from MIT and was working for a company called Bolt, Beranek, and Newman (BBN). In his living room were 3 of his colleagues from BBN (Wally Feurzeig, Cynthia Solomon, and Dick Grant) and an MIT professor: Seymour Papert. BBN had tried to teach young kids how to program by using BBN’s own language (Telcomp), which was a variation of Joss. BBN had asked Professor Seymour Papert for his opinion. The group was all gathered in Dan’s house to hear Seymour’s opinion.

Seymour chatted with the group, which agreed with Seymour on several points:

First, Telcomp was not a great language for kids. It placed too much emphasis on math formulas. The group agreed that instead of struggling with math, kids should have more fun by programming the computer to handle strings instead.

The group also agreed that the most sophisticated language for handling strings was Lisp, but that Lisp was too complex for kids. The group concluded that a new, simplified Lisp should be invented for kids should be called Logo.

That’s how Logo began. Seymour Papert was the guiding light, and all other members of the group gave helpful input during the conversation.

That night, after his guests left, Dan went to his bedroom, where he started writing a program (in Lisp) to make the computer understand Logo.

That’s how Logo was born. Work on Logo continued. The three main researchers who continued improving Logo were Seymour (the MIT guru), Wally (from BBN), and Cynthia (also from BBN). Logo resembled Lisp but required fewer parentheses.

After helping BBN for a year, Seymour returned to MIT. Cynthia and several other BBN folks worked with him at MIT’s Artificial Intelligence Laboratory to improve Logo.

Turtles At first, Logo was as abstract and boring as most other computer languages. But in the spring of 1970, a strange creature walked into the Logo lab. It was a big yellow mechanical turtle. It looked like “half a grapefruit on wheels” and had a pen in its belly:

­    ­    ­

wheel  pen  wheel

It also had a horn, feelers, and several other fancy attachments. To use it, you put paper all over the floor and then programmed it to roll across the paper. As it rolled, the pen in its belly drew pictures on the paper. The turtle was controlled remotely by a big computer programmed in Logo.

Suddenly, Logo became a fun language whose main purpose was to control the turtle. Kids watching the turtle screamed with delight and wanted to learn how to program it. Logo became a favorite programming game for kids. Even kids who were just 7 years old started programming in Logo. Those kids were barely old enough to read, but reading and writing were not prerequisites for learning how to program in Logo. All the kids had to know was:

FD 3 makes the turtle go forward 3 steps

RT 30 makes the turtle turn to the right 30 degrees

As for the rest of Logo — all that abstract stuff about strings, numbers, and Lisp-like lists — the kids ignored it. They wanted to use just the commands “FD” and “RT” that moved the turtle.

The U.S. Government’s National Science Foundation donated money, to help MIT improve Logo further. Many kids came into the Logo lab to play with the turtles.

The turtles were expensive, and so were the big computers that controlled them. But during the early 1970’s, computer screens got dramatically cheaper; so to save money, MIT stopped building mechanical turtles and instead bought cheap computer screens that showed pictures of turtles. Those pictures were called “mock turtles”.

Cheaper computers Logo’s first version was done on BBN’s expensive weird computer (the MTS 940). Later versions were done on the PDP-1, the PDP-10, and finally on a cheaper computer: the PDP-11 minicomputer (in 1972).

At the end of the 1970’s, companies such as Apple and Radio Shack began selling microcomputers, which were even cheaper. MIT wanted to put Logo on microcomputers but ran out of money to pay for the research.

Texas Instruments (TI) came to the rescue.…

TI Logo TI agreed to pay MIT to research how to put Logo on TI’s microcomputer (the TI-99/4).

TI and MIT thought the job would be easy, since MIT had already written a Pascal program that made the computer understand Logo, and since TI had already written a version of Pascal for the CPU chip inside the TI-99/4. Initially, MIT was worried because the Pascal program running on MIT’s PDP-10 computer handled Logo too slowly; but TI claimed TI’s Pascal was faster than the PDP-10’s and that Logo would therefore run fast enough on the TI.

TI was wrong. TI’s Pascal couldn’t make Logo run fast enough, and TI’s Pascal also required too much RAM. So TI had to take MIT’s research (on the PDP-10) and laboriously translate it into TI’s assembly language, by hand. The hand translation went slower that TI expected. TI became impatient and took a short-cut: it omitted parts of Logo, such as decimals. TI began selling its version of Logo, which understood just integers.

MIT Apple Logo After TI started selling its Logo, the MIT group invented a version of Logo for the Apple. The Apple version included decimals but omitted “sprites” (animated creatures that carry objects across the screen) because Apple’s hardware couldn’t handle sprites fast enough.

MIT wanted to sell the Apple version, since more schools owned Apples than TI computers. But if MIT were to make money from selling the Apple version, MIT might get into legal trouble, since MIT was supposed to be non-profit. And anyway, who “owned” Logo? Possible contenders were:

MIT, which did most of the research

BBN, which trademarked the name “Logo” and did the early research

Uncle Sam, whose National Science Foundation paid for much research

TI, which also paid for much research

Eventually, MIT solved the legal problems and sold the rights for “MIT Apple Logo” to two companies: Krell and Terrapin.

Krell was strictly a marketing company. It sold MIT Apple Logo to schools but made no attempt to improve Logo further.

Terrapin, on the other hand, was a research organization that had built mechanical turtles for several years. Terrapin hired MIT graduates to improve Logo further.

LCSI versus competitors Back when MIT was waiting for its lawyers to determine who owned Apple Logo, a group of MIT’s faculty and students (headed by Cynthia Solomon) impatiently left MIT and formed a company called Logo Computer Systems Incorporated (LCSI). That company invented its own version of Logo for the Apple. LCSI became successful and was hired by Apple, IBM, Atari, and Microsoft to invent Logo versions for those systems. Commodore hired Terrapin instead.

For the Apple 2c (and 2e and 2+), you could buy either the official Apple Logo (sold by Apple Computer Inc. and created by LCSI), or “Terrapin Logo for the Apple” (sold by Terrapin), or the original “MIT Logo for the Apple” (sold by Krell). Krell became unpopular, leaving Terrapin and LCSI as the main Logo versions. LCSI’s versions were daring (resulting from wild experiments), while Terrapin’s versions were conservative (closer to the MIT original).

The two companies had different styles: Terrapin was small & friendly and charged little; LCSI was big & rude and charged more. On the phone, Terrapin was nicer than LCSI.

Terrapin’s original owners had financial difficulties, moved to Maine, then sold the company to Harvard Associates (a Massachusetts company that had invented a Logo version called “PC Logo”). So now Terrapin is part of Harvard Associates (run by Bill Glass, who’s friendly). To find out about his Terrapin Logo, look at his Web site (www.terrapinlogo.com) then phone him at 800-774-Logo (or 508-487-4141) or write to 955 Massachusetts Ave. #365, Cambridge MA 02139-3233.

LCSI’s newest, daring version of Logo is MicroWorlds Pro. To find out about it, look at LCSI’s Web site (www.lcsi.ca) then phone LCSI at 800-321-5646. LCSI is based in Montreal, Canada but accepts U.S. mail at PO Box 162, Highgate Springs VT 05460.

Logo versus Basic Most of Logo’s designers hate Basic. They want to eliminate Basic from schools altogether. They believe Logo’s easier to learn than Basic, encourages a kid to be more creative, and lets a kid think in a more organized fashion. They also argue that since Logo is best for little kids, and since switching languages is difficult, kids should continue using Logo until they graduate from high school and should never use Basic.

That argument is wrong. It ignores the fact that knowing Basic is essential to understanding our computerized society. Most programs are still written in Basic, not Logo, because Basic consumes less RAM and because Basic’s newest versions contain many practical features (for business, science, and graphics) that Logo lacks.

Another advantage of Basic is that Logo suffers from awkward notation. For example, in Basic you can type a formula such as —

A=B+C

but in Logo you must type:

MAKE "A :B+:C

Notice how ugly the Logo command looks! Notice you must put a quotation mark before the A but not afterwards! And look at those frightful colons! Anybody who thinks such notation is great for kids is a fool.

Extensible One of Logo’s nicest features is that you can modify Logo and turn it into your own language, because Logo lets you invent your own commands and add them to the Logo language. A language (such as Logo) that lets you invent your own commands is called an extensible language. Though some earlier languages (such as Lisp) were extensible also, Logo is more extensible and pleasanter.

Forth

Like Logo, Forth is extensible. But Forth has two advantages over Logo:

Forth consumes less memory: you can easily run Forth on a computer having just 8K of RAM.

Forth runs faster: the computer handles Forth almost as fast as assembly language.

Since Forth is extensible and consumes so little of the computer’s memory and time, professional programmers have used Forth often. Famous programs written in Forth include Easywriter (a word-processing program), Valdocs (the operating system for Epson’s first computer), and Rapid File (an easy-to-learn data-management system).

Unfortunately, the original versions of Easywriter and Valdocs contained many bugs, but that’s because their programmers were careless.

In Forth, if you want to add 2 and 3 (to get 5) you do not type 2+3. Instead, you must type:

2 3 +

The idea of putting the plus sign afterwards (instead of in the middle) is called postfix notation. The postfix notation (2 3 +) has two advantages over infix notation (2+3): the computer handles postfix notation faster, and you never need to use parentheses for “order of operations”. But postfix notation hard for humans to read.

Like Forth, ancient HP pocket calculators used postfix notation. If you used such as calculator, you’ll find Forth easy.

Postfix notation is the reverse of prefix notation (+ 2 3), which was invented around 1926 by the Polish mathematician Lukasiewicz. So postfix notation is called reverse Polish notation. Since Forth is so difficult for a human to read, cynics call it “an inhuman Polish joke”.

Forth was invented by Chuck Moore in his spare time while he worked at many schools and companies. He wanted to name it “Fourth”, because he considered it to be an ultra-modern “fourth-generation” language; but since his old IBM 1130 computer couldn’t handle a name as long as “Fourth”, he omitted the letter “u”.

Pilot

Pilot was invented in 1968 by John Starkweather at the University of California’s San Francisco branch. It’s easier to learn than Basic but intended to be programmed by teachers, not students. Teachers using Pilot can easily make the computer teach students about history, geography, math, French, and other schoolbook subjects.

For example, suppose you’re a teacher and want to make the computer chat with your students. Here’s how to do it in Pilot:

Basic program

10 CLS

20 PRINT "I AM A COMPUTER"

30 INPUT "DO YOU LIKE COMPUTERS";A\$

40 IF A\$="YES" OR A\$="YEAH" OR A\$="YEP" OR A\$="SURE" OR A\$="SURELY" OR A\$="I SUR

E DO" THEN PRINT "I LIKE YOU TOO" ELSE PRINT "TOUGH LUCK"

Pilot program                              What the computer will do

T:I AM A COMPUTER      Type “I AM A COMPUTER”.

T:DO YOU LIKE COMPUTERS? Type “DO YOU LIKE COMPUTERS?”

M:YE,SURE                 Match. (See whether answer contains “YE” or “SURE”.)

TY:I LIKE YOU TOO         If there was a match, type “I LIKE YOU TOO”.

TN:TOUGH LUCK          If no match, type “TOUGH LUCK”.

Notice that the Pilot program is briefer than Basic.

Atari, Apple, and Radio Shack have all sold versions of Pilot that include commands to handle graphics. Atari’s version is the best, since it includes the fanciest graphics and music and even a Logo-like turtle, and since it’s also the easiest version to learn how to use.

Though Pilot is easier than Basic, most teachers prefer Basic because it’s available on more computers, costs less, and accomplishes a greater variety of tasks. Hardly anybody uses Pilot.

Specialists

For specialized applications, use a special language.

Apt

Type an Apt program that says how you want the metal cut. When you run the program, the computer will create a special instruction tape. If you feed that tape into a metal-cutting machine, the machine will cut metal as you said.

Let’s write an Apt program that makes the machine cut out the shaded area:

We’ll make the machine move the cutter where the circles are.

Here’s the program:

Program                                                                  What the computer will do

CUTTER/1                            Use a cutter whose diameter is 1".

TOLER/.005                          The tolerance of the cut is .005".

FEDRAT/80                           Use a feedrate of 80" per minute.

MODE/1                              Operate the tool in mode 1.

SPINDL/2400                       Turn the spindle on, at 2400 rpm.

COOLNT/FLOOD                      Turn the coolant on, at flood setting.

PT1=POINT/4,5                     PT1 = the point whose coordinates are (4,5).

FROM/(SETPT=POINT/1,1)            SETPT = point (1,1). Start tool from SETPT.

INDIRP/(TIP=PIONT/1,3)            TIP = (1,3). Aim tool in direction of TIP.

BASE=LINE/TIP, AT ANGL, 0         BASE = line going through TIP at 0 degrees.

GOTO/BASE                           Make the tool go to BASE.

TL RGT, GO RGT/BASE               With tool on right, go right along BASE.

GO FWD/(ELLIPS/CENTER, PT1, 3,2,0) Go forward along ellipse whose center is PT1,

semi-major axis is 3", semi-minor axis is 2",

and major axis slants 0 degrees.

GO LFT/(LINE/2,4,1,3,), PAST, BASE Go left along the line that joins (2,4) and (1,3),

until you get past BASE.

GOTO/SETPT                          Make the tool go to SETPT.

COOLNT/OFF                          Turn the coolant off.

SPINDL/OFF                          Turn the spindle off.

END                                 End use of the machine.

FINI                              The program is finished.

Dynamo

Dynamo uses these symbols:

Symbol      Meaning

.J       a moment ago

.K       now

.JK      during the past moment

.KL      during the next moment

DT       how long “a moment” is

For example, suppose you want to explain to the computer how population depends on birth rate. If you let P be the population, BR be the birth rate, and DR be the death rate, here’s what to say in Dynamo:

P.K=P.J+DT*(BR.JK-DR.JK)

The equation says: Population now = Population before + (how long “a moment” is) times (Birth Rate during the past moment - Death Rate during the past moment).

World Dynamics The most famous Dynamo program is the World Dynamics Model, which Jay Forrester programmed at MIT in 1970. His program has 117 equations that describe 112 variables about our world.

Here’s how the program begins:

* WORLD DYNAMICS

L P.K=P.J+DT*(BR.JK-DR.JK)

N P=PI

C PI=1.65E9

R BR.KL=P.K*FIFGE(BRN,BRN1,SWT1,TIME.K)*BRFM.K*BRMM.K*BRCM.K*BRPM.K

etc.

The first line gives the program’s title. The next line defines the Level of Population, in terms of Birth Rate and Death Rate.

The second equation defines the iNitial Population to be PI (Population Initial). The next equation defines the Constant PI to be 1.65e9, because the world’s population was 1.65 billion in 1900.

The next equation says the Rate BR.KL (the Birth Rate during the next moment) is determined by the Population now and several other factors, such as the BRFM (Birth-Rate-from-Food Multiplier), the BRMM (Birth-Rate-from-Material Multiplier), the BRCM (Birth-Rate-from-Crowding Multiplier), and the BRPM (Birth-Rate-from-Pollution Multiplier). Each of those factors is defined in later equations.

When you run the program, the computer automatically solves all the equations simultaneously and draws graphs showing how the population, birth rate, etc. will change during the next several decades. The graphs show the quality of life will decrease (because of the overpopulation, pollution, and dwindling natural resources). Although the material standard of living will improve for a while, it too will eventually decrease, as will industrialization (capital investment).

The bad outlook is caused mainly by dwindling natural resources. Suppose scientists suddenly make a “new discovery” that lets us reduce our usage of natural resources by 75%. Will our lives be better? The computer predicted that if the “new discovery” were made in 1970, this would happen:

People will well, so in 2030 the population is almost 4 times what it was in 1970. But the large population generates too much pollution. In 2030, the pollution is being created faster than it can dissipate. From 2040 to 2060, a pollution crisis occurs: the pollution increases until it’s 40 times as great as in 1970 and kills most people on earth, so the world’s population in 2060 is a sixth of what it was in 2040. After the crisis, the few survivors create little pollution and enjoy a very high quality of life.

Forrester tried other experiments on the computer. To improve the quality of life, he tested the effect of requiring birth control, reducing pollution, and adopting other strategies. Each of those simple strategies backfired. The graphs showed that the only way to maintain a high quality of life is to adopt a combination strategy immediately:

reduce natural resource usage by 75%

reduce pollution generation by 50%

reduce the birth rate by 30%

reduce capital-investment generation by 40%

reduce food production by 20%

Other popular applications Although the World Dynamics Model is Dynamo’s most famous program, Dynamo has also been applied to many other problems.

The first Dynamo programs ever written were aimed at helping managers run companies. Just plug your policies about buying, selling, hiring, and firing into the program’s equations; when you run the program, the computer draws a graph showing what will happen to your company during the coming months and years. If you don’t like the computer’s prediction, change your policies, put them into the equations, and see whether the computer’s graphs are more optimistic.

How Dynamo developed Dynamo developed from research at MIT.

At MIT in 1958, Richard Bennett invented a language called Simple, which stood for “Simulation of Industrial Management Problems with Lots of Equations”. In 1959, Phyllis Fox and Alexander Pugh III invented Dynamo as an improvement on Simple. At MIT in 1961, Jay Forrester wrote a book called Industrial Dynamics, which explained how Dynamo can help you manage a company.

MIT is near Boston, whose mayor from 1960 to 1967 was John Collins. When his term as mayor ended, he became a visiting professor at MIT. His office happened to be next to Forrester’s. He asked Forrester whether Dynamo could solve the problems of managing a city. Forrester organized a conference of urban experts and got them to turn urban problems into 330 Dynamo equations involving 310 variables.

Forrester ran the program and made the computer graph the consequences. The results were surprising:

The graph showed that if you try to help the underemployed (by giving them low-cost housing, job-training programs, and artificially created jobs), the city becomes better for the underemployed — but then more underemployed people move to the city, the percentage of the city that’s underemployed increases, and the city is worse than before the reforms were begun. So socialist reform just backfires.

Another example: free public transportation creates more traffic, because it encourages people to live farther from their jobs.

The graphs show the only long-term solution to the city’s problems is to do this instead: knock down slums, fund new “labor-intensive export” businesses (businesses that will hire many workers, occupy little land, and produce goods that can be sold outside the city), and let the underemployed fend for themselves in this new environment.

Another surprise: any city-funded housing program makes matters worse (regardless of whether the housing is for the underemployed, the workers, or the rich) because more housing creates less space for industry, so fewer jobs.

If you ever become a mayor or President, use the computer’s recommendations cautiously: they’ll improve the cities, but only by driving the underemployed out to the suburbs, which will worsen.

In 1970 Forrester created the World Dynamics Model to help “The Club of Rome”, a private club of 75 people who try to save the world from ecological calamity.

GPSS

A queue is a line of people who are waiting. GPSS analyzes queues. For example, let’s use GPSS to analyze the customers waiting in “Quickie Joe’s Barbershop”.

Joe’s the only barber in the shop, and he spends exactly 7 minutes on each haircut. (That’s why he’s called “Quickie Joe”.)

About once every 10 minutes, a new customer enters the barbershop. More precisely, the number of minutes before another customer enters is a random number between 5 and 15.

To make the computer imitate the barbershop and analyze what happens to the first 100 customers, type this program:

SIMULATE

GENERATE   10,5    A new customer comes every 10 minutes ± 5 minutes.

QUEUE      JOEQ    He waits in the queue, called JOEQ.

SEIZE      JOE     When his turn comes, he seizes JOE,

DEPART     JOEQ        which means he leaves the JOEQ.

ADVANCE    7       After 7 minutes go by,

RELEASE    JOE         he releases JOE (so someone else can use JOE)

TERMINATE  1           and leaves the shop.

START      100     Do all that 100 times.

END

Indent so that the word SIMULATE begins in column 8 (preceded by 7 spaces) and the “10,5” begins in column 19.

When you run the program, the computer will tell you the following.…

Joe was working 68.5% of the time. The rest of the time, his shop was empty and he was waiting for customers.

There was never more than 1 customer waiting. “On the average”, .04 customers were waiting.

There were 101 customers. (The 101st customer stopped the experiment.) 79 of them (78.2% of them) obtained Joe immediately and didn’t have to wait.

The “average customer” had to wait in line .405 minutes. The “average not-immediately-served customer” had to wait in line 1.863 minutes.

How to make the program fancier Below the RELEASE statement and above the TERMINATE statement, you can insert two extra statements:

TABULATE   1

1     TABLE      M1,0,1,26

(Indent so that the 1 before TABLE is in column 2.) Those two statements make the computer add the following comments.

Of the 100 analyzed customers, the “average customer” spent 7.369 minutes in the shop (from when he walked in to when he walked out).

More precisely, 79 customers spend 7 minutes each, 9 customers spend 8 minutes each, 9 customers spend 9 minutes each, 2 customers spend 10 minutes each, and 1 customer had to spend 11 minutes.

The computer also prints the “standard deviation”, “cumulative tables”, and other statistical claptrap.

On your own computer, the numbers might be slightly different, depending on how the random numbers came out. To have more faith in the computer’s averages, try 1000 customers instead of 100.

Alternative languages For most problems about queues, GPSS is the easiest language to use. But if your problem is complex, you might have to use Simscript (based on Fortran) or Simula (an elaboration of Algol) or Simpl/I (an elaboration of PL/I).

RPG

RPG is the most popular language for IBM minicomputers, such as the IBM System/3, System/32, System/34, and System/36.

For example, suppose you run a company that provides male football coaches, male boxing trainers, and male strippers, and you have a file called MANHOURS containing one line for each employee:

20331ARMSTRONG,J.D. 045

21450AZUR,M.P.      102

39976BUGLE,I.M.     041

44411CHESTER,O.P.   040

On each line:

The first 5 characters contain the employee’s ID#.

Characters 6-20 contain his name.

Characters 21-23 tell how many hours he worked.

The file’s been typed on punched cards (each line on a separate card).

Let’s make the computer print the whole file onto paper, with spacing between the columns, and also print the total hours worked, like this:

20331   ARMSTRONG,J.D.    045

21450   AZUR,M.P.         102

39976   BUGLE,I.M.        041

44411   CHESTER,O.P.      040

00228

To create the program, start by filling in 4 forms (on paper, by using your pencil).

On form #1 (which resembles Cobol’s ENVIRONMENT DIVISION), describe the controls and files, so the form looks like this:

Size to compile         Size to execute

008             008

Filename      I/O/U/C    P/S/C/R/T/D     Record length       Device

MANHOURS  I         P             96            MFCU1

That means:

Reserve 8K of memory for the program.

The file “MANHOURS” is for Input, and it’s the Primary file. In that file, each card can hold 96 characters. It’s on card reader #1 (which is called MFCU1).

The file “ADDLIST” is for Output. In that file, each line can hold 96 characters and will appear on the PRINTER.

Form #2 describes the input:

Filename      Sequence     Indicator      From       To     Decimals      Field name

MANHOURS  AA        01

1     5            MANNO

6     20            NAME

21     23  0         HRS

That means:

MANHOURS is unorganized (“AA”). Reading a card from that file is called “activity #01”.

On each card, characters 1-5 contain MANNO, characters 6-20 contain NAME, and characters 21-23 contain HRS, which is a number having 0 digits after the decimal point.

Form #3 describes the calculations:

Indicator      Factor 1    Operation    Factor 2    Result field     Field length     Decimals

01        HRS      ADD       TOTAL    TOTAL      5          0

That means:

After each occurrence of activity #01, let HRS + TOTAL be the new TOTAL, which is a 5-digit number having 0 digits after the decimal point.

Form #4 describes the output:

Filename      Type    Space before     After       Indicator      Field name      End position

MANNO      5

NAME       23

HRS        29

T     3            0     LR

TOTAL      29

That means:

For file ADDLIST, here’s how to print each line of Details. Press the Enter key 1 time before you print the line, 0 times after you print the line. Do the printing after each occurrence of activity #01.

Print MANNO so it ends in “column 5” (the 5th character on the printed line).

Print NAME is it ends in column 23. Since form #2 said NAME requires 15 columns (15 characters), the computer will print NAME in columns 9-23.

Here’s how to print the Total. Press the Enter key 3 times before printing it, 0 times after printing it. Print it just after the Last Record (last card) has been read.

Print the TOTAL so it ends in column 29. Since form #3 said TOTAL requires 5 columns, the computer will print TOTAL in columns 25-29.

After you’ve filled in the 4 forms by using your pencil, hand them to a typist, who types what you handwrote (but doesn’t type the column headings). Then the program runs!

To do that in Basic, Fortran, or traditional Cobol, you’d have to write a loop; you’d have to say GO TO, DO, or PERFORM. RPG makes the computer do loops automatically, without forcing you to specify how. The order in which you write statements is less important in RPG than in those other languages; you’re less likely to err; RPG is more reliable.

But today, RPG is considered old-fashioned, since newer languages (such as DBase) let you generate loops, totals, and reports even more easily than RPG. Moreover, DBase costs less than RPG and can run on cheaper computers.

SPSS

The most popular computer language for statistics is SPSS, which stands for Statistical Package for the Social Sciences.

Simple example Suppose you survey 10 of your friends and ask each of them two questions:

1. In the next election, will you probably vote Republican or Democrat?

2. Are you male or female?

Maybe you can guess the answer to the second question by just looking at the person; but to be sure, you’d better ask.

Suppose nobody gives an unusual answer (such as Prohibitionist or Communist or Transsexual or Undecided). You think it would be cool to feed all the data into the computer. For example, if a person said “Republican Female”, you’d feed the computer this line:

RF

If a person said “Democrat Male”, you’d feed the computer this line:

DM

This SPSS program makes the computer analyze the data:

Program                                                                   Meaning

VARIABLE LIST  PARTY,SEX          Read each person’s PARTY and SEX,

INPUT FORMAT   FIXED (2A1)          using this Fortran FORMAT: “2A1”.

N OF CASES     10                There are 10 people.

INPUT MEDIUM   CARD              The data to read is on the “cards” below.

 }

PRINT FORMATS  PARTY,SEX (A)        To print the PARTY and SEX, use “A” format.

CROSSTABS      TABLES=SEX BY PARTY Print table showing how SEX relates to PARTY.

READ INPUT DATA                     The data to read is on the following lines.

RF

DM

RM

RM

DF                                 the “data cards”

DM

DF

DF

RM

DF

FINISH                              The program is finished.

In the top line, the word PARTY begins in column 16. Most SPSS statements consist of a control field (columns 1-15) followed by a specification field (columns 16-80).

When you run the program, the computer will print this kind of table:

ROW

R     D     TOTAL

┌─────┬─────┐

M     │   3 │   2 │    5

│60.0%│40.0%│ 50.0%

│75.0%│33.3%│

│30.0%│20.0%│

├─────┼─────┤

F     │   1 │   4 │    5

│20.0%│80.0%│ 50.0%

│25.0%│66.7%│

│10.0%│40.0%│

└─────┴─────┘

COLUMN    4     6     10

TOTAL 40.0% 60.0% 100.0%

Look at the top number in each box. Those numbers say there were 3 male Republicans, 2 male Democrats, 1 female Republican, and 4 female Democrats. The first box says: the 3 male Republicans were 60% of the males, 75% of the Republicans, and 30% of the total population.

The computer prints the table in reverse-alphabetical order: “M” before “F”, and “R” before “D”. Each row is a SEX, and each column is a PARTY. In the program, if you change “SEX BY PARTY” to “PARTY BY SEX”, each row will be a PARTY, and each column will be a SEX.

Fancy features The CROSSTABS statement has options. Here are some of them.

option 3: don’t print the row percentages (the 60.0%, 40.0%, 20.0%, and 80.0%)

option 4: don’t print the column percentages (75.0%, 33.3%, 25.0%, and 66.7%)

option 5: don’t print the total percentages (30.0%, 20.0%, 10.0% and 40.0%)

If you want options 3 and 5, put this statement under the CROSSTABS statement:

OPTIONS        3,5

The CROSSTABS statement has statistics. Here are some of them:

1. chi-square, its degrees of freedom, level of significance

2. phi or Cramer’s V

3. contingency coefficient

4. lambda, symmetric and asymmetric

5. uncertainty coefficient, symmetric and asymmetric

6. Kendall’s tau b and its level of significance

7. Kendall’s tau c and its level of significance

8. gamma

9. Somer’s D

Those statistics are numbers that help you analyze the crosstab table. If you want statistics 1 and 8, insert this statement underneath the CROSSTABS and OPTIONS statements:

STATISTICS     1,8

It makes the computer print statistics 1 and 8 underneath the table. If you want the computer to print all 9 statistics, say:

STATISTICS     ALL

The CROSSTABS statement is called a procedure. Here are other procedures SPSS can handle:

AGGREGATE       NONPAR CORR

ANOVA           ONEWAY

BREAKDOWN       PARTIAL CORR

CANCORR          PEARSON CORR

CONDESCRIPTIVE  REGRESSION

DISCRIMINANT    SCATTERGRAM

FACTOR          T-TEST

FREQUENCIES     WRITE CASES

GUTTMAN SCALE

Each procedure has its own OPTIONS and STATISTICS.

SPSS includes many other kinds of statements:

ALLOCATE         PRINT BACK

ASSIGN MISSING   RAW OUTPUT UNIT

COMPUTE            RECODE

COUNT            REORDER VARS

DATA LIST        RUN NAME

DELETE SUBFILES  RUN SUBFILES

DELETE VARS      SAMPLE

DO REPEAT        SAVE ARCHIVE

DOCUMENT         SAVE FILE

EDIT             SELECT IF

END REPEAT       SORT CASES

FILE NAME        SUBFILE LIST

GET FILE         VALUE LABELS

IF               WEIGHT

KEEP VARS        WRITE FILEINFO

LIST ARCHINFO

LIST CASES

LIST FILE INFO

SPSS contains more statistical features than any other language. If you don’t need quite so many features, use an easier language, such as STATPAK or DATATEXT.

Prolog

In 1972, Prolog was invented in France at the University of Marseilles. In 1981, a different version of Prolog arose in Scotland at the University of Edinburgh. In 1986, Turbo Prolog was created in California by Borland International (which also created Turbo Pascal).

Those versions of Prolog are called Marseilles Prolog, Edinburgh Prolog, and Turbo Prolog.

Prolog programmers call Marseilles Prolog the “old classic”, Edinburgh Prolog the “current standard”, and Turbo Prolog the “radical departure”.

Turbo Prolog has two advantages over its predecessors: it runs programs extra-fast, and it uses English words instead of weird symbols. On the other hand, it requires extra lines at the beginning of your program, to tell the computer which variables are strings.

The ideal Prolog would be a compromise, incorporating the best features of Marseilles, Edinburgh, and Turbo. Here’s how to use the ideal Prolog and how the various versions differ from it.…

Creating the database Prolog analyzes relationships. Suppose Alice loves tennis and sailing, Tom loves everything that Alice loves, and Tom also loves football (which Alice does not love). To feed all those facts to the computer, give these Prolog commands:

loves(alice,tennis).

loves(alice,sailing).

loves(tom,X) if loves(alice,X).

loves(tom,football).

The top two lines say Alice loves tennis and sailing. In the third line, the “X” means “something”, so that line says: Tom loves something if Alice loves it. The bottom line says Tom loves football.

When you type those lines, be careful about capitalization.

You must capitalize variables (such as X). You must not capitalize specifics (such as tennis, sailing, football, alice, tom, and love).

At the end of each sentence, put a period.

That’s how to program by using ideal Prolog. Here’s how other versions of Prolog differ.…

For Edinburgh Prolog, type the symbol “:-” instead of the word “if”.

For Marseilles Prolog, replace the period by a semicolon, and replace the word “if” by an arrow (->), which you must put in every line:

loves(alice,tennis)->;

loves(alice,sailing)->;

loves(tom,X) -> loves(alice,X);

loves(tom,football)->;

For Turbo Prolog, you must add extra lines at the top of your program, to warn the computer that the person and sport are strings (“symbols”), and the word “loves” is a verb (“predicate”) that relates a person to a sport:

domains

person,sport=symbol

predicates

loves(person,sport)

clauses

loves(alice,tennis).

loves(alice,sailing).

loves(tom,X) if loves (alice,X).

loves(tom,football).

(To indent, press the Tab key. To stop indenting, press the left-arrow key.) When you’ve typed all that, press the Esc key (which means Escape) then the R key (which means Run).

Simple questions After you’ve fed the database to the computer, you can ask the computer questions about it.

Does Alice love tennis? To ask the computer that question, type this:

loves(alice,tennis)?

yes

Does Alice love football? Ask this:

loves(alice,football)?

no

That’s how the ideal Prolog works. Other versions differ. Marseilles Prolog is similar to the ideal Prolog. Turbo Prolog omits the question mark, says “true” instead of “yes”, and says “false” instead of “no”. Edinburgh Prolog puts the question mark at the beginning of the sentence instead of the end, like this:

?-loves(alice,tennis).

Advanced questions What does Alice love? Does Alice love something? Ask this:

loves(alice,X)?

X=tennis

X=sailing

2 solutions

What does Tom love? Does Tom love something? Ask:

loves(tom,X)?

X=tennis

X=sailing

X=football

3 solutions

loves(X,tennis)?

X=alice

X=tom

2 solutions

loves(X,hockey)?

The computer doesn’t know of anybody who loves hockey, so the computer will answer:

no solution

Does Tom love something that Alice doesn’t? Ask:

loves(tom,X) and not (loves(alice,X))?

X=football

1 solution

That’s ideal Prolog.

Turbo Prolog is similar to ideal Prolog. For Marseilles Prolog, replace the word “and” by a blank space.

For Edinburgh Prolog, replace the word “and” by a comma. After the computer finds a solution, type a semicolon, which tells the computer to find others; when the computer can’t find any more solutions, it says “no” (which means “no more solutions”) instead of printing a summary message such as “2 solutions”.

Prolog’s popularity After being invented in France, Prolog quickly became popular throughout Europe.

Its main competitor was Lisp, which was invented in the United States before Prolog. Long after Prolog’s debut, Americans continued to use Lisp and ignored Prolog.

In the 1980’s, the Japanese launched the Fifth Generation Project, which was an attempt to develop a more intelligent kind of computer. To develop that computer’s software, the Japanese decided to use Prolog instead of Lisp, because Prolog was non-American and therefore furthered the project’s purpose, which was to one-up the Americans.

When American researchers heard that the Japanese chose Prolog as a software weapon, the Americans got scared and launched a counter-attack by learning Prolog also.

When Borland — an American company — developed Turbo Prolog, American researchers were thrilled, since Turbo Prolog ran faster than any other Prolog. It ran faster on a cheap IBM PC than Japan’s Prolog ran on Japan’s expensive maxicomputers! The money that Japan had spent on maxicomputers was wasted! The Americans giggled with glee.

Moral: though the Japanese can beat us in making hardware, we’re still way ahead in software. But wouldn’t it be great if our countries could work together and share talents?