Q# (pronounced as ''Q sharp'') is a
domain-specific programming language
A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging f ...
used for expressing
quantum algorithms
In quantum computing, a quantum algorithm is an algorithm which runs on a realistic model of quantum computation, the most commonly used model being the quantum circuit model of computation. A classical (or non-quantum) algorithm is a finite sequ ...
.
It was initially released to the public by
Microsoft
Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washi ...
as part of the Quantum Development Kit.
History
Historically,
Microsoft Research
Microsoft Research (MSR) is the research subsidiary of Microsoft. It was created in 1991 by Richard Rashid, Bill Gates and Nathan Myhrvold with the intent to advance state-of-the-art computing and solve difficult world problems through technolog ...
had two teams interested in quantum computing, the QuArC team based in Redmond, directed by
Krysta Svore, that explored the construction of quantum circuitry, and Station Q initially located in Santa Barbara and directed by
Michael Freedman
Michael Hartley Freedman (born April 21, 1951) is an American mathematician, at Microsoft Station Q, a research group at the University of California, Santa Barbara. In 1986, he was awarded a Fields Medal for his work on the 4-dimensional gene ...
, that explored
topological quantum computing
A topological quantum computer is a theoretical quantum computer proposed by Russian-American physicist Alexei Kitaev in 1997. It employs quasiparticles in two-dimensional systems, called anyons, whose world lines pass around one another to form ...
.
During a
Microsoft Ignite Keynote on September 26, 2017, Microsoft announced that they were going to release a new programming language geared specifically towards quantum computers. On December 11, 2017, Microsoft released Q# as a part of the Quantum Development Kit.
At
Build 2019, Microsoft announced that it is open-sourcing the Quantum Development Kit, including its Q# compilers and simulators.
Bettina Heim
Bettina Heim (born 2 July 1989) was a Swiss competitive figure skater who now leads leads the language design team for Microsoft's Q# programming language.
Figure skating career
She was the 2011 Swiss national champion, and competed at two Wor ...
currently leads the Q# language development effort.
Usage
Q# is available as a separately downloaded extension for
Visual Studio
Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platfor ...
, but it can also be run as an independent tool from the Command line or Visual Studio Code. The Quantum Development Kit ships with a
quantum simulator which is capable of running Q#.
In order to invoke the quantum simulator, another
.NET programming language, usually
C#, is used, which provides the (classical) input data for the simulator and reads the (classical) output data from the simulator.
Features
A primary feature of Q# is the ability to create and use
qubits
In quantum computing, a qubit () or quantum bit is a basic unit of quantum information—the quantum version of the classic binary bit physically realized with a two-state device. A qubit is a two-state (or two-level) quantum-mechanical system, ...
for algorithms. As a consequence, some of the most prominent features of Q# are the ability to
entangle and introduce
superpositioning to qubits via
Controlled NOT gates and
Hadamard gates, respectively, as well as
Toffoli Gates,
Pauli X, Y, Z Gate, and many more which are used for a variety of operations; see the list at the article on
quantum logic gates
In physics, a quantum (plural quanta) is the minimum amount of any physical entity (physical property) involved in an interaction. The fundamental notion that a physical property can be "quantized" is referred to as "the hypothesis of quantizati ...
.
The hardware stack that will eventually come together with Q# is expected to implement Qubits as
topological qubits. The quantum simulator that is shipped with the Quantum Development Kit today is capable of processing up to 32 qubits on a user machine and up to 40 qubits on
Azure.
Documentation and resources
Currently, the resources available for Q# are scarce, but the official documentation is published
Microsoft Developer Network: Q#Microsoft Quantum Github repositoryis also a large collection of sample programs implementing a variety of Quantum algorithms and their tests.
Microsoft has also hosted a Quantum Coding contest on
Codeforces here
Microsoft Q# Coding Contest - Codeforces and also provided related material to help answer the questions in the blog posts, plus the detailed solutions in the tutorials.
Microsoft hosts a set of learning exercises to help learn Q# on GitHub
microsoft/QuantumKataswith links to resources, and answers to the problems.
Syntax
Q# is syntactically related to both
C# and
F# yet also has some significant differences.
Similarities with C#
* Uses for code isolation
* All statements end with a
* Curly braces are used for statements of scope
* Single line comments are done using
* Variable data types such as and are similar, although capitalised (and Int is 64-bit)
* Qubits are allocated and disposed inside a block.
* Lambda functions using the
=>
operator.
* Results are returned using the keyword.
Similarities with F#
* Variables are declared using either or
* First-order functions
* Modules, which are imported using the keyword
* The datatype is declared after the variable name
* The range operator
* loops
* Every operation/function has a return value, rather than . Instead of , an empty Tuple is returned.
* Definition of record datatypes (using the keyword, instead of ).
Differences
* Functions are declared using the keyword
* Operations on the quantum computer are declared using the keyword
* Lack of multiline comments
* Asserts instead of throwing exceptions
* Documentation is written in
Markdown
Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber and Aaron Swartz created Markdown in 2004 as a markup language that is appealing to human readers in its source code form. Markdown i ...
instead of
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
-based documentation tags
Example
The following source code is a
multiplexer
In electronics, a multiplexer (or mux; spelled sometimes as multiplexor), also known as a data selector, is a device that selects between several analog or digital input signals and forwards the selected input to a single output line. The sel ...
from the official Microsoft Q# library repository.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Canon
References
External links
*
*
{{Microsoft development tools
Free and open-source software
Microsoft free software
Microsoft programming languages
Quantum programming
Programming languages created in 2017
Software using the MIT license