News

# Q# Is for Quantum Computing: A New Programming Language from Microsoft

December 16, 2017 by Chantelle Dubois

## Microsoft recently released a preview of a new programming language that will be used specifically for quantum computing programming: Q# (pronounced ‘Q-sharp’).

Microsoft recently released a preview of a new programming language that will be used specifically for quantum computing programming: Q# (pronounced ‘Q-sharp’).

The company’s goal is to eventually create a full software stack that will give interested developers a chance to learn about quantum computing programming before the technology becomes more readily available.

Built from the ground up to support quantum computing programming, Q# is a high-level programming language meant for writing scripts that will execute its sub-programs on a quantum processor that is linked to a classic host computer which receives its results. This is not unlike hybrid computer architecture types such as CPUs and GPUs, or CPUs and FPGAs.

Developers using the language need not have in-depth knowledge of quantum physics. For the interested, Microsoft does provide a primer on essential quantum computing concepts, covering vector and matrix mathematics, the qubit, Dirac notation, Pauli measurements, and quantum circuits.

The Q# development kit is available for free with detailed instructions on how to install it and introductory programming tutorials. Q# compiles on a Visual Studio quantum simulator, simulating a 32 qubits quantum processor. The Azure edition of the simulator can simulate up to 40 qubits.

Microsoft expects that a quantum computing stack will contain several different layers of software and hardware all running at different temperatures to operate. For example, cryogenic processors or FPGAs are likely going to be required to handle error correcting in quantum computers, and a classical host computer will also work in tandem with the quantum computer since qubits are not stable.

Q# is meant to abstract away from the requirements of managing all of these layers from the developer, so that the focus can remain on algorithm development and problem solving, using a language that looks familiar.

### What Does Q# Look Like

At first blush, the Q# programming language looks not unlike most other programming languages, and is very similar to its C# counterpart.

The very first tutorial provided by Microsoft involves creating a Q# Bell State script—the four entangled states of two qubits. The end result leads to observing entanglement in two measured bits in the output of the program. A later tutorial walks the user through writing a script to simulate quantum teleportation. Microsoft hopes that introducing such a novel concept to would-be developers may pique interest in the language and quantum computing.

Q# has a few interesting primitive types. In addition to the more typical ones such as int, double, bool, and string, there is also a Pauli, Range, Result, and Qubit type.

There are also many Q# quirks in the language, including functions being referred to as operations, and so on.

##### Quantum Circuit for Teleportation. Image courtesy of Microsoft.

operation Teleport(msg : Qubit, there : Qubit) : () {
body {
using (register = Qubit[1]) {
let here = register[0];
H(here);
CNOT(here, there);
CNOT(msg, here);
H(msg);
// Measure out the entanglement.
if (M(msg) == One) { Z(there); }
if (M(here) == One) { X(there); }

}
}
}
##### Teleportation.qs script from the Q# tutorial. Tutorial available here.

For the more algorithmically inclined, it might be worth checking out the Quantum Algorithm Zoo for ideas on how to play with Q#.

### Quantum Computing for Solving Hard Problems

Quantum computing is expected to disrupt many industries and fields once it becomes available and ubiquitous. Many encryption methods being used today will no longer be effective against quantum computing, including RSA.

However, quantum computing will also help us solve pretty complex problems. It will even solve the encryption problem it initially undoes, since quantum encryption will be, as far as we are concerned, completely secure.

It will also become possible to model chemical and protein interaction for drug design and could open the door for individual drug design therapy, where drugs are developed based on an individual’s genetics. Or help us address climate change through weather and climate prediction modeling. We’ll be that much closer to successfully modeling the human brain, creating much more capable artificial intelligence, and basically making a leap in every major tech domain.

For now, we can prepare ourselves by becoming acquainted with Q# and being ready for when we can start putting our quantum algorithms to work.

Feature image courtesy of Microsoft.

• Share