Ada Lovelace (1815-1852) was a British mathematician involved in the extremely early history of computers, long before the "modern era" of actual construction of working computers. She worked with Charles Babbage on an extremely visionary, completely mechanical, computer called the "analytical engine". It was never built, because Babbage's design was way ahead of its time.
She is noteworthy for writing an 1843 paper with Luigi Menabrea (it actually started out has her translation of Menabrea's shorter paper from French to English; she then added extensive notes) about the analytical engine. The paper ends with the famous "Note G", in which she analyzes an algorithm for calculating Bernoulli numbers and shows the code for it on the (never built) machine. Because of this, she is often credited with "writing the first computer program" and being "the world's first computer programmer.". While this was not a program written in anything that would be recognized as a programming language in the modern sense, it was the first mathematical algorithm encoded for the purpose of being executed by an automatically controlled digital computer. That is, she wrote the first published, surviving computer program designed to solve a real problem.
But the issue is not clear-cut, because there are different opinions about what constitutes a "program" and what constitutes a "computer". Perhaps the main objection is that the computer for which her program was written was never built, so her program did not actually run. Ada had to write the algorithm on paper, rather than at a keypunch or computer terminal, of course. But, to use modern terminology, she actually "wrote code". Also, since the term "program" had not been coined, she described her algorithm as a "plan". In the 20th century, the program was carefully analyzed and simulated, and found to have a minor "bug". The controversy will be discussed at length below.
- 1 Early life
- 2 What would the program have done, had the Analytical Engine been built?
- 3 What did Ada's Bernoulli program look like?
- 4 Was it a computer?
- 5 How can someone have written a computer program in 1843? Computers hadn't been invented!
- 6 But was it really a program?
- 7 How about loops? "Do/while"? "For"? "Goto"?
- 8 Was Ada really first? Was the Bernoulli program the first program?
- 9 Why is there controversy about this?
- 10 The ADA programming language
- 11 References
- 12 Further reading
She was the only legitimate child of the famous British poet Lord Byron, but he abandoned her and her mother before her first birthday. She was raised by her mother.
She was born Augusta Ada Byron, and called by her middle name as a child. She married William King, who later became Earl of Lovelace, making her "Countess of Lovelace". She has been called Augusta Ada, Augusta Ada Byron, Augusta Ada Lovelace, Ada Lovelace, Ada King, or just Ada.
In October 1842 Luigi Federico Menabrea (1809-1896), an Italian professor of mechanics at University of Turin (and later premier of the Kingdom of Italy), published a paper describing the function and theory of Babbage's Analytical Engine. Ada translated the paper from French to English and added her own extensive comments. (See Science and Reform, Selected Works of Charles Babbage by Anthony Hyman.) This was published in 1843 and impressed Babbage, for it included, as Babbage himself wrote,
|“||some complicated programs of her own, the most complex of these being one to calculate the sequence of Bernoulli numbers.||”|
What would the program have done, had the Analytical Engine been built?
Her program calculated Bernoulli numbers. These are a series of numbers (unlike the factorials or Fibonacci numbers, they are not integers—the Analytical Engine could handle that) that have certain interesting properties in mathematical analysis. They are significantly harder to calculate than factorials or Fibonacci numbers. It should be noted that the recurrence relations and power series coefficients used to compute them were known well before Ada's paper—she just coded it for the analytical engine.
What did Ada's Bernoulli program look like?
The program, and detailed technical commentary, appeared in the paper "Sketch of the Analytical Engine Invented by Charles Babbage" that Ada wrote in 1843. The program itself has been reproduced in the "sidebar" on page 79. It can also be seen in the original paper. First there is a list of the six input and output variables that are used: V1, V2, V3, V21, V22 and V23. And the temporary variables V4 through V13. In modern terminology in a strongly typed language such as C++, we would write something like:
int V1, V2, V3; // inputs int V21, V22, V23; // outputs int V4, V5, V6, V7, V8, V9, V10, V11, V12, V13; // temps
At the start of the program, she gives initialization of V1=1, V2=2, and V3=N. (Modern computers often have "immediate" instructions to handle constants without using up registers.)
Then she lists the 25 instructions, giving their source and destination registers, opcodes, and commentary on the progress of the program. The first 5 instructions, for example, are:
V4=V5=V6 = V2 * V3; // Get 2N. The machine allowed multiple destination registers. V4 = V4 - V1; // Get 2N-1. V5 = V5 + V1; // Get 2N+1. V11 = V4 / V5; // Get (2N-1)/(2N+1). V11 = V12 / V2; // Get (1/2) * (2N-1)/(2N+1).
(She used the old-fashioned multiply and divide signs "" and "". These seem quaint by today's standards, but they were the symbols that people used at the time. Neither the 026 keypunch nor the ASCII character set had been invented.)
She used two loops—see the other sidebar on page 78. V10 is the outer loop counter. The loop consists of instructions 13 to 23. It continues until V10 counts down to 1.
Was it a computer?
The "analytical engine" was so far ahead of its time that one might be tempted to call it just a "visionary idea". The technology of the time was nowhere near capable of building it. Even the much-less-ambitious "difference engine" was beyond the technology of the day—making the counters do arithmetic reliably required very careful machining of the parts. Only a small partial prototype of the difference engine was built in Babbage's lifetime. But Babbage clearly knew what he wanted. His vision of a calculating device that can perform operations under control of a "program" punched into cards, and that makes control decisions based on the data resulting from the calculation steps, was incredibly prescient. It was exactly the principle used in modern computers. Lovelace understood that vision, and even extended it to the idea that computers might perform tasks beyond purely numerical ones, such as composing music. The fact that the analytical engine was mechanical rather than electronic did not make it any less a computer. It just made it harder to build. It took about 100 years for the field of electrical engineering to make computers such as that envisioned by Babbage realizable.
How can someone have written a computer program in 1843? Computers hadn't been invented!
One needs to be flexible in one's thinking about what constitutes a "computer" or a "program". It's certainly true that nothing like the modern conception of a computer had been invented. But, at a deeper philosophical level, we can say that Babbage, Lovelace, and Menabrea (and undoubtedly a few of their colleagues) saw a fundamental truth: It is possible for an automatic machine to process information. That is the essence of computing.
The computer involved was the "Analytical Engine", conceived and designed by the amazingly talented Charles Babbage. His visionary idea of a machine that automatically processes information (that is, a computer) was about 100 years ahead of its time. It was purely mechanical (that fact alone makes it seriously inferior to modern electronic computers), but it was, in principle, a workable idea. Babbage was very familiar with the Jacquard loom, which was a device for weaving complex tapestries under the control of punched cards mechanically linked together and running around a track. It had the ability to move the cards forward and backward, executing complex loops. (This makes it somewhat like a Turing Machine, though the similarity ends there.) The Analytical Engine was essentially a glorified Jacquard loom, controlling an arithmetic unit (completely mechanical, of course) instead of a weaving loom. A mechanical arithmetic unit was also a rather visionary idea, but Babbage knew how to do it, as shown by his earlier design of the "Difference Engine". The Difference Engine was not completed in Babbage's lifetime either, but it came close. Both machines were beyond the ability of the mechanical engineering technology of the day. But in 1991 a Difference Engine was completed, and it works perfectly (albeit millions of times slower than an electronic computer.)
The Analytical Engine was basically a Difference Engine programmed by the punched cards of a Jacquard loom. The Difference Engine part of it is what we would now call the "Arithmetic Logic Unit", or ALU. (At the time, it was called the "mill".)
The Analytical Engine design got the attention of Luigi Federico Menabrea (1809-1896), an Italian professor of mechanics at University of Turin (and later premier of the Kingdom of Italy), and of Ada Lovelace. Menabrea wrote a paper about it in 1842, and, at Babbage's suggestion, Lovelace translated it from French to English. She also added notes of her own, that in fact comprised about 3/4ths of the final paper, and that are frequently quoted even today.
Biographer Betty Toole wrote: "Her 'Notes' also predict that, given the right algorithms, calculating engines might compose music and create graphics. She even presaged Alan Turing and the 'garbage-in, garbage out' effect, saying, 'The Analytical Engine has no pretensions whatever to originate any thing. It can do whatever we know how to order it to perform -- it has no power of anticipating any analytical relations or truths.'" This statement is often quoted even today as a profound truism about computers.
Toole further says: "Ada suggested to Babbage writing a plan for how the engine might calculate Bernoulli numbers. This plan is now regarded as the first 'computer program.'"
Ada's "Note G" contains the Bernoulli program. Reading the Menabrea/Lovelace paper, one is struck by the degree to which they had to break new ground. Computers, and the field of computer science, had not been invented. They had to figure out what it meant to have a computer, and to encode mathematical algorithms for it. What they figured out is very different from modern computer science, but one can see the beginnings in the Menabrea/Lovelace paper.
But was it really a program?
It is impossible to answer this to everyone's satisfaction. One's answer to this depends on how much one is willing to accept something that looks very different from what programs look like today. Keep in mind that essentially all of the vocabulary of modern computer science did not exist. For example, here are some terms that are staples of thinking about computers in the modern world:
- Source Code
- Machine code
- Assembly Code
- any kind of Code
- High-Level Language
- Low-level Language
- Assembly Language
- any kind of Computer Language
- Flow Chart
None of these terms existed at the time. (Of course the words existed, but they had no meaning in the context of computers.) Nevertheless, Babbage, Lovelace, and Menabrea understood what it would mean for an automatic machine to process information, a vision that would not come to fruition for another century.
One must keep an open mind about what "machine code" looks like for a machine that reads its instructions with rods poking through holes in large punched cards running around on a track, and does its arithmetic by counting teeth on turning gears.
Ada certainly didn't punch the program on cards or type it into a computer terminal. (She might conceivably have punched it onto cards if Babbage had made his design sufficiently concrete as to assign binary opcodes, but he never got anywhere near that far.) Since it never ran on a computer in the form in which she wrote it, it could be argued that it wasn't a program, but was merely an algorithm. But, whatever it was, it was written in the peculiarly stilted language of computer machine code. That is, the numbers that it was manipulating were assigned to specific registers. As the iteration loop cycled around, those registers were overwritten with new values. That is not the way ordinary mathematical algorithms are expressed. They are expressed in terms of more abstract formulas and recurrences. In Ada's case, the formulas were broken down into individual operations, manipulating specific registers that she specified.
Algorithms like Euclid's algorithm or Heron's formula, or even integration techniques or the description of the factorial function, are not described that way unless one is writing a computer program.
"Algorithms" for calculating Bernoulli numbers had been known for some time. But she wrote this "algorithm" in the form of specifically realizable numerical operations that she (naively, Babbage's design was far beyond what the technology of the day would have provided) believed the analytical engine could have done. And she used the specific ability of a calculating device to make control decisions based on the data.
Biographer Martin Campbell-Kelly says that she was "a computer pioneer, if not a programmer as the term is understood today".
Some have suggested that Ada could not have been a programmer because, as her Biographer Betty Toole wrote: "Ada certainly did not invent a computer language.". Toole is correct; no computer language was involved.
The important point is that the algorithm that Lovelace put in her "Note G" was encoded for the purpose of being executed by an automatically controlled digital computer. That is, she wrote the first published, surviving computer program designed to solve a real problem.
How about loops? "Do/while"? "For"? "Goto"?
As Ada's note C points out, the Jacquard loom, and hence the analytical engine, had the ability to automatically back up the card sequence and thereby repeat instructions in what would now be called a "loop", though the exact mechanism isn't described. Note G shows the repetition: cards 1-12 are processed once (we would call this "initialization"), cards 13-23 are repeated a number of times depending on which Bernoulli number is desired (we would call this the "loop") and cards 24-25 are processed once at the end. (Calculation of B1 is a special case and does not involve cards 8-12.)
But, since programming languages had not been invented, Lovelace had to express this in terms of the way the Jacquard loom worked. She did this by drawing large "curly braces" in the left margin. The paper does not say how that would actually be coded so that the analytical engine would control the operation.
Was Ada really first? Was the Bernoulli program the first program?
There are those who claim  that Babbage himself, or an assistant of his, or perhaps some of his sons, must have written "programs" before Ada did. Issues like this arise from time to time, perhaps most notably in the "calculus war" between Newton and Leibniz, or the "non-Euclidean geometry war" among Gauss, Bolyai, and Lobachevsky. The scientific community generally gives great weight to the act of publishing one's work. If these other people wrote programs before Ada did, they don't seem to have published them, and they are lost. It is not known what problems these earlier programs might have been solving.
Why is there controversy about this?
In addition to the inevitable controversy about the scientific issues:
- Was a "program" written 100 years before the invention of the modern computer really a "program"?
- Was the Analytical Engine really a computer?
- Is it significant that the Analytical Engine was never built, and hence that this program never ran as intended?
- Was the Lovelace/Bernoulli program actually first?
There may be additional social/political issues because Ada Lovelace was a woman. The issue of Women in Science and Mathematics has long been a contentious one, because the field is dominated by men. There are those that feel that women who have made significant contributions should be held up as role models to encourage girls to go into these fields (the effect is particularly pronounced in the case of Marie Curie), and those who disagree. As often happens, people sometimes mix these issues with other political issues, such as the entire issue of feminism.
But one should keep in mind that nothing about modern feminism or educational/social issues has any bearing on what happened 170 years ago.
The ADA programming language
Starting in the 1970s, a project was undertaken by the U.S. Department of Defense to find one high-level language to be used for all DoD software, replacing the hundreds of languages then in use. After much evaluation work, the winning language (called "green" in the evaluation process) was named ADA in Ada Lovelace's honor. Its goal of replacing all the previous languages has not been met, partly because interoperability considerations have changed the way software is put together, relative to the way things were done in the 1970s. The ADA language has had less than complete acceptance in the military, and is not widely used in the civilian sector.
- Menabrea's Sketch and Ada's Notes
- Scientific American, May 1999, pp76
- Augusta Ada Byron (1815-1852) - Ryan Stansifer, Associate Professor - Department of Computer Sciences - Florida Institute of Technology
- That Babbage knew what he was doing is attested to by the fact that his full difference engine was finally constructed in 1991 (the bicentennial of Babbage's birth) and is on display at the London Science Museum. Babbage's original plans were almost exactly correct.
- This sometimes gets rather silly
- Repurposing Ada - contains several denials (including one by a biographer) that her "Notes" were a computer program
- Menabrea's Sketch and Ada's Notes
- Ada, The Enchantress of Numbers: Poetical Science, Betty Toole (e-book)
- Ada, the Enchantress of Numbers: A Selection from the Letters of Lord Byron's Daughter and Her Description of the First Computer, Betty Toole, 1992, ISBN 978-0912647098
- Ada, the Enchantress of Numbers: Prophet of the Computer Age, Betty Toole, 1998, ISBN 978-0912647180
- Computer: A History Of The Information Machine, Second Edition, Martin Campbell-Kelly & William Aspray, 2004, ISBN 978-0813342641