◷ Computing history

Grace Hopper: compilers, COBOL and the Mark II moth

Grace Hopper from the Harvard Mark I to the A-0 compiler and COBOL: the idea of programming with words instead of numeric codes, and the famous bug.

In the 1950s, programming a computer meant writing long sequences of numeric codes, each corresponding to a machine instruction. Grace Hopper was among the first to champion an idea that then seemed almost provocative: computers should adapt to people, not the other way round. Her work on compilers and English-oriented languages led to COBOL, one of the longest-lived languages in history.

From mathematics to the Navy

Grace Murray Hopper earned her doctorate in mathematics at Yale in 1934 and taught for some years at Vassar College. In 1943, during the war, she joined the US Navy Reserve. She was assigned to Harvard, to Howard Aiken's group, which ran the Mark I, a large electromechanical calculator built with IBM.

Hopper was among the first programmers of the Mark I. Among other things she wrote much of the machine's manual, a document explaining how to prepare programs on punched tape.

The moth of 9 September 1947

In 1947, while the group was working on its successor, the Mark II, the operators found a moth trapped between the contacts of a relay, causing a malfunction. The moth was removed and taped into the logbook, next to a note reading "First actual case of bug being found". That logbook page is now held at the Smithsonian.

It is often said that the term "bug" was born on that occasion. That is not accurate: the word had long been used by engineers, Thomas Edison among them, to describe a defect in a device. The joke in the logbook works precisely because the term was already familiar. Hopper often told this story, helping to make it famous.

The idea of the compiler

After the war Hopper joined the Eckert–Mauchly Computer Corporation, the company founded by the builders of ENIAC, which was developing UNIVAC. There she ran into a practical problem: many programs contained the same sequences of instructions, which were copied by hand with the risk of introducing errors.

A-0

In 1952 Hopper developed A-0, a system that let you specify which subroutines to use, taking them from a library on tape and automatically assembling them into a complete program. She called it a "compiler", in the literal sense of someone who gathers and puts material together. It was closer to what we would today call a linker or loader than to a modern compiler, but the underlying idea was the same: let the computer write the machine code.

At first the idea was met with scepticism. Hopper recalled being told that computers could only do arithmetic and could not write programs.

FLOW-MATIC: programming in English

Hopper went a step further. She believed that business programs, which handle customer records, invoices and inventory, should be written in a language close to English, understandable even to office managers. Her team developed FLOW-MATIC, one of the first languages whose statements were made of English words.

A statement of that kind read like a sentence: compare the product number with that of the master file, and if they are equal go to a certain step.

COBOL

In 1959 the US Department of Defense sponsored a committee of representatives from companies and government bodies, known as CODASYL, to define a common language for business applications that could run on computers from different manufacturers. The result was COBOL, the Common Business-Oriented Language.

Hopper was a technical adviser to the committee, and FLOW-MATIC was one of the main influences on the new language. That is why she is often called the "grandmother of COBOL", even though the language was the product of collective work.

What a COBOL program looks like

COBOL favours readability over brevity:

IF CUSTOMER-BALANCE IS GREATER THAN CREDIT-LIMIT
    MOVE "BLOCKED" TO CUSTOMER-STATUS
ELSE
    ADD ORDER-AMOUNT TO CUSTOMER-BALANCE
END-IF.

It is verbose, but an auditor can read it and grasp its logic without knowing how to program. That is exactly the goal Hopper had set herself.

Surprising longevity

COBOL is still in use in many banking, insurance and public administration systems. These are systems that have run for decades, handle large volumes of transactions and would be costly and risky to rewrite. Even today, people who work in these environments need to be able to read it.

Other legacies

Throughout her career Hopper insisted on the standardisation of languages and the validation of compilers, topics that were neglected at the time. She was famous for a teaching example: she handed out pieces of wire about thirty centimetres long, the distance light travels in a nanosecond, to show why signals cannot travel instantaneously and why the size of computers matters.

She retired from the Navy in 1986 with the rank of rear admiral. She died in 1992. In 2016 she was posthumously awarded the Presidential Medal of Freedom.

In short

  • Grace Hopper was among the first programmers of the Harvard Mark I and made famous the episode of the moth in the Mark II in 1947, though the term "bug" was already in use.
  • In 1952 she developed A-0, one of the first systems to generate machine code automatically.
  • With FLOW-MATIC she introduced a language based on English words, which influenced COBOL, defined in 1959.
  • COBOL is still in use in many banking and administrative systems.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. With degrees in computer science and psychology, he combines technical analysis with an understanding of the human factor.

Read also