Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your GitHub account [0] gives Common Lisp some love. Why did you choose to use this language? Specifically, for the implementation of your Quantum Virtual Machine?

[0]https://github.com/rigetticomputing



That's my doing.

When we started thinking about quantum programming languages, we didn't know what they should look like. Experimenting with different languages efficiently requires a language that makes language-building easy. I find that there are two classes of languages that provide that: Lisp-likes with metaprogramming and ML-likes with a good type system including algebraic data types.

Quil [0], our quantum instruction language, came out of language experimentation in Lisp. In fact, the Quil code:

    H 0
    CNOT 0 1
    MEASURE 0 [0]
used to look like this:

    ((H 0)
     (CNOT 0 1)
     (MEASURE 0 (ADDRESS 0)))
This was a no-hassle way to play around without thinking about how to wrangle lex and yacc with shift/shift and shift/reduce issues. If you've ever used them, it takes a while to get what you want, and integrate it into a product you're trying to create.

In addition to the need to construct languages, we also needed to simulate/interpret the language. Simulating the evolution of a quantum state is very expensive (which is why we are building quantum computers!), and is usually relegated to some closer-to-metal language like C.

Unfortunately, in C, high-speed numerical code (that is also blazing fast) is very difficult to experiment with, extend, maintain, etc.

Fortunately, over the past 30 years, Lisp compilers have become excellent at producing native machine code. With a compiler like SBCL [1], you can produce code which is very nearly optimal. For example, we have a function to compute the probability from a wavefunction amplitude. Here it is:

    > (disassemble #'probability)
    ; disassembly for PROBABILITY
    ; Size: 90 bytes. Origin: #x22B67F5A
    ; 5A:       F20F104901       MOVSD XMM1, [RCX+1]
    ; 5F:       F20F105109       MOVSD XMM2, [RCX+9]
    ; 64:       F20F59C9         MULSD XMM1, XMM1
    ; 68:       F20F59D2         MULSD XMM2, XMM2
    ; 6C:       F20F58D1         ADDSD XMM2, XMM1
    ; ...
There's some additional code that follows, but it disappears because this function is also inlined at the call sites.

Writing the QVM and associated compiler in Lisp has allowed us to move fast. The code is compact, extremely robust, and extremely fast.

I could say a lot more about this, but that's the gist of why we thought it was a sensible decision.

[0] https://arxiv.org/abs/1608.03355

[1] http://www.sbcl.org/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: