For developers who want to start working with quantum computing concepts today, Microsoft has released a quantum computing Development Kit. It includes the following items:
- Native quantum-focused programming language and compiler: Q#
- A Q# Standard library that contains the Q# quantum algorithms and classic language controls
- A quantum machine simulator that can be run locally
- Visual Studio Extensions for Q#
- Sample code and libraries
You can access this development kit at https://www.microsoft.com/en-us/quantum/development-kit. You also can find it in the Visual Studio Marketplace if you search for the Microsoft Quantum Development Kit.
The developer kit will require you to use a 64-bit version of Windows as well as a newer Intel processor to use the Simulator. Additionally, you'll need to be using Visual Studio 2017 or later. After you've downloaded the file from the URL or accessed the extension from the marketplace, you'll be able to install the necessary extensions into Visual Studio 2017.
Once installed, you should verify that your installation works. To do the verification, copy the sample solution Microsoft has created on GitHub and run the Teleportation Sample. You can clone the example by first going to Team --> Manage Connections in Visual Studio 2017 (See Figure 1).
Figure 1: First step toward cloning a GitHub example
In the Connect dialog, select Clone within the Local Git Repository section. In the displayed dialog, enter https://github.com/Microsoft/Quantum.git as the source and press the Clone button, as shown in Figure 2.
Figure 2: The Connect dialog
This will clone the files you need. Once completed, you should have a copy of the QSharpLibraries on your local machine that you can load into the Solution Explorer. Select the TeleportationExample, as shown in Figure 3. Right-click TeleportationExample and choose to set it as the startup project.
Figure 3: The QSharpLibraries in Solution Explorer
With the startup project set, run the project (by pressing F5). If all goes well, you should get output similar to what is shown in Figure 4, which shows output from rounds of Teleportation.
Figure 4: Running the Quantum Teleportation tries
Once you've seen this output, you have confirmed that you have successfully installed Q# and the Quantum libraries. You are now set to do Q# programming in Visual Studio!
With the Quantum development environment in place, you now should have new project types available under Visual C#. This will include a Q# Application template as well as templates for building a Q# library and a Q# test project, as shown in Figure 5.
Figure 5: The Q# Project types in Visual Studio
When building Q# programs, you'll use a driver program written in C# that constructs the quantum simulator that will execute your Q# code. The driver program also prepares arguments, runs the quantum algorithms, and processes the results of the operations.
You can create a new quantum program from scratch by starting a new project in Visual Studio and then selecting Q# Application. This will give you a default template that will include the C# driver program and more (see Figure 6).
Figure 6: A new Q# Program in Visual Studio
The value of using quantum computing is not to display simple text, so a "Hello World" application in a quantum computing environment is going to be much more complex than displaying text as would be done in a standard "Hello World" application for C# or C++. A "hello world" quantum application is more likely to manipulate numbers and do operations.
Microsoft has provided a relatively simple "hello world" example that can be found at https://docs.microsoft.com/en-us/quantum/quantum-writeaquantumprogram?view=qsharp-preview. Rather than repeat a similar example here, you should go to the example on that page and work through it. As you work through the example, avoid making minor mistakes. For example, you should note the case of the commands being entered. When working with the X gate, the letter ex is a capital, not a lowercase letter:
X(qubits); let res = M (qubits);
Once you've worked through the "simple" example, you also can dig into the QSharpLibraries examples mentioned earlier in this article. One of the more interesting examples in the library is IntegerFactorization, which shows factorizing an integer. As you'll see by looking at the source code including the Shor.qs file, quantum development is quite a bit more complex than what you'd see with C# or C++!
By using Q#, you have a chance to begin familiarizing yourself with the quantum computing concepts that will be coming to future development projects. The value of a quantum computing language isn't going to be achieved on today's computers. The value of this type of programming will happen when there is access to quantum processors. It is the speed gains that will be achieved on such quantum processors that will justify the added coding required to build the apps.