Q needs you
Read the following sections to familiarize yourself with Q’s objectives, inspirations, and plans for the future.
Thursday, 30 April 2020, is our one-year anniversary. From conception 12 months ago to now we’ve built a functioning code API and a drag-and-drop circuit editor. While there are still many exciting features to add, and a list of issues to resolve, this anniversary is a milestone worth celebrating. As initial work on the circuit editor interface winds down our focus will shift back to optimization of the simulator itself. During Summer 2020 our primary focus will be wrangling multiple execution threads and hardware acceleration via WebGPU. On the back burner we’ll be adding new import and export utilities to make hopping between Q and other quantum suites a breeze.
For most people anything “quantum” is brand new. Even the simpler mathematics are things that most folks probably haven’t seen since high school. (When’s the last time the average person actually had to think about complex numbers?) If we’re going to make quantum accessible we need to include simple / legible / digestible concept primers for these topics right in the documentation, and also provide links to learning resources.
To this end documentation for Q classes—such as Q.Matrix, Q.Qubit, and so on—include brief explanations of the mathematics that the class represents before diving into the code and usage specifics. We also provide a separate Resources page with links to learn more about quantum computing in general.
This collection of
HTML files serve as Q’s interactive
Its design objectives are tidiness, shareability, and consistency.
When possible the general UI features,
such as the main navigation
or body modules,
are visually flat.
Buttons intended to be “pushed”
or circuit operations intended to be “dragged and dropped”
may be represented as dimensional.
Programs must be written for people to read, and only incidentally for machines to execute.
Structure and Interpretation of Computer Programs,
Preface to the first edition
Q’s source code is verbose, heavily commented, and there’s great empathy for fellow learners. Visual hierarchy is key when facing a brick of monospace code gibberish. White space helps; white space around variables, between conceptually different blocks of code. (You’ve got to let code breathe.) Semicolons as line-enders are avoided unless absolutely necessary. (They’re just visual clutter otherwise; typographic noise in the signal.) Q is meant to be flexible and expressive to adapt to your style. “Fluent interface” method chaining is prized, but Q often uses static class methods as a foundation for instance methods, so you’re free to use either approach.
Low barrier to entry
Hackable by design
There is nothing wrong with
and it’s in fact
more powerful than classical inheritance.
and to paper over that with
or ignore the power of
or pretend private variables weren’t possible prior to 2015
is like confusing an aptitude for Rock Band
with actual musicianship.
While Q’s internal code uses
const when declaring variables,
the examples here use
redeclare and overwrite example variables to your heart’s content.
Destructive vs non-destructive methods
Q pays particular attention to destructive versus non-destructive instance methods.
For example, the archetypal non-destructive method is
which returns a new sibling instance of the object it was called from
and by its nature makes no alterations to that original object.
.copy$( sibling ) is the archetypal destructive method
which causes an instance to alter itself by overwriting its own properties’ values with values from a sibling instance, then returns itself.
The dollar sign suffix is similar to
exclamation point suffix and is a reminder that the operation is destructive; will alter the instance.
cat = new Q.ComplexNumber( 1, 2 ),
dog = new Q.ComplexNumber( 3, -4 )
cat.toText() // Returns '1 + 2i'
dog.toText() // Returns '3 - 4i'
cat.add( dog ) // Non-destructive.
cat.toText() // Still returns '1 + 2i'
cat.add$( dog )// Destructive. Note the ‘$’ suffix.
cat.toText() // Now returns '4 - 2i'
The notable exception to this is the “Python-inspired” circuit editing syntax which uses convenience functions not suffixed with a dollar sign. This allows creating a circuit in Q to more closely resemble editing a Python script for Amazon Braket, IBM Qiskit, and so on:
Q( 2, 2 )
.h( 1, 1 )
.x( 2, [ 1, 2 ])
our CSS eschews modules and shadow DOM containers
in favor of carefully named global variables.
We feel it should be easy for you, the developer,
to be able to remix and reconfigure Q with ease.
Reuse the Q classes, customize them, or leave them be.
(Any box is a
“black box” if you don’t look inside it.)
Our CSS variables are prefixed with “
and several categories, such as color palette values,
are exposed for your convenience.