Skip to content

Al-Jazari and the Programmable Automata

Abstract

In 1206 Ismail al-Jazari, chief engineer at the Artuqid court in Amid (today Diyarbakır, Turkey), finished a book describing fifty machines he had built, among them water clocks with mechanical musicians and a boat of automatic players for royal drinking parties. In 2006 the roboticist Noel Sharkey built a model of the boat’s drummer and called it a programmable drum machine, and the label stuck: al-Jazari is now widely called the inventor of the first programmable robot. His text describes pegs fixed on a rotating shaft; whether anyone ever moved them to change the rhythm is not recorded. A stronger case for an early programmable machine is three and a half centuries older, the automatic flute player of the Banu Musa brothers in ninth-century Baghdad, whose melody was set by pins on a cylinder that could be laid out for any tune, even copied from a live player.

Al-Jazari Musical Boat 1315
The musical boat, from a copy of al-Jazari’s Book of Knowledge of Ingenious Mechanical Devices made in 1315, Freer Gallery of Art, Washington. Image: Farruq ibn Abd al-Latif (calligrapher), public domain, via Wikimedia Commons.

The Banu Musa in Baghdad

Muhammad, Ahmad, and al-Hasan, the three sons of Musa ibn Shakir, worked at the House of Wisdom in Baghdad, the scholarly institution of the caliph al-Ma’mun (reigned 813 to 833). Around 850 they compiled the Book of Ingenious Devices (Kitab al-Hiyal), illustrated designs for about a hundred automatic devices. Donald R. Hill translated it into English in 1979.

A separate treatise of theirs, al-Ala allati tuzammir bi-nafsiha (The Instrument That Plays by Itself), describes a hydraulic organ. A water wheel drives an air pump that feeds a flute through a compressed-air reservoir. The flute has nine holes, eight of them opened and closed by levers, and the levers are lifted by pins on a revolving cylinder, a second water wheel turning the cylinder at a speed that a tap can regulate. The pins are fixed “following circles parallel to the rods,” their lengths proportional to the notes of the melody. The ZKM, which exhibited a reconstruction, describes the cylinder as a way to “freely encode” whatever music the instrument is to play.

The treatise also explains how to make a new cylinder from a performance. A wooden cylinder coated in black wax turns at an even speed; eight levers rest on it, each tied by a string to one finger of a flute player; as the musician plays, the levers scratch the wax. The scratches are measured and replaced by pins of the same length and spacing. The Banu Musa’s original drawing is lost. Mona Sanjakdar Chaarani translated the text from photographic negatives of a manuscript held in two Beirut libraries, and Henry George Farmer had printed a drawing of the instrument in The Organ of the Ancients in 1931. A team at the Berlin University of the Arts built a working reconstruction in 2015 for the ZKM in Karlsruhe.

The historian of mechanism Teun Koetsier put this flute player at the start of his 2001 prehistory of programmable machines, whose title names its three stages: musical automata, looms, and calculators, the last leading to Charles Babbage. The case rests on the separation of mechanism and program: the machine is one thing, the tune is a replaceable part, and the tune can be written down by the machine itself.

Al-Jazari at Amid

Badi al-Zaman Abu al-Izz ibn Ismail ibn al-Razzaz al-Jazari was employed by the Artuqid rulers from the last quarter of the twelfth century. The Artuqid Nasir al-Din Mahmud (reigned 1201 to 1222) commissioned a record of the machines, and al-Jazari completed The Book of Knowledge of Ingenious Mechanical Devices (Kitab fi ma’rifat al-hiyal al-handasiyya) in 1206. The earliest known manuscript, from the same year, is in the Topkapı Palace Library in Istanbul.

