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 | Quantum, functional, imperative |
|---|---|
| Designed by | Microsoft Research (quantum architectures and computation group; QuArC) |
| Developer | Microsoft |
| First appeared | December 11, 2017[1] |
| Typing discipline | Static, strong |
| Platform | Common Language Infrastructure |
| License | MIT License[2] |
| Filename extensions | .qs |
| Website | learn |
| Influenced by | |
| C#, F#, Python | |
Q# (pronounced Q sharp) is a domain-specific programming language used for expressing quantum algorithms.[3] It was initially released to the public by Microsoft as part of the Quantum Development Kit.[4]
Q# works in conjunction with classical languages such as C#, Python and F#, and is designed to allow the use of traditional programming concepts in quantum computing, including functions with variables and branches as well as a syntax-highlighted development environment with a quantum debugger.[1][5][6]
History
Historically, Microsoft Research had two teams interested in quantum computing: the QuArC team based in Redmond, Washington,[7] directed by Krysta Svore, that explored the construction of quantum circuitry, and Station Q initially located in Santa Barbara and directed by Michael Freedman, that explored topological quantum computing.[8][9]
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.[10] On December 11, 2017, Microsoft released Q# as a part of the Quantum Development Kit.[4]
At Build 2019, Microsoft announced that it would be open-sourcing the Quantum Development Kit, including its Q# compilers and simulators.[11]
To support Q#, Microsoft developed Quantum Intermediate Representation (QIR) in 2023 as a common interface between programming languages and target quantum processors. The company also announced a compiler extension that generates QIR from Q#.[12]
Bettina Heim used to lead the Q# language development effort.[13][14]
Usage
Q# is available as a separately downloaded extension for Visual Studio,[15] but it can also be run as an independent tool from the command line or Visual Studio Code. Q# was introduced on Windows and is available on MacOS and Linux.[16]
The Quantum Development Kit includes a quantum simulator capable of running Q# and simulated 30 logical qubits.[17][18]
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.[19]
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 quantum logic gates).[citation needed]
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.[20]
Documentation and resources
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, called 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/QuantumKatas with 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
namespacefor 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
IntDoubleStringandBoolare similar, although capitalised (and Int is 64-bit)[21] - Qubits are allocated and disposed inside a
usingblock. - Lambda functions are defined using the
=>operator. - Results are returned using the
returnkeyword.
Similarities with F#
- Variables are declared using either
letormutable[3] - First-order functions
- Modules, which are imported using the
openkeyword - The datatype is declared after the variable name
- The range operator
.. for … inloops- Every operation/function has a return value, rather than
void. Instead ofvoid, an empty Tuple()is returned. - Definition of record datatypes (using the
newtypekeyword, instead oftype).
Differences
- Functions are declared using the
functionkeyword - Operations on the quantum computer are declared using the
operationkeyword - Lack of multiline comments
- Asserts instead of throwing exceptions
- Documentation is written in Markdown instead of XML-based documentation tags
References
- ↑ 1.0 1.1 "Microsoft's Q# quantum programming language out now in preview" (in en-US). 12 Dec 2017. https://arstechnica.com/gadgets/2017/12/microsofts-q-quantum-programming-language-out-now-in-preview/.
- ↑ "Introduction to Q#". University of Washington. https://courses.cs.washington.edu/courses/cse490q/20au/hws/qsharp-intro.pdf.
- ↑ 3.0 3.1 QuantumWriter. "The Q# Programming Language" (in en-us). https://docs.microsoft.com/en-us/quantum/quantum-qr-intro?view=qsharp-preview.
- ↑ 4.0 4.1 "Announcing the Microsoft Quantum Development Kit" (in en-US). https://cloudblogs.microsoft.com/quantum/2017/12/11/announcing-microsoft-quantum-development-kit/.
- ↑ "Microsoft makes play for next wave of computing with quantum computing toolkit" (in en-US). 25 Sep 2017. https://arstechnica.com/gadgets/2017/09/microsoft-quantum-toolkit/.
- ↑ "Quantum Computers Barely Exist—Here's Why We're Writing Languages for Them Anyway" (in en-US). 22 Dec 2017. https://www.technologyreview.com/2017/12/22/3662/quantum-computers-barely-exist-heres-why-were-writing-languages-for-them-anyway/.
- ↑ "Solving the quantum many-body problem with artificial neural networks". 15 February 2017. https://cloudblogs.microsoft.com/quantum/2017/02/15/solving-the-quantum-many-body-problem-with-artificial-neural-networks/.
- ↑ Scott Aaronson's blog, 2013, 'Microsoft: From QDOS to QMA in less than 35 years', https://scottaaronson.blog/?p=1471
- ↑ "What are the Q# programming language & QDK? - Azure Quantum" (in en-us). 12 January 2024. https://learn.microsoft.com/en-us/azure/quantum/overview-what-is-qsharp-and-qdk.
- ↑ "Microsoft announces quantum computing programming language" (in en-US). https://cloudblogs.microsoft.com/quantum/2017/09/26/microsoft-announces-quantum-computing-programming-language/.
- ↑ "Microsoft is open-sourcing its Quantum Development Kit". https://venturebeat.com/2019/05/06/microsoft-open-sourcing-quantum-development-kit/.
- ↑ Krill, Paul (29 Sep 2020). "Microsoft taps LLVM for quantum computing" (in en-US). https://www.infoworld.com/article/2260508/microsoft-taps-llvm-for-quantum-computing.html.
- ↑ "The Women of QuArC". 30 March 2019. https://devblogs.microsoft.com/qsharp/the-women-of-quarc/.
- ↑ "Intro to Q# - Intro to Quantum Software Development". https://stem.mitre.org/quantum/software-tools/intro-qsharp.html.
- ↑ QuantumWriter. "Setting up the Q# development environment" (in en-us). https://docs.microsoft.com/en-us/quantum/quantum-installconfig?view=qsharp-preview.
- ↑ Coppock, Mark (26 Feb 2018). "Microsoft's quantum computing language is now available for MacOS" (in en). https://www.digitaltrends.com/computing/microsoft-quantum-computing-q-available-macos-linux/.
- ↑ Akdogan, Erman (23 October 2022). "Quantum computing is coming for finance & crypto" (in en). https://medium.datadriveninvestor.com/quantum-computing-is-coming-for-finance-crypto-b56c0255cb09.
- ↑ Melanson, Mike (16 Dec 2017). "This Week in Programming: Get Quantum with Q Sharp" (in en). https://thenewstack.io/week-programming-get-quantum-q-sharp/.
- ↑ "This Week in Programming: Get Quantum with Q Sharp". 16 December 2017. https://thenewstack.io/week-programming-get-quantum-q-sharp/.
- ↑ "Microsoft previews quantum computing development kit". https://www2.cio.com.au/article/631142/microsoft-previews-quantum-computing-development-kit/.
- ↑ "Types in Q# - Microsoft Quantum". 27 July 2022. https://docs.microsoft.com/en-us/quantum/user-guide/language/types.
External links
- Official website
- on GitHub (now deprecated)
- on GitHub (Modern QDK repository)
