Difference between Q#, Silq, Quil and OpenQASM in quantum programming
Q# and Silq are high-level quantum programming languages; Quil and OpenQASM 3 are low-level instruction formats that list gates on numbered qubits. Q# (Microsoft) gives you operations, types and loops. Silq (ETH Zürich) adds a type system that refuses to copy a qubit or drop one it cannot uncompute automatically. Quil (Rigetti) reads like assembly. OpenQASM 3 (started at IBM) is the circuit format that tools and hardware exchange.
The same program shows the difference best. Below, each language builds a Bell pair, two entangled qubits, and each program ran 1,000 times on a simulator on 2026-12-02: 00 between 481 and 502 times, 11 between 498 and 519, 01 and 10 zero times, in all four.
What is the difference between Q#, Silq, Quil and OpenQASM?
| Language | What it is |
|---|---|
| Q# | high-level language with operations, types and control flow; Microsoft Quantum Development Kit, 2017 |
| Silq | high-level language with linear types and automatic uncomputation; ETH Zürich, 2020 |
| Quil | instruction language, assembly-like; Rigetti, 2016 |
| OpenQASM 3 | circuit language and interchange format; started at IBM, open specification, 2021 |
How each one names a qubit:
| Language | Qubit |
|---|---|
| Q# | a value bound to a name: use q = Qubit(); |
| Silq | a typed variable: a := 0:𝔹 |
| Quil | an integer index: 0, 1 |
| OpenQASM 3 | a declared register: qubit[2] q;, then q[0] |
How each one writes the controlled-NOT, “flip B if A is 1”:
| Language | Controlled-NOT |
|---|---|
| Q# | CNOT(q1, q2); |
| Silq | if a { b := X(b); } |
| Quil | CNOT 0 1 |
| OpenQASM 3 | cx q[0], q[1]; |
How each one measures:
| Language | Measurement |
|---|---|
| Q# | M(q) returns a Result: Zero or One |
| Silq | measure(x) returns a classical !𝔹 |
| Quil | MEASURE 0 ro[0] writes into declared memory |
| OpenQASM 3 | c = measure q; into a declared bit register |
What each one stops you doing (checked on this program, 2026-12-02):
| Language | Mistake caught |
|---|---|
| Q# | releasing a qubit that is not back in |0⟩: runtime error ReleasedQubitNotZero in the simulator |
| Silq | copying a qubit (return (a, a): “consumed”) or dropping one it cannot uncompute (“not consumed”): compile errors |
| Quil | no types on qubits: any integer is a qubit; readings go to declared memory |
| OpenQASM 3 | qubits and bits must be declared with a type before use |
Where each one runs:
| Language | Runs on |
|---|---|
| Q# | QDK simulators; hardware through Azure Quantum |
| Silq | its own simulator; no hardware back end |
| Quil | Rigetti’s QVM simulator; Rigetti processors through the quilc compiler |
| OpenQASM 3 | Qiskit and IBM Quantum; also accepted by Amazon Braket |
What does a Bell pair do, step by step?
- Step 1. Both qubits start as 0. Reading them gives 00 every time.
- Step 2. H turns A into an equal mix of 0 and 1 (amplitude 0.71 each). B is untouched, so the pair reads 00 or 10.
- Step 3. CNOT flips B wherever A is 1. The 10 part becomes 11; the 00 part stays. Now A and B are entangled: neither has a value of its own, but they agree.
- Step 4. Reading collapses the pair to 00 or 11 at random. Run it again and you get a fresh coin toss, but never a mismatch.
What is the maths behind a Bell pair?
A two-qubit state is four amplitudes, one per reading, in the order 00, 01, 10, 11 (left bit = qubit A). The start state:
|ψ₀⟩ = |00⟩ = (1, 0, 0, 0)
The Hadamard gate, applied to A alone (identity I on B):
H = (1/√2) · [ 1 1 ]
[ 1 −1 ]
|ψ₁⟩ = (H ⊗ I) |00⟩
= (|00⟩ + |10⟩) / √2
= (0.71, 0, 0.71, 0)
The CNOT with A as control and B as target swaps the 10 and 11 amplitudes and leaves the rest:
CNOT = [ 1 0 0 0 ]
[ 0 1 0 0 ]
[ 0 0 0 1 ]
[ 0 0 1 0 ]
|ψ₂⟩ = CNOT |ψ₁⟩
= (|00⟩ + |11⟩) / √2 = |Φ⁺⟩
= (0.71, 0, 0, 0.71)
Reading the pair gives x with probability |amplitude|² (the Born rule):
P(x) = |⟨x|ψ₂⟩|²
P(00) = P(11) = (1/√2)² = 0.5
P(01) = P(10) = 0
These are the numbers in the figure above; NumPy on the same matrices gives (0.7071, 0, 0.7071, 0), then (0.7071, 0, 0, 0.7071). Qiskit prints bit strings with q[0] on the right; for 00 and 11 the order makes no difference.
How do you write a Bell pair in Q#?
Q# writes quantum programs with ordinary programming ideas: operations, types, control flow.
@EntryPoint()
operation Main() : (Result, Result) {
// Allocate two qubits, initially |00>
use (q1, q2) = (Qubit(), Qubit());
// Put first qubit into superposition
H(q1);
// Entangle the two qubits
CNOT(q1, q2);
// Measure both qubits
let r1 = M(q1);
let r2 = M(q2);
// Reset before releasing
Reset(q1);
Reset(q2);
return (r1, r2);
}
Qubit()allocates a qubit in |0⟩;usereleases it at the end of the block.H(q1)applies the Hadamard gate;CNOT(q1, q2)entangles.M(q1)measures in the 0/1 basis and returnsZeroorOne.Resetputs each qubit back to |0⟩. Without it, every run that reads 11 (about half) stops with “Qubit1 released while not in |0⟩ state”; runs that read 00 already end in |0⟩.
Run: qsharp 1.31.0 (Python package; it now points to its successor, qdk), qsharp.run("Main()", shots=1000) → 00: 502, 11: 498. Docs: Microsoft Learn, Q#.
How do you write a Bell pair in Silq?
Silq is high-level and strongly typed, with automatic uncomputation: temporary quantum values are cleaned up for you.
def bell() {
// Create superposition
a := H(0:𝔹);
// Initialize second qubit
b := 0:𝔹;
// Apply X to b controlled by a
if a {
b := X(b);
}
return (a, b);
}
def main() {
return measure(bell());
}
0:𝔹is a qubit holding 0 (𝔹 is Silq’s bit type; without!it is quantum).if a { b := X(b); }branches on a quantum value. Nothing is measured: both branches happen in superposition, which is exactly a CNOT.measure(...)turns the pair into classical bits. Withreturn bell();instead, the simulator prints the state itself,√0.5·|[0,0]⟩ + √0.5·|[1,1]⟩, not a reading.- A qubit cannot be copied:
return (a, a);fails with “previous declarationa: 𝔹consumed here”. It cannot be silently dropped either when Silq cannot uncompute it: leavinga(made byH, which is notqfree) unused fails with “variableais not consumed”.
Run: Silq built from source (commit a7f0550, LDC 1.42.0), silq --run bell.slq 1,000 times → [0,0]: 497, [1,1]: 503. Docs: silq.ethz.ch.
How do you write a Bell pair in Quil?
Quil reads like assembly: one instruction per line, qubits by number, results into declared classical memory.
DECLARE ro BIT[2]
# Put qubit 0 into superposition
H 0
# Entangle qubit 0 and qubit 1
CNOT 0 1
# Measure both qubits
MEASURE 0 ro[0]
MEASURE 1 ro[1]
| Instruction | Meaning |
|---|---|
DECLARE ro BIT[2] | two classical bits named ro (readout) |
H 0 | Hadamard on qubit 0 |
CNOT 0 1 | controlled-NOT, control 0, target 1 |
MEASURE 0 ro[0] | measure qubit 0, store the bit in ro[0] |
The same program from Python with pyQuil (print(p) prints the Quil above, without the comments):
from pyquil import Program
from pyquil.gates import H, CNOT, MEASURE
p = Program()
ro = p.declare("ro", "BIT", 2)
p += H(0)
p += CNOT(0, 1)
p += MEASURE(0, ro[0])
p += MEASURE(1, ro[1])
print(p)
Run: the raw Quil on Rigetti’s QVM 1.17.2 (qvm -S, one multishot request, 1,000 trials) → 00: 495, 11: 505; pyQuil 4.23.0 prints the same five lines. Docs: Rigetti QCS docs.
How do you write a Bell pair in OpenQASM 3?
OpenQASM describes a circuit as a list of instructions. It is the format tools and hardware exchange, more than a language people write large programs in.
OPENQASM 3.0;
include "stdgates.inc";
// Allocate quantum and classical registers
qubit[2] q;
bit[2] c;
// Create superposition
h q[0];
// Create entanglement
cx q[0], q[1];
// Measure both qubits
c = measure q;
qubit[2] qdeclares two qubits;bit[2] ctwo classical bits.his Hadamard,cxis controlled-X (CNOT), both fromstdgates.inc.c = measure q;measures the whole register intoc.
Run: Qiskit 2.6.2 qasm3.loads(...) (needs the separate qiskit-qasm3-import 0.6.0 package) on Qiskit Aer 0.18.4, 1,000 shots → 00: 481, 11: 519. Docs: openqasm.com.
Do all four give the same result?
Yes. All four are noise-free simulators, so 01 and 10 cannot appear; on real hardware, gate and readout errors put a few percent of runs there. The 00 / 11 split varies from run to run the way 1,000 coin tosses do.
Which quantum language should you use?
- Q#: writing algorithms with functions, types and loops; Microsoft’s QDK and Azure Quantum.
- Silq: seeing what a type system can enforce about qubits; research and teaching.
- Quil: close to the hardware instructions; Rigetti’s QVM and processors, often generated from pyQuil.
- OpenQASM 3: moving a circuit between tools, compilers and IBM hardware; Qiskit reads and writes it.
FAQ
Is OpenQASM a programming language?
Version 3 is: it has classical variables, if, loops and subroutines next to gates. In practice it is used mostly as the circuit format that compilers, SDKs and hardware exchange.
Can Silq run on a real quantum computer?
No. Silq comes with its own simulator and has no compiler to quantum hardware.
Does Qiskit use OpenQASM?
Yes. Qiskit reads and writes OpenQASM 2 and 3; reading version 3 with qasm3.loads needs the qiskit-qasm3-import package.
Why does a Bell pair never give 01 or 10?
After the CNOT the amplitudes of 01 and 10 are exactly 0, and the chance of a reading is its amplitude squared. Only gate and readout errors on real hardware produce them.