Preface

The gap this book fills

There are good books about quantum computing. Nielsen and Chuang is a monument. There are excellent lecture notes, a first-rate free Qiskit course from IBM, thorough Q# documentation from Microsoft, and a growing pile of survey papers. What there isn't — what there has never been — is a book that treats quantum programming as a software engineering discipline.

The distinction matters more than it sounds. A theory book asks: what can a quantum computer compute, and how fast? It answers with mathematics, and the mathematics is beautiful. A programming book has to ask a different and much less glamorous set of questions:

  • My circuit works on the simulator and returns garbage on hardware. Is that noise or a bug, and how would I tell?
  • How do I write a unit test for a function that legitimately returns a different answer every time?
  • I can't print the intermediate state, because printing it destroys it. So how do I debug?
  • My three-gate circuit became forty gates after transpilation. What happened, and can I stop it?
  • There are five frameworks. Which one, and what happens when I need to move between them?
  • What is my circuit actually costing me in queue time and dollars, and is this run worth it?

Those questions have real answers. The answers are scattered across framework documentation, GitHub issues, conference tutorials, and the accumulated folklore of people who have spent a few years doing this. Collecting them, testing them, and writing them down in one place is what this book is for.

What you will actually do

You will run a program on a real quantum processor in Chapter 2, probably within an hour of starting. Not a simulation — a physical device, cooled to a few millikelvin, somewhere in a data center, that you reached over the internet for free.

The result will be slightly wrong. That is the first real lesson of the book, and it is the reason Chapter 2 comes before all the theory: a Bell state is supposed to give you fifty percent 00 and fifty percent 11 and nothing else, and what you will get is roughly that, plus a stubborn few percent of 01 and 10 that have no business existing. That residue is not a defect in your code. It is the physics of imperfect qubits, and learning to work with it — to measure it, model it, mitigate it, and route around it — is most of what separates a quantum software engineer from someone who has read about quantum computing.

By the last chapter you will have built a Variational Quantum Eigensolver from scratch: a program that computes the ground-state energy of a hydrogen molecule on real quantum hardware and lands within chemical accuracy of the exact answer. That is one of the very few things current quantum computers do that is genuinely interesting, and you will understand every line of it.

Five frameworks, no religion

This book teaches Qiskit, Cirq, PennyLane, Q#, Amazon Braket, and OpenQASM.

That is not thoroughness for its own sake. The quantum field has not converged on a single language the way the classical field converged on, say, C for systems work. Each framework encodes a different bet about what quantum programming is: Qiskit bets on circuits and IBM hardware, Cirq on explicit hardware-aware scheduling, PennyLane on differentiability, Q# on a real type system for quantum data, Braket on hardware diversity. Those bets produce genuinely different tools, and a professional needs to be able to read all of them and choose among them.

The book's center of gravity is Qiskit, because it has the largest community, the best free hardware access, and the most complete tooling. But every major concept appears at least twice, in at least two frameworks, and Chapter 18 puts the same algorithm side by side in five.

What this book will not do

It will not oversell. Current quantum computers cannot break RSA, cannot train useful machine learning models better than a laptop, and cannot solve your logistics problem faster than a good classical solver. Chapters 33, 34, and 37 say so plainly, with the numbers. A book that pretends otherwise would waste your time and damage your credibility when you repeated its claims. Where the honest answer is "not yet, and here is what would have to change," that is the answer you will get — in a 🔬 Honest Assessment callout, so you can find them all.

It will not teach you quantum mechanics as physics. You will learn exactly as much quantum theory as the code requires, at the moment the code requires it, in ⚛️ The Physics Underneath callouts. If you want the full physical picture, read a physics book alongside this one. You do not need it to start.

It will not pretend the APIs are stable. They are not. Qiskit 1.0 deleted execute(), the function that appeared in essentially every tutorial written before 2024. Qiskit 2.0 removed the entire Pulse module. Half the quantum code on the internet does not run. This book writes against the current API, states the version each example was verified on, and marks every significant change with a 🗝️ Version Note so that you can still read the older material you will inevitably find.

Who this is for

Software engineers who want to add quantum to their skillset. CS students taking the lab course that accompanies a quantum theory course. Researchers who know the theory and need the implementation. Data scientists curious about quantum machine learning. Security professionals evaluating post-quantum migration who want to understand the threat concretely rather than rhetorically.

You need Python — comfortable with functions, classes, pip, and NumPy. You need vectors and matrices at the level of one linear algebra course, and Appendix D will refresh that in twenty pages if it has been a while. You need no quantum background at all.

A word about the field's timing

Quantum computing is roughly where classical computing was in the mid-1950s: the machines exist, they are large and unreliable, the programming models are unsettled, and almost nothing useful runs on them yet. It is also true that the people who learned to program those early machines defined the discipline for the next fifty years.

Whether quantum computers become transformative in five years or twenty is not a question this book can settle, and anyone who tells you they know is selling something. What is certain is that when the hardware becomes capable, the shortage will not be of physicists. It will be of people who can write correct, efficient, testable software for these machines.

That skill is learnable now, for free, on real hardware. This book is a complete path to it.

Start with Chapter 1 if you want the map. Start with Chapter 2 if you want to run something. Both are correct.