Explore quantum hero banner

Explore quantum

The Q# language

Q# is a programming language designed by Microsoft specifically for quantum computing. Q# is part of Microsoft’s Quantum Development Kit (QDK) and is designed specifically to support the development of future large-scale quantum applications while still supporting ongoing research on current quantum hardware. Q# is a stand-alone language offering a high level of abstraction. There is no notion of a quantum state or a circuit. Instead, Q# implements programs in terms of statements and expressions, much like classical programming languages. Distinct quantum capabilities such as support for functors and control-flow constructs facilitate expressing, for example, phase estimation and quantum chemistry algorithms. 

 

Q# graphic

 

Q# can be used to write quantum algorithms, simulate them on classical computers, and then run them on actual quantum computers. Q# also provides a library of built-in quantum operations, such as quantum gates and measurements, that are used to manipulate qubits and perform quantum computations. Some key Q# features include:

  • Qubit management: In Q#, qubits are resources that are requested from the runtime when needed and returned when no longer in use. This is similar to the way that classical languages deal with heap memory.

  • Agnostic qubit type: The Q# language doesn’t specify whether program qubits are logical or physical. This can be decided by the runtime when the algorithm is executed. Similarly, the mapping from a qubit variable in a program to an actual logical or physical qubit is decided by the runtime, and that mapping may be deferred until after the topology and other details of the target device is known.

  • Compiler-generated controlled and adjoint specializations: Q# includes keywords and compiler support for automatically generating the adjoint and/or controlled variation of an operation, which maps to common patterns used in reversible quantum computation. This both makes writing algorithms easier and allows for compiler driven optimization of quantum code.

  • First-class operations: Operations and functions in Q# are first-class entities; they can be passed to other operations, assigned to variables, and used like any other value. This makes it easy to express protocols such as amplitude amplification, phase estimation, and others.

  • Classical control flow: Q# supports general classical control flow during the execution of an algorithm. For instance, the loop required for probabilistic algorithms such as Grover's search can easily be expressed in Q#, rather than having to return to the classical driver to test whether the result satisfies the oracle and rerunning if not.

  • Mixed classical and quantum computation: Q# supports rich classical computation as well as quantum operations. This allows clean expression of adaptive algorithms such as the random walk phase estimation operation. Such algorithms are difficult to express directly in the circuit model of a fixed sequence of quantum gates.
     

For more information on Q#, visit the official Q# repository on GitHub

 

 

Suggested Topics

The qubit

Learn how qubits use the quantum-mechanical phenomena of superposition and entanglement to power quantum computations

Quantum math

Learn about the mathematics behind quantum computing, and how it is used to describe the behavior of qubits and quantum gates

Dirac notation

Learn about Dirac notation, also known as bra-ket notation, and how it is used to represent quantum states and operations

Entanglement

Learn how quantum entanglement is used to enable parallelism in quantum computers, unlocking simultaneous calculation