A new programming language for quantum computing

The language can describe and verify which pieces of data are entangled to prevent bugs in a quantum program.


Programming quantum computers require awareness of entanglement, the phenomenon in which measurement outcomes of qubits are correlated. Entanglement can determine the correctness of algorithms and the suitability of programming patterns.

Entangled qubits give rise to Einstein’s characterization of “spooky action at a distance.” But that potency is equal parts a source of weakness. While programming, discarding one qubit without being aware of its entanglement with one more qubit can obliterate the information put away in the other, endangering the accuracy of the program.

MIT scientists have created their programming language for quantum computing. This new language, called Twist, can describe and verify which pieces of data are entangled in a quantum program.

To create this new language, scientists used a concept called Purity. It enforces the absence of entanglement and results in more intuitive programs, with ideally fewer bugs.

Charles Yuan, an MIT Ph.D. student in electrical engineering and computer science and the lead author of a new paper about Twist, said, “Our language Twist allows a developer to write safer quantum programs by explicitly stating when a qubit must not be entangled with another. Because understanding quantum programs requires understanding entanglement, we hope that Twist paves the way to languages that make the unique challenges of quantum computing more accessible to programmers.”

The Twist is designed to be expressive enough to write out programs for well-known quantum algorithms and identifies bugs in their implementations. They evaluated the design by modifying the programs to introduce a relatively subtle bug for a human programmer to detect. It showed that Twist could automatically identify the bugs and reject the programs.

Yuan said, “For those wary of quantum’s “seedy” reputation in its potential to break encryption systems, it’s still not very well known to what extent quantum computers will be able to reach their performance promises in practice. There’s a lot of research that’s going on in post-quantum cryptography, which exists because even quantum computing is not all-powerful. So far, there’s a particular set of applications in which people have developed algorithms and techniques where a quantum computer can outperform classical computers.”

Using Twist, scientists are further planning to create higher-level quantum programming languages.

Fred Chong, the Seymour Goodman Professor of Computer Science at the University of Chicago and chief scientist at Super. Tech said“Quantum computers are error-prone and difficult to program. By introducing and reasoning about the ‘purity’ of program code, Twist takes a big step towards making quantum programming easier by guaranteeing that the quantum bits in a pure piece of code cannot be altered by bits, not in that code.”

Journal Reference:

  1. Charles Yuan, Christopher McNally, and Michael Carbin. Twist: Sound Reasoning for Purity and Entanglement in Quantum Programs. DOI: 10.5281/zenodo.5541967


See stories of the future in your inbox each morning.