You’ve already learned the most popular computer languages: QBASIC, Visual BASIC, PASCAL, C, C++, Java, and DBASE. But those 9 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.
The dictionary clumps the languages into groups. For example, look at the languages in the second group: ALGOL, PASCAL, MODULA, and ADA. Those 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 that 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:
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.
Of those 26 languages, 5 were invented in Europe (ALGOL, PASCAL, MODULA, ADA, and PROLOG). The others were invented in the United States.
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 others were invented by geniuses elsewhere.
The first mainstream languages were FORTRAN, ALGOL, and COBOL. They were the big 3.
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:
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 three 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 four 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.…
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 365-461, 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:
In FORTRAN, you must lengthen the program, so it looks like this instead:
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:
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:
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:
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:
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):
In QBASIC, the symbol ^ means exponents (for example,
4.7 ^ 3 means “4.7 times 4.7 times 4.7”). Since FORTRAN is 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:
Then came improvements:
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 to 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.
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.
But in some ways, FORTRAN’s still better for engineering that BASIC, PASCAL, or C++. Here’s why:
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:
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 IBM refused to put ALGOL on its computers. Since most American programmers used IBM computers, most American programmers couldn’t use ALGOL.
Critics blamed IBM for ALGOL’s demise. But here’s IBM’s side of the story:
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 has three loopholes:
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).
If you’re a students 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, administrators who manage computer departments got together and decided that 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 (after the original programmer gets fired).
Those administrators invented a computer language that lets the programmer just fill in an outline and feed the outline to the computer. The outline itself would act as the program. No further programming would be necessary.
That outline-oriented computer language would be used especially for handling tough programming problems in business accounting (such as payroll, inventory, accounts payable, and accounts receivable), so it was called the COmmon Business Oriented Language (whose abbreviation is COBOL, which is pronounced “koe ball”).
Four parts To write a program in COBOL, you just fill in an outline, which has four parts:
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 divisions to find out what kind of variable the procedure involves and which computer device the variable is being stored on.
Although creating such an outline is a cute idea, it doesn’t work very well: when you write 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 and decided to develop a single business language for all computers. The group asked the Department of Defense to help sponsor the research.
The Department agreed. At a follow-up meeting held at the Pentagon in May. At that meeting, the group tentatively decided to call the new language “CBL” (for “Common Business Language”) and created three committees.
The Short-Range Committee met immediately and created a language nice enough so that 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 six names:
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 two rules:
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 the programmers construct mathematical formulas by using these symbols:
But other members of the committee disagreed: they argued that since COBOL is supposed to be for stupid businessmen who fear formulas, COBOL ought to 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; if you prefer, you can use a formula instead, but you must warn the computer by putting the word COMPUTE in front of the formula.
Can COBOL handle long numbers? How long? The committee decided that COBOL would handle any number up to 18 digits long. The committee also decided that COBOL would handle any variable name up to 30 characters long. So the limits of COBOL are “18 and 30”.
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.
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. Although 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 also Einstein’s youngest assistant. He told Einstein he wanted to quit math and instead hand out leaflets for world peace. Einstein replied: handing out leaflets 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 Kemeny to come to Dartmouth, chair the department, and “bring all your 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 90% discount, in return for which his department had to invent programs for it 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 Thomas 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 became bored and thought of quitting Dartmouth. Then Dartmouth asked him to become president of the college. 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 profound 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:
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 doesn’t have string variables and doesn’t name programs (you must give each program a number instead, and remember what the number was). Also, programs written in JOSS run more slowly and require more of the computer’s memory than if written in BASIC.
A few programmers still use JOSS and three of its variants, which are called AID, FOCAL, and MUMPS. They all run on computers built by DEC. AID is used by high-school kids on PDP-8 computers, FOCAL by scientists on PDP-10 computers, and MUMPS by doctors designing databases of patient records on PDP-11 computers. Though MUMPS does have string variables and other modern features, it’s gradually being replaced by newer database languages such as DBASE.
Six versions Kemeny and Kurtz finished the original version of BASIC in May 1964. It included just these statements:
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 — a way so sophisticated that most microcomputers don’t have it yet!
How BASIC became popular During the 1960’s and 1970’s, Kemeny & Kurtz worked on BASIC with a fervor that was almost religious.
General Electric, which built Dartmouth’s computer, quit making computers and sold its computer factory to Honeywell. So now Dartmouth’s computer is 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 having to worry about copyrights or patents.
DEC The first company to copy Dartmouth’s ideas was Digital Equipment Corporation (DEC).
HP Soon after DEC started putting BASIC on its computers, Hewlett-Packard (HP) decided to do likewise.
Other major manufacturers Most other manufacturers imitate the versions of BASIC invented by Dartmouth and DEC. Unfortunately, Data General, Wang, and IBM made the mistake of copying Hewlett-Packard instead.
That’s how BASIC developed on maxicomputers and minicomputers.
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. When Mits didn’t treat Bill Gates fairly, he broke away from Mits and formed his own company, called Microsoft.
Bill Gates and his company, Microsoft, invented many versions of BASIC.
All those versions of BASIC were written for computers that contained an 8080 or Z-80 CPU. Simultaneously, he wrote 6502 BASIC, for Apple 2 and Commodore computers.
Unfortunately, 6502 BASIC is rather primitive: it resembles his 8K BASIC. So if you’re trying to learn advanced BASIC programming, you should not get an Apple 2e or 2c or Commodore 64!
After writing 6502 BASIC, Bill wrote an improved version of it, called 6809 BASIC, available 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”. Then TI told Bill what kind of BASIC it wanted. Bill’s company — Microsoft — found 90 ways in which 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.
Because of those differences, TI’s computers became unpopular, and TI stopped making them. Moral: if you contradict Bill, you’ll die!
Bill later invented an amazingly wonderful version of BASIC, better than all the other versions that had been invented. He called it GW BASIC (which stands for “Gee-Whiz BASIC”). It runs only 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, but ask!
Beyond GW BASIC GW BASIC was the last version of BASIC that Bill developed personally. All further improvements & variants were done by his assistants at Microsoft.
Microsoft’s newest variations are 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 easily create Windows-style programs that let the human use a mouse and pull-down menus). Those BASICs are slightly harder to learn how to use than GW BASIC; but once you understand them, you’ll prefer them because 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 three new commands that are particularly exciting: 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:
That makes the computer translate “I love you” into phonetics and then say the phonetics. That command works on the Amiga, and I hope Microsoft will put it on other computers also.
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:
By using the SUB command, you can give a subroutine a name.
Microsoft’s main competitor for languages is Borland, which made Turbo PASCAL, Turbo C, and
Turbo BASIC version 1.1 runs faster than Quick BASIC, is easier to understand, and includes almost as many commands. But Borland’s stopped marketing Turbo BASIC, so Borland can devote its energies to other Borland products that are more profitable.
Divergences GW BASIC, Microsoft BASIC for the Macintosh, Amiga Microsoft BASIC, Quick BASIC, and Turbo BASIC are all 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!
While DEC, Hewlett-Packard, 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” or 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 quite reasonable, and 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 the most advanced aspects of BASIC.
Comparison chart This chart compares the most popular versions of BASIC for microcomputers:
It shows which versions of BASIC understand these 9 words: USING, LINE, CIRCLE, SOUND, PLAY, SAY, ELSE, END IF, and SUB.
The versions of BASIC at the top of the chart (QBASIC, Visual BASIC, and Amiga BASIC) are the best: they understand 8 of the 9 words. The versions of BASIC at the bottom of the chart (Commodore 64 BASIC and Vic-20 BASIC) are the worst: they understand none of the words.
Here’s what those 9 words accomplish:
Although the Commodore 128 and Radio Shack TRS-80 Color Computer were cheap, the chart shows their versions of BASIC are better than the Apple 2c’s, which cost more. 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!
During the early 1960’s, IBM sold two kinds of computers. One kind was for use by scientists; the other kind was for use by 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, large 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 also included commands for handling strings and fields in data files. But IBM never announced FORTRAN V to the public; instead, in 1963 IBM began working on a dramatically 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 the 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.
When IBM discovered that the letters “NPL” already stood for the National Physics Laboratory in England, IBM changed the language’s name to Programming Language One (PL/I), to brag it was the first good programming language and all its predecessors were worth zero by comparison.
Troublesome timing The committee that invented PL/I had a hard time.
After the design was finished, the language still had to be put onto 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 weren’t willing to switch to PL/I. Switching was too much trouble.
Other troubles PL/I was expensive to run. It required twice as much RAM as COBOL, four times as much RAM as FORTRAN. It ran slowly: it took 1½ times as long to compile as COBOL, twice as long as FORTRAN.
Another obstacle to PL/I’s acceptance was lethargy: most programmers already knew FORTRAN and COBOL, were satisfied with those languages, and weren’t willing to spend the time to learn something new.
Some programmers praise PL/I for being amazingly powerful. Others call it just a scheme by IBM to get people to buy more RAM. Others call it a disorganized mess, an “ugly kitchen sink of a language”, thrown together by a committee that was in too much of a rush.
Since PL/I is such a large language, hardly anybody understands it all. As a typical harried PL/I programmer, you study just the part of the language you intend 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 different part of the language that you never studied. So instead of griping, the computer will perform an instruction that wasn’t what you meant.
Universities Universities debated which language to teach freshman. For a while, the choice was between FORTRAN (the “standard”), ALGOL (the “pure and simple”), and PL/I (the “powerful”).
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. Although it allows fewer statements than PL/C, it runs faster and prints messages that are even more helpful. SP/k comes in several sizes: the tiniest is SP/1; the largest is SP/8.
Stripped-down versions of PL/I remained popular in universities until about 1980, when they began to be replaced by PASCAL.
Microcomputers Digital Research invented a tiny version of PL/I for microcomputers, and called it PL/M. Unfortunately, PL/M can’t handle decimals. PL/M was popular during the late 1970’s and early 1980’s, but most PL/M programmers eventually switched to C.
Maxicomputers PL/I is still used on large IBM computers, because it’s 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:
These statements interrupt:
These statements handle conditions:
These statements handle variables:
These statements handle general logic:
Half of those statements are borrowed from FORTRAN, ALGOL, and COBOL.
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).
In 1968, a European committee tried to invent an improved version of ALGOL. The majority of the committee agreed on a version called “ALGOL 68”. It was strange: it even required you to spell some commands backwards.
A few members of the committee were dissidents who disagreed with the majority and thought ALGOL 68 was nuts. One of the dissidents, Niklaus Wirth, quit the committee and created his own version of ALGOL. He called his version PASCAL. Today, most computerists feel he was right and the majority of the committee was wrong, PASCAL is better than ALGOL 68.
He wrote PASCAL in Switzerland, for 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 three limitations were corrected in later versions of PASCAL — especially the version invented at the University of California at San Diego (UCSD), which even 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 advertisements, bragging that the Apple 2 was the only popular microcomputer that could handle PASCAL.
For $495, Apple Computer Company sold the “Apple Language System”, which included 4 disks containing PASCAL, 2 disks containing souped-up BASIC, and a card containing 16K of extra RAM. Many people spent the $495 for PASCAL but were disappointed. They expected that by spending $495, they’d be able to write programs more easily, but they discovered that PASCAL is harder to learn than BASIC.
PASCAL is helpful only if the program you’re writing is long. PASCAL helps you organize and dissect long programs more easily than BASIC. But the average Apple owner never writes long programs and never needs PASCAL.
Many customers felt “ripped off”, since they had spent $495 and received no benefit in return. But maybe that’s what “marketing” is all about.
PASCAL’s popularity Many programmers who’d been writing big FORTRAN programs for big computers switched to PASCAL, because PASCAL helps organize large programs better, 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. 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.
But recently, 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. PASCAL is ignored.
After Niklaus Wirth invented PASCAL, he began designing a more ambitious language, called MODULA.
He designed the first version of MODULA in 1975. In 1979 he designed an improvement called MODULA-2. When today’s programmers discuss “MODULA”, they mean MODULA-2.
MODULA-2 is very similar to 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:
That example shows four 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.
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. (Unix was invented at Bell Labs. The original version of Unix was created 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.
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 of 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?
In 1975, the U.S. Department of Defense decided it wanted a new kind of computer language, so the Department wrote a list of requirements the language would have to meet.
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).
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 was invented by Wayne Ratliff because he wanted to bet on which football teams would win the 1978 season. To bet wisely, he had to know how each team had 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 that was small enough to run on the CP/M microcomputer in his house. It was even 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 on 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 the “Lashlee” part sounded too wimpy, they changed the name to Ashton-Tate Software.
Instead of selling the original version of VULCAN, 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 most of 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 ad was ingenious. It showed a photograph 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, which was a popular, concise weekly newspaper read by all computer experts. Suddenly, all experts knew that DBASE was the database-management system that claimed not to suck.
The ad generated just one serious 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 and didn’t want to 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 that you learn programming.
In 1988, Ashton-Tate began shipping DBASE 4, which includes extra programming commands.
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 sells Visual DBASE 7.5 and is trying to develop DBASE 2000 (DB2K).
Dramatic improvements to DBASE have been created by other companies, who make clones of DBASE that outshine DBASE itself! The most popular clone is Visual FOXPRO 6, which runs faster than DBASE, includes extra commands, and is marketed by Microsoft.
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:
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:
The computer will say the answer:
Whenever the computer prints, it automatically prints a blank space afterwards but does not press the ENTER key. So if you run this program —
the computer will say:
Here’s a fancier example:
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:
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:
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:
To let R be a random decimal, type:
To let R be a random integer from 1 to 6, type:
To let R be a random integer from -3 to 5, type:
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:
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:
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:
To shorten the program, use the words NOT and BUT:
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:
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:
This program makes the computer say 5, 8, 11, 14, and 17:
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:
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:
In that example, PREPARE is like BASIC’s DIM.
DATA EASY’s DATA statement resembles BASIC’s. But instead of saying READ X, say:
HOW In EASY, you can give any command you wish, such as:
If you give that command, you must also give an explanation that begins with the words:
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 —
you can say:
Instead of saying —
you can say:
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.
Most C programmers have switched to an improved C, called C++.
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.
Let’s examine the radical languages, beginning with the oldest radical — the oldest hippie — 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:
If you want the computer to add 5 and 2, just type:
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:
If you type —
the computer will add 1, 3, 1, and 1 and print:
If you type —
the computer will find the difference between 7 and 2*3 and print:
If you type —
the computer will print:
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:
That makes the computer print:
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.
In a list, the first item is called the CAR, and the remainder 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:
The computer will print:
If you type —
the computer will print:
If you type —
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:
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:
The computer will print:
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:
Then if you say —
the computer will print 9.
To make Y stand for the word LOVE, say:
Then if you say —
the computer will say:
To make STOOGES stand for the list (MOE LARRY CURLEY), say:
Then if you say —
the computer will say:
To find the first of the STOOGES, say:
The computer will say:
Your own functions You can define your own functions. For example, you can define (DOUBLE X) to be 2*X, by typing this:
Then if you say —
the computer will print:
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.
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:
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 —
the computer will print:
The definition is almost circular: the definition of REPEAT assumes you already know what REPEAT is. For example:
That kind of definition, which is almost circular, is called recursive.
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 that (ITEM N X) is the Nth item in list X, and so that (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:
If your computer doesn’t understand (ONEP N), say (EQUAL 1 N) instead.
SNOBOL lets you analyze strings more easily than any other language. It can handle numbers also.
Simple example Here’s a simple SNOBOL program:
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 symbol =, the symbol +, 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:
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:
Looping This program’s a loop:
The first line (whose name is FRED) makes the computer print:
The next line makes the computer print —
and then go to FRED. Altogether the computer will print:
Replacing SNOBOL lets you easily replace one phrase by another.
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:
That program changed the first “IN” to “UCK”. Here’s how to change every “IN” to “UCK”:
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:
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:
Deleting This program deletes the first “IN”:
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”:
The computer will print:
Counting 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:
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:
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 the Symbolic Communication Language (SCL), which manipulated strings of mathematical symbols instead of words and helped mathematicians do abstract mathematics.
A team at Bell Labs decided to invent a language similar to SCL, but easier to learn and including features from COMIT. At first, they called their new language “SCL7”, because it resembled SCL. Then they changed its name to “SEXI” (which stands for String EXpression Interpreter), but the management of Bell Labs didn’t like sex. Then, as a joke, they named it SNOBOL, using the flimsy excuse that SNOBOL stands for StriNg-Oriented symBOlic Language.
Cynics jeered that SNOBOL didn’t have “a snowball’s chance in Hell”. But the cynics were wrong, and SNOBOL became popular. It was used mainly for writing programs that translate between computer languages. (For example, you could write a SNOBOL program that translates FORTRAN into BASIC.)
Which is better: COMIT or SNOBOL?
Now most versions of SNOBOL are named after baseball pitching methods — such as FASBOL, SLOBOL, and SPITBOL. (SPITBOL stands for SPeedy ImplemenTation of snoBOL.)
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:
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:
Scalar operators APL uses these scalar operators:
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 —
the computer will start with 5, add 3 (to get 8), and then multiply by 2 (to get 16). The computer will print:
In BASIC and most other languages, the answer would be 11 instead.
If you type —
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:
In most other languages, the answer would be 2 instead.
You can use parentheses. Although 9-4-3 is 8, (9-4)-3 is 2.
Compare these examples:
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:
The first line says X is 3. The second line makes the computer print X+2. The computer will print:
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:
The first line says Y is the vector 5 2 8. The next line makes the computer add 1 to each item and print:
This program prints the same answer:
The computer will print:
This program prints the same answer:
You can add a vector to another vector:
The computer will add 5 to 3, and 2.1 to 2.8, and 6 to - 7, and print:
This program prints the same answer:
This program prints the same answer:
Here’s something different:
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:
You can combine many ideas on the same line, but remember that the computer goes from right to left:
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:
Each of APL’s scalar operators works like addition. Here are examples:
Vector operators Here are vector operators; the examples assume V is 8 5 6:
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 began in 1967, during an evening at Dan Bobrow’s home in Belmont, Massachusetts.
Dan had gotten his Ph.D. from MIT and was working for a company called Bolt, Beranek, and Newman (BBN). In his living room were three 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, and the entire group agreed with Seymour on several points:
That night, after his guests left, Dan went to the terminal in his bedroom and started programming the computer to understand LOGO. Specifically, he wrote a LISP program that explained to the computer how to handle 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:
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 that “FD 3” made the turtle go forward 3 steps, and “RT 30” made the turtle turn to the right 30 degrees.
As for the rest of LOGO — all that abstract stuff about strings and 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. To let more kids use LOGO, the first problem was to reduce the cost of the turtle and its controlling computer.
During the early 1970’s, computer screens got dramatically cheaper. 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 The original version of LOGO was done on BBN’s expensive weird computer (the MTS 940). Later versions were done on the PDP-1 (in 1968), the PDP-10 (in 1970), 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 microcomputers (the TI-99/4 and the TI-99/4A).
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 alas, the Apple version omitted “sprites” (which are animated creatures that carry objects across the screen) because Apple’s hardware couldn’t handle sprites fast enough. (TI’s hardware was fancier and did handle sprites.)
MIT wanted to sell the Apple version to schools since more schools owned Apples than TI computers. But if MIT were to make lots of 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:
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 some MIT graduates to improve LOGO further.
LCSI versus competitors Back when MIT was asking its lawyers to determine who owned Apple LOGO, a group of MIT’s faculty and students became impatient. The group, headed by Cynthia Solomon (one of the original inventors of LOGO), 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 quite successful. Apple, IBM, Atari, and Microsoft all hired LCSI to write versions of LOGO. Commodore hired Terrapin instead.
If you have an Apple 2c (or 2e or 2+), you can 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 has become less popular. That leaves just two major players: Terrapin and LCSI. Generally speaking, LCSI’s versions of LOGO are daring — LCSI tried wild experiments — while Terrapin’s versions of LOGO are conservative — closer to the MIT original.
The two companies have different styles. Terrapin is small and friendly and charges very little. LCSI is large, charges more, and is often rude. Terrapin gives more help to customers on the phone than LCSI.
The original owners of Terrapin 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, which is run by Bill Glass, a friendly guy. To find out about his Terrapin LOGO, look at his Web site (www.terrapinlogo.com) then phone him at 800-774-Logo (or 617-547-Logo) or write to 10 Holworthy St., Cambridge MA 02138.
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 US mail at PO Box 162, Highgate Springs VT 05460.
LOGO versus BASIC Most of LOGO’s designers hate BASIC. They believe BASIC should be eliminated from schools altogether.
They believe LOGO is easier to learn than BASIC, and that LOGO encourages a kid to be more creative. They also believe that LOGO leads the kid to think in a more organized fashion than BASIC. They also argue that since LOGO is best for little kids, and since switching languages is difficult, the 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 a knowledge of BASIC is essential to surviving in our computerized society. Today, 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 and science and graphics that LOGO lacks.
Another advantage of BASIC over LOGO is that LOGO suffers from awkward notation. For example, in BASIC you can type a formula such as —
but in LOGO you must type:
Notice how ugly the LOGO command looks! Notice you must put a quotation mark before the A but must not but a quotation mark afterwards! And look at those frightful colons! Anybody who thinks such notation is great for kids is a fool.
Extensible One of the nicest things about LOGO is that you can change it and turn it into your own language! That’s 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. Although some earlier languages (such as LISP) were extensible also, LOGO is more extensible and more pleasant.
Like LOGO, FORTH is extensible. But FORTH has two advantages over LOGO:
Since FORTH is extensible and consumes so little of the computer’s memory and time, professional programmers use it often. Famous programs written in FORTH include Easywriter (which is a word-processing program for the Apple and the IBM Personal Computer), Valdocs (which is the operating system for Epson’s first computer), and Rapid File (an easy-to-learn data-management system developed by Miller Microcomputer Systems and sold by Ashton-Tate).
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:
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”. On the other hand, postfix notation seems inhuman: it’s hard for a human to read.
Like FORTH, Hewlett-Packard pocket calculators use postfix notation. So if you’ve already had experience with a Hewlett-Packard 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 often 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, during 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. Since he was using an old IBM 1130 minicomputer, which couldn’t handle a name as long as “FOURTH”, he omitted the letter “U”.
PILOT was invented at the San Francisco branch of the University of California, by John Starkweather in 1968. It’s easier to learn than BASIC, but it’s intended to be used by teachers instead of students. Teachers using PILOT can easily make the computer tutor 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 BASIC, and more easily in PILOT:
Notice that the PILOT program is briefer than BASIC.
Atari, Apple, and Radio Shack all sell 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.
Although PILOT is easier than BASIC, most teachers prefer to learn BASIC because BASIC is available on more computers, costs less, and accomplishes a greater variety of tasks. Hardly anybody uses PILOT.
For specialized applications, use a special language.
If you use APT, the computer will help you cut metal.
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:
DYNAMO uses these symbols:
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:
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:
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 that show how the population, birth rate, etc. will change during this century and the next. Here are some of the results:
The graph shows 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).
Dwindling natural resources are the main problem. Suppose scientists suddenly make a new discovery that lets us reduce our usage of natural resources by 75%. Will our lives be better?
Here’s what the computer predicted would happen, if the “new discovery” were made in 1970:
In that picture, you see the graph of natural resources changing sharply in 1970, because of the new scientific discovery. As a result, people live well, so that 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 is 40 times as great as in 1970; then most people on earth die, so that the world 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 them backfired. The graphs showed that the only way to maintain a high quality of life throughout the next century is to adopt a combination strategy now:
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:
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.
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:
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:
(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 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:
On each line:
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:
To write the program, fill out four forms.
The first form describes the controls and files, like COBOL’s environment division. Here’s how to fill it out:
Line 01 says “008 008”. That makes the computer reserve 8 kilobytes of memory for the program.
Line 02 describes the file MANHOURS. The “IP” means the file is for Input and is the Primary file. The “96” means each card in the file has 96 characters. The “MFCU1” means card reader #1.
Line 03 says “ADDLIST” will be the name of the Output file, which has 96 columns and will appear on the PRINTER.
The second form describes the input:
Line 01 says the file MANHOURS is unorganized (“AA”), reading a card from the file is called “activity #01”. The remaining lines say that 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.
The third form describes the calculations:
That form says: 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.
The fourth form describes the output:
That form explains how to print the file ADDLIST.
After you’ve filled out the four forms in longhand, type what you wrote. Here’s the RPG program:
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.
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:
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:
If a person said “Democrat Male”, you’d feed the computer this line:
This SPSS program makes the computer analyze the data:
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:
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.
If you want options 3 and 5, put this statement under the CROSSTABS statement:
The CROSSTABS statement has statistics. Here are some of them:
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:
It makes the computer print statistics 1 and 8 underneath the table. If you want the computer to print all 9 statistics, say:
The CROSSTABS statement is called a procedure. Here are other procedures SPSS can handle:
Each procedure has its own OPTIONS and STATISTICS.
SPSS includes many other kinds of statements:
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.
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.
Today, 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:
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.
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:
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:
(To indent, press the TAB key. To stop indenting, press the left-arrow key.) When you’ve typed all that, press the ESCape key and 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:
The computer will answer:
Does Alice love football? Ask this:
The computer will answer:
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:
Advanced questions What does Alice love? Does Alice love something? Ask this:
The computer will answer:
What does Tom love? Does Tom love something? Ask:
The computer will answer:
Who loves tennis? Ask:
The computer will answer:
Does anybody love hockey? Ask:
The computer doesn’t know of anybody who loves hockey, so the computer will answer:
Does Tom love something that Alice doesn’t? Ask:
The computer will answer:
That’s ideal PROLOG.
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?