Search code examples
functional-programmingquantum-computing

From an application programmer's perspective - Can Functional Programming be used to program Quantum Computers?


I'm not an expert in Functional Programming (FP). In fact, I just started learning it.

So, here is the real question: Since, FP is derived from Mathematics and not from von. Neumann machine, can this programming style/paradigm be used to program Quantum Computers? This is more from an application programmer's perspective since low-level machine instructions may be completely different.


Solution

  • No. Functional programs still perform classical computation. The functional style as we currently define it has nothing resembling superposition, quantum mechanical gates, or interference. While it is possible to transport the general idea of higher-order and first-class functions into the realm of quantum computation (and people are researching that right now), just as there are quantum Turing machines, as far as I can tell the results are as different from classical functional programming as quantum algorithms are from classical algorithms. For example, in QML if ... then ... else ... is removed in favor of a similar conditional where the condition is a qbit and the result is a superposition of the then and else values.

    Now, of course quantum computers are Turing-complete and could, in theory, execute any classical algorithm. But why on earth would you do that? We already have classical computers, and they are (and will always be) much more efficient at executing classical computations. The only reason to program a quantum computer is to make it run an algorithm that exploits in a nontrivial way the weirdness of quantum effects. To even express that, one needs a very different language regardless of the level of abstraction at which you work.