front matter

preface

I started working on my PhD thesis in 1995 at Delft University of Technology in the Netherlands. My work was mainly focused on the acoustic wave equation, and I needed to combine theoretical models with experimental data, which, of course, required data processing and visualization. Around that same time, a new programming language named Java was unveiled. Several things made Java attractive for scientific work, including its portability to different platforms, which made it easy to create applications with a user interface and execute them on the various platforms I was working on.

However, it occurred to me that there was a large gap between the scientific world and the IT world. While researchers in science are typically trying to find answers to difficult questions, ITers are working on implementing the results of science and dealing with scalability, failover, code reuse, and functional or object-oriented development. Often, ideas and models created by scientists need to be implemented by ITers. Scientists should not worry about unit tests, while ITers should not have knowledge of the Standard Model of physics; but somehow, the handover between the two areas should be smooth.

I was privileged to be a frequent co-speaker with James Weaver, a long-time Java expert who became interested in quantum computing. Because of my background in science, he asked me to co-present on quantum computing.

If you need to do a presentation about something, it often helps if you know at least something about the subject. Even though I had worked on the acoustic wave equation, quantum computing was something different. Hence, I was forced to learn about quantum computing. The best way to learn something is to work with it; so, to understand quantum computing, I created a simulator of a quantum computer in Java, named Strange. Step by step, I added functionality to Strange, and by implementing it, I got a better idea of what quantum computing means for developers.

My general observation that scientists face different issues than developers turned out to be true for quantum computing. I believe that one of the significant challenges in quantum computing is finding ways for existing developers to use quantum computing without requiring them to understand the physics behind it. But it also works the other way: great algorithms that may lead to improvements in various areas often require a good understanding of modern IT development before they can be successful.

It is my belief that quantum computing can lead to major breakthroughs in several domains, including healthcare and security. With this book, I hope to explain to developers how you can benefit from quantum computing without having to become experts in quantum physics.

acknowledgments

Thank you to my family for their constant support and patience, which has provided me the opportunity to write this book. 

I’d like to thank my colleagues at Gluon for their support, especially in many technical ways. Likewise, the continuous support and encouragement from the Java and JavaFX communities has motivated me to make this a book that is useful to developers.

Many thanks to the entire Manning team who helped me realize this book. In particular, I’d like to thank Mike Stephens, Andrew Waldron, Dustin Archibald, Alain Couniot, Jan Goyvaerts, and Candace Gillhoolley for your knowledge and guidance along the way. Thanks also to Tiffany Taylor, Keir Samson, Melody Dolab, Meredith Mix, and Andy Marinkovich for guiding the book through production and for your commitment to making the book the best it can be.

For obvious reasons, the past couple of years have been intense. We are certainly living in a strange time in which scientific work has become more relevant than ever. Studying quantum computing forced me to dive deep into the mysteries of nature. I am very grateful to all the scientists who are working to understand and explain the fundamental concepts of nature, so that hardware and software developers can work on concrete benefits based on those new insights.

To all the reviewers: Aleksandr Erofeev, Alessandro Campeis, Antonio Magnaghi, Ariel Gamino, Carlos Aya-Moreno, David Lindelof, Evan Wallace, Flavio Diez, Girish Ahankari, Greg Wright, Gustavo Filipe Ramos Gomes, Harro Lissenberg, Jean-François Morin, Jens Christian Bredahl Madsen, Kelum Prabath Senanayake, Ken W. Alger, Marcel van den Brink, Michael Wall, Nathan B Crocker, Patrick Regan, Potito Coluccelli, Rich Ward, Roberto Casadei, Satej Kumar Sahu, Vasile Boris, Vlad Navitski, William E. Wheeler, and William W. Fly, your suggestions helped make this a better book. 

about this book

Most available resources about quantum computing are about either the mind-boggling physics that is used to enable quantum computing or the high-level consequences that can be expected when quantum computing becomes mainstream. In this book, we address the questions many developers ask: How will quantum computing affect my daily development, and how can I benefit from it? To answer this, we look at quantum computing from the perspective of a developer: we assume that hardware is or will be available (via native hardware or simulators), and we write code that is agnostic to marketing hype.

Who should read this book?

This book is written for developers who are interested in knowing whether and how they can benefit from quantum computing, now or in the future, or in general, what impact will quantum computing have on their work. The reader is not expected to know anything about quantum physics. The book explains the areas where quantum computing might lead to improvements and how developers can use it similarly to how they use modern hardware (such as GPUs) without knowing the internal details.

How this book is organized: a roadmap

This book contains three parts. Part 1 gives some basic information about quantum computing. Part 2 introduces the fundamental concepts that make quantum computing different from classical computing. Part 3 covers algorithms and code that are directly applicable to existing developers, and that use quantum advantages.