The book is a builder’s manual. Hill’s 1974 translation has fifty chapters, grouped in six categories: ten clocks (among them a castle water clock, a “water-clock of the drummers,” and the elephant clock), ten vessels and figures for drinking parties, ten pitchers and basins for hand-washing and blood-letting, ten fountains and “perpetual flutes,” five machines for raising water, and five miscellaneous devices, including a combination lock with twelve letters, a protractor, and the cast brass door of the king’s palace at Amid. Each chapter gives dimensions, materials, and assembly steps. Hill judged that “it is impossible to overemphasize the importance of al-Jazari’s work in the history of engineering.”

The musical boat is the fourth device of the drinking-party category. It floated on a pool in the palace, carrying figures of the king, his companions, and four musicians: a harpist, a flautist, and two drummers. A reservoir emptied slowly into a tipping bucket; when the bucket filled, roughly every half hour, it tipped its water onto a scoop wheel, whose axle carried pegs. The pegs lifted rods connected to the players’ hands, so that each turn of the wheel produced a short performance, while water forced through a whistle stood in for the flute. The spacing of the pegs determined the rhythm.

Sharkey’s Drum Machine

In 2006 the Sheffield computer scientist Noel Sharkey built the core of that mechanism for The Ancient Robots, a History Channel programme due to air in the United States in early 2007. His model had one drummer with a drum, cymbals, and bells, and a penny whistle in place of the flute; in his words he “bodged it together from a pile of rubbish.” Its point, the university’s staff magazine reported, was to show that the drummer “can be made to play different rhythms and different drum patterns if the pegs are moved around. In other words it is a programmable drum machine.”

In July 2007 Sharkey set out the argument in New Scientist. He started from Mark Rosheim’s claim that a clockwork lion of Leonardo da Vinci, built around 1515, was programmable through adjustable arms on its cart, traced the idea back through medieval Europe, and named al-Jazari’s boat as the earlier example. In the same article he went back further still, to the mobile automaton theatre of Heron of Alexandria in the first century AD, whose cart was driven by string wound around its axles; Sharkey wrote its program out as commands such as “Forward (10), Backward (5).” Popular accounts kept the middle step: “the first programmable robot,” dated 1206.

Myth: Al-Jazari built the first programmable robot

The claim comes from Noel Sharkey’s model for a television documentary and his 2007 New Scientist article, not from al-Jazari’s text, which describes pegs on an axle and gives no method for rearranging them to play other rhythms; even an enthusiastic commentary on the boat concludes, “Did al-Jazari actually ‘program’ the musical boat? We will never know.” Sharkey himself was careful: “Whether or not al-Jazari dynamically programmed his machines is an intriguing question,” he said, adding that it was “quite likely” he moved pegs at least to fine-tune the rhythm, and in New Scientist he conceded that “there is no evidence in their writings or elsewhere that they actually programmed their robots.” The same New Scientist piece placed al-Jazari in Baghdad; he worked in Amid. Programmability in the sense of a replaceable program is better documented about 350 years earlier in the Banu Musa’s flute player, whose pinned cylinder could be laid out for any melody and even copied from a recorded performance, and Sharkey himself proposed Heron’s cart, about eight centuries before that. See Myths and Misconceptions.

From Pinned Cylinder to Punched Card

None of these devices computed anything. They are in the prehistory of computing because they separated a sequence of actions from the machine that performed it, and stored that sequence in a medium that could be changed. The pinned cylinder outlived its Baghdad origins by centuries: from the fourteenth century such cylinders rang church bells in Western Europe, Athanasius Kircher described a hydraulic organ on the same principle in 1650, and Jacques de Vaucanson’s mechanical flute player, shown in Paris in 1738, played from a turning cylinder (see Robotics). Vaucanson then applied the stored pattern to an automatic loom in 1745, and Jacquard’s loom of the early nineteenth century replaced his cylinder with a chain of punched cards, the line that led to Babbage’s Analytical Engine (see Before the Computer: Mechanical Calculation). No document connects the Banu Musa or al-Jazari to these European machines directly; the shared principle is easier to show than a chain of transmission.

📚 Sources