Total Pageviews

Saturday, August 13, 2011

Programming languages


Machine language
One implication of the stored-program model was that programs could read and operate on other programs as data; that is, they would be capable of self-modification. Konrad Zuse had looked upon this possibility as “making a contract with the Devil” because of the potential for abuse, and he had chosen not to implement it in his machines. But self-modification was essential for achieving a true general-purpose machine.
One of the very first employments of self-modification was for computer language translation, “language” here referring to the instructions that make the machine work. Although the earliest machines worked by flipping switches, the stored-program machines were driven by stored coded instructions, and the conventions for encoding these instructions were referred to as the machine's language.
Writing programs for early computers meant using the machine's language. The form of a particular machine's language is dictated by its physical and logical structure. For example, if the machine uses registers to store intermediate results of calculations, there must be instructions for moving data between such registers.
The vocabulary and rules of syntax of machine language tend to be highly detailed and very far from the natural or mathematical language in which problems are normally formulated. The desirability of automating the translation of problems into machine language was immediately evident to users, who either had to become computer experts and programmers themselves in order to use the machines or had to rely on experts and programmers who might not fully understand the problems they were translating.
Automatic translation from pure mathematics or some other “high-level language” to machine language was therefore necessary before computers would be useful to a broader class of users. As early as the 1830s, Charles Babbage and Lady Lovelace had recognized that such translation could be done by machine (see the earlier section Lady Lovelace, the first programmer), but they made no attempt to follow up on this idea and simply wrote their programs in machine language.
Howard Aiken, working in the 1930s, also saw the virtue of automated translation from a high-level language to machine language. Aiken proposed a coding machine that would be dedicated to this task, accepting high-level programs and producing the actual machine-language instructions that the computer would process.
But a separate machine was not actually necessary. The IAS model guaranteed that the stored-program computer would have the power to serve as its own coding machine. The translator program, written in machine language and running on the computer, would be fed the target program as data, and it would output machine-language instructions. This plan was altogether feasible, but the cost of the machines was so great that it was not seen as cost-effective to use them for anything that a human could do—including program translation.
Two forces, in fact, argued against the early development of high-level computer languages. One was skepticism that anyone outside the “priesthood” of computer operators could or would use computers directly. Consequently, early computer makers saw no need to make them more accessible to people who would not use them anyway. A second reason was efficiency. Any translation process would necessarily add to the computing time necessary to solve a problem, and mathematicians and operators were far cheaper by the hour than computers.
Programmers did, though, come up with specialized high-level languages, or HLLs, for computer instruction—even without automatic translators to turn their programs into machine language. They simply did the translation by hand. They did this because casting problems in an intermediate programming language, somewhere between mathematics and the highly detailed language of the machine, had the advantage of making it easier to understand the program's logical structure and to correct, or debug, any defects in the program.
The early HLLs thus were all paper-and-pencil methods of recasting problems in an intermediate form that made it easier to write code for a machine. Herman Goldstine, with contributions from his wife, Adele Goldstine, and from John von Neumann, created a graphical representation of this process: flow diagrams. Although the diagrams were only a notational device, they were widely circulated and had great influence, evolving into what are known today as flowcharts.
 
Zuse's Plankalkül
Konrad Zuse developed the first real programming language, Plankalkül (“Plan Calculus”), in 1944–45. Zuse's language allowed for the creation of procedures (also called routines or subroutines; stored chunks of code that could be invoked repeatedly to perform routine operations such as taking a square root) and structured data (such as a record in a database, with a mixture of alphabetic and numeric data representing, for instance, name, address, and birth date). In addition, it provided conditional statements that could modify program execution, as well as repeat, or loop, statements that would cause a marked block of statements or a subroutine to be repeated a specified number of times or for as long as some condition held.
Zuse knew that computers could do more than arithmetic, but he was aware of the propensity of anyone introduced to them to view them as nothing more than calculators. So he took pains to demonstrate nonnumeric solutions with Plankalkül. He wrote programs to check the syntactical correctness of Boolean expressions (an application in logic and text handling) and even to check chess moves.
Unlike flowcharts, Zuse's program was no intermediate language intended for pencil-and-paper translation by mathematicians. It was deliberately intended for machine translation, and Zuse did some work toward implementing a translator for Plankalkül. He did not get very far, however; he had to disassemble his machine near the end of the war and was not able to put it back together and work on it for several years. Unfortunately, his language and his work, which were roughly a dozen years ahead of their time, were not generally known outside Germany.
 
Interpreters
HLL coding was attempted right from the start of the stored-program era in the late 1940s. Shortcode, or short-order code, was the first such language actually implemented. Suggested by John Mauchly in 1949, it was implemented by William Schmitt for the BINAC computer in that year and for UNIVAC in 1950. Shortcode went through multiple steps: first it converted the alphabetic statements of the language to numeric codes, and then it translated these numeric codes into machine language. It was an interpreter, meaning that it translated HLL statements and executed, or performed, them one at a time—a slow process. Because of their slow execution, interpreters are now rarely used outside of program development, where they may help a programmer to locate errors quickly.
 
