23.10 20100

Damian Conway’s Quantum::Superpositions talk

All things considered, Damians Conway’s talk is Yet Another Perl6 Promotion (YAPP), but a damn fun one.  Highlighting some very funky new features that Perl 6 makes happen, in constant time. Theoretically.

Conway is one of the best speakers I’ve seen so far. His talks have speed, passion, a big dose of absurd humor and loads of geek references. If you have the chance to attend one of his talks: go see him, you won’t be disappointed, promise.

The talks starts with a lighthearted refresh of the history of quantum mechanics, unexpected revelations about Bohrs activities in modeling and winter sports and so on.
When the audience is under his spell Conway dives a bit deeper and shows many examples of Perl 6′s more natural syntax, and possible uses of superpositions. Showing how superpositions -called Junctions in Perl 6, are not just reserved for mad scientists. Junctions might be damn useful for programmers; replacing contrived nested for loops with elegant code generating prime’s, testing list membership, doing string comparison, all the while letting Perl take care of parallelization automagically, in constant time. Theoretically.

A very simple example showing the power of superpositions, in Perl 5, taken from the description page of Quantum::Superpositions.pm:

$ideal = any( all("tall", "rich", "handsome"),
all("rich", "old"),
all("smart","Australian","rich")
);

Operations involving such a composite superposition operate recursively and in parallel on each its states individually and then recompose the result. For example:

while (@features = get_description) {
if (any(@features) eq $ideal) {
print "True love";
}
}

The any(@features) eq $ideal equality is true if the input characteristics collectively match any of the three superimposed conjunctive superpositions. That is, if the characteristics collectively equate to each of “tall” and “rich” and “handsome”, or to both “rich” and “old”, or to all three of “smart” and “Australian” and “rich”.

Find a good description of the concepts here, and most of the examples used in his talk on here but you’ll miss the funky Perl 6 rewrites of them. Junctions are documented in the Perl 6 documentation here.

Start using Superpositions/Junctions in Perl 5 by installing the Quantum::Superpositions module from CPAN. The module is currently maintained by Steven Lembark, and will only add the “any”, “all” and “eigenstate” operators. For a more up to date implementation with more junction operators and autothreading fetch Perl 6 by installing Raduko.

Can’t wait until Conway returns for part II: Time::Space::Continuum!

Comments are closed.