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.

2 Comments
  • R
    Richard Kent Murray Jr. December 22, 2017

    Excuse me, but I am extremely skeptical regarding what I have heard about quantum computing. It sounds to me like random noise and is not likely to accomplish anything. I will try to keep an open mind; I am sure that modern computer science is already based on quantum mechanical principles. But what I’ve heard so far sounds unlikely to work. Trillions of atoms are needed for circuit components to function in a deterministic fashion, trillions, if not quadrillions or quintillions of electrons are needed to escape the essential indeterminate nature of quantum physics. Okay, you might prove me wrong, but I doubt it.

    Like. Reply
  • Roderick Sprague December 22, 2017

    I implore the open source community to come up with a logically consistent, intuitive environment and language to run on quantum computers. I tested with an IQ of over 180. I was trying to simply place a track on my music CD on my personal desktop on a University of Idaho loaner laptop. I had tried all the fastest logical ways to do that and had been “scolded” with the annoying doink sound. A mildly retarded friend of mine then looked over my shoulder and suggested everything I had tried in the same order I had. Huston, we have a problem. I have mild autism and we both have memory issues, so we need a logically consistent environment to be productive. Rote memorisation takes far longer for my friend and I that it takes all the normals when it comes to our counterintuitive culture. We both could be far more productive and useful to society with a more logically consistent environment. If I had used a phonetic shorthand in school, I would have a PhD instead of a Bachelors now, because note taking is too complicated with a brain that treats English note taking, with its counterintuitive spellings, as a second language I am still learning at the age of 58. I am looking into getting a computer with a better operating system I can download for free. The next MacroShaft fanboy who points out to me there are fine online learning resources for those products will be beaten to death with a large plastic penguin. The Winblows environment is logically consistent the way English is phonetic and consequently has held back progress far more than all the hopeless mediocretin normals who blow people off with “just grit your teeth and deal with it” realize.

    Like. Reply