Compilers
An alternative to this approach is what is now known as compilation. In compilation, the entire HLL program is converted to machine language and stored for later execution. Although translation may take many hours or even days, once the translated program is stored, it can be recalled anytime in the form of a fast-executing machine-language program.
In 1952 Heinz Rutishauser, who had worked with Zuse on his computers after the war, wrote an influential paper, Automatische Rechenplanfertigung bei programmgesteuerten Rechenmaschinen (loosely translatable as “Computer Automated Conversion of Code to Machine Language”), in which he laid down the foundations of compiler construction and described two proposed compilers. Rutishauser was later involved in creating one of the most carefully defined programming languages of this early era, ALGOL. (See next section, FORTRAN, COBOL, and ALGOL.)
Then, in September 1952, Alick Glennie, a student at the University of Manchester, England, created the first of several programs called Autocode for the Manchester Mark I. Autocode was the first compiler actually to be implemented. (The language that it compiled was called by the same name.) Glennie's compiler had little influence, however. When J. Halcombe Laning created a compiler for the Whirlwind computer at the Massachusetts Institute of Technology (MIT) two years later, he met with similar lack of interest. Both compilers had the fatal drawback of producing code that ran slower (10 times slower, in the case of Laning's) than code handwritten in machine language.
FORTRAN, COBOL, and ALGOL
Grace Murray Hopper
  • Grace Murray Hopper at the UNIVAC keyboard, c. 1960.
While the high cost of computer resources placed a premium on fast hand-coded machine-language programs, one individual worked tirelessly to promote high-level programming languages and their associated compilers. Grace Murray Hopper taught mathematics at Vassar College, Poughkeepsie, New York, from 1931 to 1943 before joining the U.S. Naval Reserve. In 1944 she was assigned to the Bureau of Ordnance Computation Project at Harvard University, where she programmed the Mark I under the direction of Howard Aiken. After World War II she joined J. Presper Eckert, Jr., and John Mauchly at their new company and, among other things, wrote compiler software for the BINAC and UNIVAC systems. Throughout the 1950s Hopper campaigned earnestly for high-level languages across the United States, and through her public appearances she helped to remove resistance to the idea. Such urging found a receptive audience at IBM, where the management wanted to add computers to the company's successful line of business machines.
 
IBM develops FORTRAN
In the early 1950s John Backus convinced his managers at IBM to let him put together a team to design a language and write a compiler for it. He had a machine in mind: the IBM 704, which had built-in floating-point math operations. That the 704 used floating-point representation made it especially useful for scientific work, and Backus believed that a scientifically oriented programming language would make the machine even more attractive. Still, he understood the resistance to anything that slowed a machine down, and he set out to produce a language and a compiler that would produce code that ran virtually as fast as hand-coded machine language—and at the same time made the program-writing process a lot easier.
By 1954 Backus and a team of programmers had designed the language, which they called FORTRAN (Formula Translation). Programs written in FORTRAN looked a lot more like mathematics than machine instructions:
DO 10 J = 1,11
I = 11 − J
Y = F(A(I + 1))
IF (400 − Y) 4,8,8
4 PRINT 5,1
5 FORMAT (I10, 10H TOO LARGE)

The compiler was written, and the language was released with a professional-looking typeset manual (a first for programming languages) in 1957.
FORTRAN took another step toward making programming more accessible, allowing comments in the programs. The ability to insert annotations, marked to be ignored by the translator program but readable by a human, meant that a well-annotated program could be read in a certain sense by people with no programming knowledge at all. For the first time a nonprogrammer could get an idea what a program did—or at least what it was intended to do—by reading (part of) the code. It was an obvious but powerful step in opening up computers to a wider audience.
FORTRAN has continued to evolve, and it retains a large user base in academia and among scientists.
 
COBOL
About the time that Backus and his team invented FORTRAN, Hopper's group at UNIVAC released Math-matic, a FORTRAN-like language for UNIVAC computers. It was slower than FORTRAN and not particularly successful. Another language developed at Hopper's laboratory at the same time had more influence. Flow-matic used a more English-like syntax and vocabulary:
1 COMPARE PART-NUMBER (A) TO PART-NUMBER (B);
IF GREATER GO TO OPERATION 13;
IF EQUAL GO TO OPERATION 4;
OTHERWISE GO TO OPERATION 2.

Flow-matic led to the development by Hopper's group of COBOL (Common Business-Oriented Language) in 1959. COBOL was explicitly a business programming language with a very verbose English-like style. It became central to the wide acceptance of computers by business after 1959.
 
ALGOL
Although both FORTRAN and COBOL were universal languages (meaning that they could, in principle, be used to solve any problem that a computer could unravel), FORTRAN was better suited for mathematicians and engineers, whereas COBOL was explicitly a business programming language.
During the late 1950s a multitude of programming languages appeared. This proliferation of incompatible specialized languages spurred an interest in the United States and Europe to create a single “second-generation” language. A transatlantic committee soon formed to determine specifications for ALGOL (Algorithmic Language), as the new language would be called. Backus, on the American side, and Heinz Rutishauser, on the European side, were among the most influential committee members.
Although ALGOL introduced some important language ideas, it was not a commercial success. Customers preferred a known specialized language, such as FORTRAN or COBOL, to an unknown general-programming language. Only Pascal, a scientific programming-language offshoot of ALGOL, survives.

No comments:

Post a Comment