Q Sharp
This article may rely excessively on sources too closely associated with the subject, potentially preventing the article from being verifiable and neutral. (September 2018) (Learn how and when to remove this template message) |
Paradigm | multi-paradigm: quantum, functional, imperative |
---|---|
Designed by | Microsoft Research (quantum architectures and computation group; QuArC) |
Developer | Microsoft |
First appeared | December 11th, 2017 |
Typing discipline | static, strong |
Platform | Common Language Infrastructure |
Filename extensions | .qs |
Website | Microsoft Quantum (GitHub) |
Influenced by | |
C#, F# |
Q# (pronounced as Q sharp) is a domain-specific programming language used for expressing quantum algorithms.[1] It was initially released to the public by Microsoft as part of the Quantum Development Kit.[2]
Contents
History[edit]
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.[3] On December 11, 2017, Microsoft released Q# as a part of the Quantum Development Kit.[2]
Usage[edit]
Q# is available as a separately downloaded extension for Visual Studio,[4] but it can also be run as an independent tool from the Command line and/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[edit]
A primary feature of Q# is the ability to create and use qubits 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.
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[edit]
Currently, the resources available for Q# are scarce, but the official documentation is published: Microsoft Developer Network: Q#. Microsoft Quantum Github repository is 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: http://codeforces.com/msqs2018, 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: https://github.com/Microsoft/QuantumKatas with links to resources, and answers to the problems.
Syntax[edit]
Q# is syntactically related to both C# and F# yet also has some significant differences.
Similarities with C#[edit]
- Uses
namespace
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
Int
Double
String
andBool
are similar, although capitalised (and Int is 64-bit)[5] - Qubits are allocated and disposed inside a
using
block. - Lambda functions using the
=>
operator. - Results are returned using the
return
keyword.
Similarities with F#[edit]
- Variables are declared using either
let
ormutable
[1] - First-order functions
- Modules, which are imported using the
open
keyword - The datatype is declared after the variable name
- The range operator
..
for … in
loops- Every operation/function has a return value, rather than
void
. Instead ofvoid
, an empty Tuple()
is returned. - Definition of record datatypes (using the
newtype
keyword, instead oftype
).
Differences[edit]
- Functions are declared using the
function
keyword - Operations on the quantum computer are declared using the
operation
keyword - Lack of multiline comments
- Asserts instead of throwing exceptions
- Documentation is written in Markdown instead of XML-based documentation tags
References[edit]
- ^ a b QuantumWriter. "The Q# Programming Language". docs.microsoft.com. Retrieved 2017-12-11.
- ^ a b "Announcing the Microsoft Quantum Development Kit". Retrieved 2017-12-11.
- ^ "Microsoft announces quantum computing programming language". Retrieved 2017-12-14.
- ^ QuantumWriter. "Setting up the Q# development environment". docs.microsoft.com. Retrieved 2017-12-14.
- ^ https://docs.microsoft.com/en-gb/quantum/language/type-model?view=qsharp-preview