History
Historically,Usage
Q# is available as a separately downloaded extension for Visual Studio, 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 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 onDocumentation and resources
Currently, the resources available for Q# are scarce, but the official documentation is publishedSyntax
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 instead of XML-based documentation tagsExample
The following source code is a multiplexer from the official Microsoft Q# library repository.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