Part 1 introduces quantum computing:

  • Chapter 1 discusses the importance of quantum computing without using buzzwords or participating in the hype. Down-to-earth developers often say, “Show me the code,” and that is what this book does.

  • In chapter 2, we build our first Java application (the typical HelloWorld application) using the Java-based quantum simulator Strange. The Strange quantum simulator shields developers from the low-level details of quantum computing yet provides APIs that internally benefit from quantum concepts.

  • Chapter 3 introduces the qubit as the fundamental building block in quantum computing, similar to the regular bit in classical computing.

Part 2 introduces the relevant concepts of quantum computing:

  • Chapter 4 discusses superposition, one of the core principles of quantum physics. This chapter contains code that allows you to use quantum superposition in your Java applications.

  • Chapter 5 explains how different qubits can stay connected via quantum entanglement and what that means for applications.

  • Chapter 6 introduces quantum networking as a specific application of quantum computing.

Part 3 deals with code examples and gradually introduces more complex algorithms that are useful to developers. Although the focus is on explaining the use of the algorithms, some explanations of the internals of the algorithms are given, as well, to help you work on similar algorithms:

  • Chapter 7 explains the HelloWorld application shown in chapter 2. This simple application has no direct benefits (similar to HelloWorld applications in general) but shows how quantum applications can be created.

  • Chapter 8 builds on chapters 6 and 7 and shows how a Java application can be created that uses quantum networking and provides a secure communication channel between two parties.

  • Chapter 9 explains the Deutsch-Jozsa algorithm. This algorithm is easy to implement in Java with Strange, and it familiarizes you with some of the typical patterns in quantum computing.

  • Chapter 10 discusses one of the most famous quantum algorithms: Grover’s search algorithm. This algorithm has real practical implications for developers.

  • Chapter 11 is about Shor’s algorithm, which is probably the most popular existing quantum algorithm. This algorithm requires a combination of classical and quantum computing, and is therefore a great topic to conclude the book.

About the code

Throughout this book, many examples and demo applications are shown and referenced. Those applications use the Strange quantum simulator. Because Strange is an evolving project, the applications in the book are expected to evolve as well.

The examples in the book depend on the latest public released version of Strange that was available at the time of this writing. This version is tagged and uploaded to well-known repositories (such as Maven Central). Because of this, the code in this book is expected to work in the future, even if the Strange APIs change. A snapshot of the code examples in this book at the time of publication is available at https://www.manning.com/books/quantum-computing-in-action. The evolving code repository for the examples is available at https://github.com/johanvos/quantumjava.

This book contains many examples of source code, both in numbered listings and in line with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. In many cases, the original source code has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, even this was not enough, and listings include line-continuation markers. Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts.

liveBook discussion forum

Purchase of Quantum Computing in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to https://livebook.manning.com/#!/book/quantum-computing-in-action/discussion. You can also learn more about Manning’s forums and the rules of conduct at https://livebook.manning.com/#!/discussion.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the author some challenging questions lest his interest stray! The forum and the archives of previous discussions will be accessible from the publisher’s website for as long as the book is in print.

about the author

    

Johan Vos is a Java Champion, active OpenJDK contributor, project lead for OpenJDK Mobile, and co-spec lead for OpenJFX. Johan holds a PhD in applied physics from Delft University of Technology. He is a co-author of ProJava FX2/8/9 and of The Definitive Guide to Modern Java Clients with JavaFX.

Johan has been active in the development of open source software. He was part of the Blackdown team that ported Java to Linux systems. Apart from his lead role in OpenJFX, he also contributes to a number of Java and JavaFX related libraries, including Strange and StrangeFX, which are discussed in this book.

about the cover illustration

The figure on the cover of Quantum Computing in Action is captioned “Femme Dalécarlie,” or Dalecarlian woman. The illustration is taken from a collection of dress costumes from various countries by Jacques Grasset de Saint-Sauveur (1757–1810), titled Costumes de Différents Pays, published in France in 1797. Each illustration is finely drawn and colored by hand. The rich variety of Grasset de Saint-Sauveur’s collection reminds us vividly of how culturally apart the world’s towns and regions were just 200 years ago. Isolated from each other, people spoke different dialects and languages. In the streets or in the countryside, it was easy to identify where they lived and what their trade or station in life was just by their dress.

The way we dress has changed since then and the diversity by region, so rich at the time, has faded away. It is now hard to tell apart the inhabitants of different continents, let alone different towns, regions, or countries. Perhaps we have traded cultural diversity for a more varied personal life—certainly for a more varied and fast-paced technological life.

At a time when it is hard to tell one computer book from another, Manning celebrates the inventiveness and initiative of the computer business with book covers based on the rich diversity of regional life of two centuries ago, brought back to life by Grasset de Saint-Sauveur’s pictures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.231.155