Programming Your Quantum Computer
The hardware doesn’t yet exist, but languages for quantum coding are ready to go.
A Functional Solution
The language called Quipper was developed in the past few years by Peter Selinger of Dalhousie University in Canada, with four colleagues. An implementation is available at http://www.mathstat.dal.ca/~selinger/quipper/.
Quipper is intended for the same kinds of programming tasks as QCL, but it has a different structure and appearance. The language is implemented as an extension of the programming language Haskell (named for the logician Haskell B. Curry), which adopts a functional rather than imperative mode of expression. That is, the language is modeled on the semantics of mathematical functions, which map inputs to outputs but have no side effects on the state of other variables. A functional style of programming seems more closely attuned to the constraints of quantum computing, although Haskell does not enforce the quantum rule that a variable can be assigned a value only once.
The Quipper system is a compiler rather than an interpreter; it translates a complete program all in one go rather than executing statements one by one. The output of the compiler consists of quantum circuits: networks of interconnected, reversible logic gates. A circuit can take the form of a wiring diagram, such as the one above, but it also constitutes a sequence of instructions ready to be executed by suitable quantum hardware or a simulator.
I find it mildly ironic that these avant-garde computers have brought us back to the idea of seeing programs as circuits, in which signals flow through long chains of gates. In the 1940s the ENIAC computer was programmed in a similar way, by plugging wires into panels. But Selinger points out there’s an important difference: We now have tools (such as QCL and Quipper) that generate the circuits automatically from a high-level source text.
Selinger and his colleagues set out to produce a practical, “scalable” system, suitable for more than just toy examples. They give solutions to seven benchmark problems, measuring the performance of their quantum programs in terms of the number of qubits needed and the number of gates in the circuits. They are able to handle large problem instances. One program requires 4,676 qubits and 30,189,977,982,990 gates. (They chose not to draw the circuit diagram with 30 trillion gates.)