Sunday, February 06, 2011

Bits are eternal

Last week I mentioned Kari and Esa, two informatics medalists interested in Haskell and category theory. This week Kari started a blog. His topmost science fiction story is an accessible summary of those themes.

The key paragraph is this:

Long ago, the program logic for computers was saved in monolithic ways, which made it difficult to reuse existing functionality for new purposes. Companies rationalized it with the need to protect their source code. On the other hand, computing capacity was also billions of times more scarce, forcing people to meticulously design all kinds of algorithms. Ancient software nowadays qualifies as a kind of art, when you looked at their painstakingly polished details and routines fine-tuned with clocksmith's precision, aiming to save every cycle and every bit of memory. Uki sighed while trying to remember what those primitive days felt like.

The Loom of Culture was a method to extend imagination as far as possible without breaking the sense-muscle interface [Note: The character, Uki, is embedded in a virtual reality where digital input fills his senses. His muscles also move him virtually. The sense-muscle interface connects his "body" to the virtual world.] All logic in the loom consisted of separate, abstract construction rules and restrictions as well as metadata, which made it possible to automatically combine the rules and restictions. The user could create contexts on the fly and combine, inherit and duplicate them. Each context had a set of objects it was working on and building. The user could add or remove assumptions, modifying the end result while the loom automatically reached logical conclusions based on type information, pruning impossible branches with restrictions. If the loom couldn't deduct some necessary feature from assumptions, the model offered the most probable default value in the same way as human vision fills blind spots with the best guess based on available information.

The loom had a basic context of general knowledge. The user could add more contexts from trusted sources. Typically each user started with a standard environment, supplementing it with libraries of his own hobbies as well as personal adjustments. The power of the system was its ability to make the knowledge in the models interact and build a massive amount of possibilities by combining simple, relative rules and pruning them with restrictions. Using it was much easier than you would think from this description, since the standard context could interpret thought, movement and speech to guide the loom. The difference to an artificial intelligence was that the loom didn't have its own intentions and it didn't act automatically, it only extended the imagination of its user.

Uki gestured to open the standard context, looked at the empty space ahead of him and said in his thoughts "Open the music library and let us assume Devil's Sonata by Tartini and the memes of popular music in the 1900s." The composition memes were made of functions. Some of the functions took other compositions as parameters, producing new compositions. For example "repeat" might be a function A ↦ AA and fade(X) produced a verion of X, which faded to silence in the end. These building blocks operated mainly on notes and concepts like "pitch", "volume", "duration" and "instrument". The memes themselves had been filtered with a genetic algorithm. The compositions were located at a timeline, and were "phenotypes". The genetic algorithm searched for the shortest set of functions to generate a composition. This program was the "genotype" of the composition, which generated the "phenotype". The idea of searching for the shortest composition was that it distilled the essential and abstract structural ideas from the compositions, relative to the current meme pool. In addition, whole compositions contained a kind of conceptual network, which described how often each block had been used as input for another and how long various patterns typically last. In addition to building blocks, the library contained information about harmony. The algorithm also increased the score of the composition if it contained several short genotypes, making it a kind of compact crossroads for several ideas. This could not completely model creativity, but it approximated it reasonably, as ideas interacted in the composer's head with other areas of life.

The next paragraphs explain what this has to do with programming.

Programming as meaningless, aimless busywork

Once I presented the character drawing software for N900 for a person in the company I work for. He commented that it was a nice competence development project. This represents a mindset where programming is meaningless, useless activity which aims to get money from the customer. Competence development is the only other imaginable reason to code. Programming to implement features is unheard of alien blasphemy.

For those people, programming as a kind of schoolwork assignment. It is impossible to talk with them about programming in any higher level of abstraction than which function call does what, since only losers talk about homework assignments unless they need hints to complete one. In school, the primary goal of reifying the status hierarchy goes far ahead of learning. Similarly at work, there is no debate about the purpose of writing software. Consequently, people are often as alienated about the nebulous goal of programming as they were in school about learning specific course content.

Making machines obey human will

In Kari's (and my) opinions, programming is all about making machines obey human will. Non-programming methods like creation wizards and cofiguration files are just as fine, but rarely enough. The short story shows programming without writing code and calling functions. The loom of culture is likely still Turing complete.

In the hierarchy of low-level and high-level languages, the loom of culture is the highest imaginable one. The programmer to expresses exactly the core requirements. The machine generates everything else by logical deduction and reasonable default values.

Programming languages are becoming more and more abstract, enabling the programs to shrink. Languages typically improve by placing low-level restrictions. This allows more guaranteed abstract features on higher levels. For example C language does not allow direct stack manipulation. This enables modular function calls.

Haskell is the current peak of this trend. Despite several attempts to learn it, I can't code in it myself. But Haskell has the reputation of producing the smallest implementations for various features. It also has the strictest low-level restriction in any language - namely, that you can't set a variable. This restriction makes it mainly an academic language which little industry adoption.

The loom of culture also has an interface which matches human intuition. Kari once described writing Haskell as the closest thing he has seen to writing what you think. Languages development requires insight into human intuition, and there is some empirical evidence that setting a variable is unintuitive.

Category theory is a branch of mathematics which is relevant to understanding Haskell and a source of inspiration for improving the state of art. I didn't understand the content of Esa's and Kari's debate at the time, and now Kari moved to Helsinki, but it was about developing even better languages. Esa says that type system is at the core of the effort, and indeed type-level restriction are mentioned in the loom of culture. Usually the word "abstract" is a rhetorical device ("This is like, totally abstract and general!") but in language development they must face it head on.

Kari and Esa are both talented, experienced and driven people, and they understand programming on some higher level that is inaccessible for my IQ and programming experience. The loom of culture is just one glimpse of it.

No comments: