Skip to content

↑ Quantum Computing

Scratch for Quantum Computing

As quantum circuits grow beyond small toy examples, preparing them for execution on real hardware becomes increasingly complex. Design automation methods take over this work: compilation adapts circuits to a specific device, resource estimation evaluates their cost, and verification checks their correctness. For newcomers, however, these concepts come with a steep learning curve, especially when quantum circuits are introduced through textual programming languages.

Scratch for Quantum Computing lowers this barrier. It adds a Quantum extension to Scratch, a widely used block-based programming environment, so that quantum circuits can be built from blocks, combined with classical program logic, and analyzed with design automation techniques directly in the browser.

The Scratch editor with the Quantum extension, showing a circuit that prepares a Bell state
A complete quantum program in Scratch: it entangles two qubits and lets the cat announce the measurement result.

Why Block-Based Programming?

Quantum computing is usually introduced through linear algebra or through programming frameworks such as Qiskit. Both pose a high entry barrier for newcomers. With blocks, syntax errors cannot occur, and the focus stays on the concepts: qubits, gates, superposition, entanglement, and measurement. Since the extension is part of regular Scratch, quantum circuits can also be combined with loops, variables, and sprites, which links quantum programs to familiar classical control flow.

Features

Build circuits

Create qubit registers and apply the standard gates, rotations, and controlled operations, all by dragging and dropping blocks.

Simulate circuits

Simulate circuits directly in the browser and use measurement outcomes in the rest of a Scratch program.

Apply design automation

Check whether two circuits are equivalent, count their qubits and gates, and see how decomposing gates changes those counts.

Export to MLIR

Translate circuits to MLIR and process them further with quantum compiler tools such as the MQT Compiler Collection.

Getting Started

  1. Open the editor and add the Quantum extension with the button in the bottom-left corner.
  2. Rebuild the program below by dragging blocks from the palette into the workspace.
  3. Click the green flag. The cat says 0 or 1; since measurement outcomes are random, the result varies between runs.
Scratch blocks: when green flag clicked, Run Quantum Circuits. Quantum Circuit: create quantum register q with 2 qubits, apply H gate to qubit 0 of register q, controlled on qubit 0 of register q containing apply X gate to qubit 1 of register q, say measure qubit 0 of register q for 2 seconds.
Preparing a Bell state: an H gate followed by a controlled X gate entangles the two qubits.

Measuring qubit 1 as well shows that the two qubits are entangled: both results always agree.

Use in Teaching

Scratch for Quantum Computing runs entirely in the browser and requires no installation. Exercises are shared as ordinary Scratch project files that users open, complete, and hand back. The tool has been used in courses on quantum computing and quantum design automation at the Technical University of Munich, where a set of guided exercises takes students from their first circuit to verification, resource estimation, and compilation in about 45 minutes. An evaluation with computer science students indicates that this approach lowers the entry barrier to quantum design automation concepts.

Would you like to use it in your own course? The exercises are freely available in the documentation, and we are happy to help; feel free to get in touch.

Further Information

The documentation walks you through a quickstart, describes every block in detail, and explains the quantum design automation tasks the extension covers.

If you use Scratch for Quantum Computing in your teaching or research, please cite:

Scratch is a project of the Scratch Foundation, in collaboration with the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at scratch.mit.edu.

Google Custom Search

We use Google to search the CDA website. Enabling search sends your search terms and technical information, including your IP address, to Google. Google may use cookies.

Information on the use of Google Search