This repository contains the source code, experimental data, and analysis tools for the research paper "Is Productivity in Quantum Programming Equβivalent to Expressiveness?".
We present a comparative analysis of Hosted and Standalone quantum programming languages. By implementing a diverse set of quantum algorithmsβranging from fundamental oracles to the Quantum Fourier Transform (QFT)βwe quantitatively evaluate their expressiveness and potential for developer productivity using software engineering metrics.
- Abstract
- Scope of the Study
- Methodology & Metrics
- Repository Structure
- Setup & Reproducibility
- Running the Analysis
- Contributions
- LICENSE
The expressiveness of quantum programming languages plays a crucial role in the efficient and comprehensible representation of quantum algorithms. Unlike classical languages with mature abstraction mechanisms, quantum languages must integrate cognitively challenging concepts such as superposition, interference, and entanglement while maintaining clarity.
This project investigates the landscape of expressiveness through a comparative analysis of 9 quantum programming languages. We evaluate how these languages support the implementation of core quantum algorithms using Lines of Code (LOC), Cyclomatic Complexity (CC), and Halstead Complexity (HC) metrics. Our findings suggest that distinct trade-offs exist between expressiveness (abstraction) and productivity (cognitive load and implementation effort).
We categorize the languages into two paradigms, highlighting the evolution of assembly languages and modern high-level frameworks.
Extensions or libraries built on top of classical languages (primarily Python and APL):
- PennyLane (Xanadu) - A leading library for differentiable programming of quantum computers.
- Qiskit (IBM) - A comprehensive framework for gate-based quantum computing.
- Cirq (Google) - Focused on NISQ algorithms and hardware control.
- Qrisp - A high-level framework for structured quantum programming.
- quAPL - An array-based quantum programming language embedded in APL.
Languages designed specifically for the quantum domain, from low-level description to high-level synthesis:
- OpenQASM 2.0 - The standard intermediate representation for quantum circuits.
- OpenQASM 3.0 - A significant evolution introducing classical control flow and pulse-level control.
- Q# (Microsoft) - A high-level, domain-specific language for scalable quantum computing.
- Qmod (Classiq) - A high-level language for quantum logic synthesis.
The benchmarks selected cover fundamental primitives, oracle-based speedups, and basis transformations:
- Deutsch-Jozsa
- Bernstein-Vazirani
- Simonβs Algorithm
- Groverβs Search
- Quantum Fourier Transform (QFT) - A key subroutine in many advanced quantum algorithms (e.g., Shor's, QPE).
We utilize a custom Python-based analysis engine to parse and evaluate the source code based on:
-
Syntactic Verbosity:
- Lines of Code (LOC): Measures conciseness by counting non-empty, non-comment lines.
-
Control Flow Complexity:
- Cyclomatic Complexity (CC): Measures the number of linearly independent paths (branching logic) required to define the circuit or algorithm.
-
Cognitive & Lexical Complexity (Halstead Metrics):
- Volume (V): Information content based on operators/operands.
- Difficulty (D): Error-proneness and implementation difficulty.
-
Effort (E): Mental effort required to write the program (
$E = D \times V$ ).
-
Derived Ratios:
-
Control Flow Density:
$CC / LOC$ -
Cognitive Load per Line:
$Effort / LOC$
-
Control Flow Density:
.
βββ classic/ # Classical baseline implementations (Python)
βββ evaluation_metrics/ # Core analysis engine (Python)
β βββ core/ # Scanners and analyzer logic
β βββ metrics/ # Individual metric implementations (CC, LOC, Halstead)
β βββ plotting/ # Visualization scripts (Scatter plots, Radar charts)
β βββ results/ # Generated CSVs and Plots
βββ hosted/ # Source code for hosted languages
β βββ cirq/
β βββ pennylane/ # PennyLane implementations
β βββ qiskit/
β βββ qrisp/
β βββ quapl/
βββ standalone/ # Source code for standalone languages
β βββ q#/
β βββ qasm/ # OpenQASM 2.0
β βββ qasm3/ # OpenQASM 3.0
β βββ qmod/
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container configuration
βββ docker-compose.yml # Orchestration
To begin, clone the repository to your local machine using the following command:
git clone https://github.com/Universidad-Cenfotec/quantum-programming-languages-expressiveness.gitThis will create a local copy of the project on your machine. After cloning, navigate to the project directory:
cd https://github.com/Universidad-Cenfotec/quantum-programming-languages-expressiveness.git
For running Q# and QASM programs, you'll need to install the Azure Quantum Development Kit (QDK) extension for Visual Studio Code:
- Open VS Code
- Go to the Extensions view (Ctrl+Shift+X)
- Search for "Azure Quantum Development Kit (QDK)"
- Click Install For more information about the QDK extension, visit the official QDK repository.
There are two ways to set up the environment for this project: using a virtual environment or using Docker. Choose one of the following methods:
Using a virtual environment ensures that the project dependencies do not interfere with other Python projects on your machine.
-
Install Python: Ensure Python 3.12.8 (or later) is installed.
-
Setup: In case that you prefer running locally, is recommended to create a virtual environment
- For Windows:
python -m venv .venv .venv\Scripts\activate
pip install -r requirements.txt - For Mac/Linux:
python3 -m venv venv source venv/bin/activatepip install -r requirements.txt
Docker allows you to run the project in a containerized environment, ensuring consistency across different machines.
-
Install Docker: Ensure that Docker and Docker Compose are installed on your machine. If you don't have Docker, you can download and install it from here. Docker
-
Build and run the Docker container: After ensuring Docker is installed, navigate to the project directory (if you're not already there) and run the following commands:
docker compose build docker compose up -dThis will build the Docker image and start the container in detached mode (-d).
Our analysis pipeline is automated. You can generate the raw data (CSVs) and the visualizations used in the paper. To generate the metrics (McCabe CC, LOC and Halstead), navigate to the evaluation directory and run the following command on your terminal (Remember to have the virtual environment active):
python -m evaluation_metrics.main
This will produce CSV files with the calculated metrics, ready for analysis. Then you can go to:
python -m evaluation_metrics.menu
And run these to generate some informative graphics. Output: Plots will be saved in evaluation_metrics/results/graphics/.
Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request. Ensure your code adheres to the existing style and includes appropriate tests.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.