SIDEBAR
»
S
I
D
E
B
A
R
«
“Sci-Fi Mavens Offer Far Out Homeland Security Advice!”
Mar 27th, 2008 by jens

Speaking of Arthur C. Clarke, another of his achievements was to live a long life without making a complete ass of himself. A goal we should all emulate, but one that’s eluded too many other SF writers.

For example! Take Larry Niven and Jerry Pournelle, who, having ceased putting any mental effort into their writing at least 25 years ago, now have the free time, in their dotage, to advise top government officials on national security issues … in their own inimitable way:

Members of the group recently offered a rambling, sometimes strident string of ideas at a panel discussion promoting the group at the DHS science and technology conference. Among the group’s approximately 24 members is Larry Niven [...]
Niven said a good way to help hospitals stem financial losses is to spread rumors in Spanish within the Latino community that emergency rooms are killing patients in order to harvest their organs for transplants. “The problem [of hospitals going broke] is hugely exaggerated by illegal aliens who aren’t going to pay for anything anyway,” Niven said. *

[Emphasis mine.] Hmm; this plan wouldn’t by chance require a huge reprint run of a Spanish edition of The Long ARM of Gil Hamilton, to be distributed free at taquerias, would it?

[Disclaimer: I used to love Niven’s books, reading and re-reading Ringworld with slack-jawed amazement. But that was when I was a kid, in that distant era we call “The Seventies”, before he devolved into the Rush Limbaugh of the spaceways. Speaking of which…]

The 45-minute panel discussion quickly deteriorated as federal, local and state homeland security officials, and at least one congressional aide, attempted to ask questions, which were largely ignored. Instead the writers used their time to pontificate on a variety of tangentially related topics, including their past roles advising the government, predictions in their stories that have come to pass, the demise of the paperback book market, and low-cost launch into space.

You have to read the whole thing! Jerry Pournelle goes out on a limb with some far-future speculation that — if portable tele-phone receivers with cameras in them became prevalent — people might use them to take photographs of illegal activities, eliminating the need for professional law enforcement officers! David Brin rants about militias and bangs his shoe on the table!

These people clearly have some brilliant ideas, and should be immediately whisked to an impregnable high-tech Undisclosed Location deep beneath the Rocky Mountains where they can work full time on the long-term project of transforming their thrilling inventions into reality, in time to save the world from terrorists, Communists, fluoridation and injured Mexicans. As a side effect, the quality of SF writing would leap upwards.

The Origin Of The iChat UI
Mar 18th, 2008 by jens

I had lost this historical document for a long time, but finally found it the other day on an old backup CD. It’s the original 1997 sketch I made of a chat user interface based on speech balloons.
Read the rest of this entry »

The Beauty Of 99¢ iPhone Apps
Mar 7th, 2008 by jens

After digesting yesterday’s iPhone announcements [with fava beans and a nice Chianti] I started thinking about the pricing models made possible by the “Application Store”. In particular,

How cheap can an iPhone app be?

I think the answer’s clear. The Application Store will obviously be based on the iTunes store, whose bread-and-butter is a product, the AAC audio file, that sells for … 99¢. Apple’s clearly able to make a profit at that price point, despite credit-card processing fees, bandwidth costs, and comparable payments [Updated. Thanks, Dru!] to the record labels. So I see no reason they wouldn’t allow a developer to price an application that low.

But why would a developer want to sell an application for a net 70¢?

Micropayments

Because at such a low price, with a one-click store a couple of taps away, it becomes an impulse purchase. It’s a form of micropayment, an idea that’s been talked about for years but hasn’t widely taken off due to the practical difficulties of collecting very small payments. The few areas where micropayments (albeit larger than the canonical 1/10¢ originally proposed) have worked include the iTunes store, and the downloadable-game stores for the Xbox and Wii.

And let’s not forget the most amazing example of what people will pay for if you make it convenient enough: ringtones. The practice of charging suckers $2 for a 30-second snippet of a song they already have, is a multi-billion-dollar industry.
Read the rest of this entry »

hash musings
Feb 19th, 2008 by jens

I’ve been thinking about writing an essay about the beauty & weirdness of cryptographic hash functions. The way any digitized data, however huge, can be named by a short fixed-size binary string. The way there are in theory an infinite number of hash collisions, but in practice zero. I was talking to myself about it, this morning, and two quotes appeared, which I write down here to remember:

“Hashing is my favorite computer-science concept.”

and

SHA is the Dewey Decimal code of Borges’s Universal Library.”

(except that there’s a fallacy in the second statement, which I leave as an exercise for the reader.)

Make Mine Mercurial
Feb 9th, 2008 by jens

Distributed version-control systems have fascinated me for while. Unlike CVS and Subversion and the like, they don’t rely on a central server; instead, any user of the software can host a copy of the repository, and change-sets are pushed between repositories in a peer-to-peer fashion. These are a lot more powerful and flexible—the centralized CVS model is merely one special case of the configurations that a distributed system can use. And the issues of trust, synchronization and branching that they deal with are very similar to those that appear in peer-to-peer networks.

I’ve tried out several of these, including Monotone and Bazaar, but lately I’ve settled on Mercurial. I find it the simplest to understand and use, and being written in Python it’s extremely portable.

Mercurial’s having a contest to design a new logo. I hadn’t been paying attention, but today I was reminded of Mercury’s symbolic connection to alchemy and the occult, and decided to design something incorporating John Dee’s Monas Hieroglyphica, a symbol he designed based on the astrological symbol for Mercury. (I’m not an expert on Dee or on the occult, but I am a fan of John Crowley, who used both John Dee and his symbol in his _Ægypt_ series of novels.)

The logos

Fine print

  • PDF, EPS, and higher-resolution PNG renderings are available here
  • The type is set in Yanone Kaffeesatz, a Creative-Commons licensed font.
  • I vectorized the glyph from a bitmap drawing that appears on Wikipedia, placed in the public domain by the artist.
Network Barbie Says “Asynchrony Is Hard!”
Feb 6th, 2008 by jens

You can’t avoid asynchrony when writing network code, since operations can take an arbitrary amount of time, and often do. To keep the app responsive it has to be able to get other things done while a slow operation is in progress.

My first exposure to network programming was in Java, whose approach to asynchrony is to use threads. Lots of ‘em. The API calls are [almost] all blocking, so you run them on background threads. This is good because it makes the way the API works more intuitive: you call a method, and it returns a value when it finishes. This makes your own code more intuitive, as it just performs the operations in order, like: open connection, send request, read response, parse response, close connection, return.

The downside is that making heavily threaded code work correctly can be very hard, and the problems are subtle, hard to understand and debug, and sometimes almost impossible to reproduce. Edward Lee’s paper The Trouble With Threads describes a complex Java server that was excruciatingly well-designed, code-reviewed and tested.

“No problems were observed until the code deadlocked in April 2004, four years later. Our relatively rigorous software engineering practice had identified and fixed many concurrency bugs. But that a problem as serious as a deadlock could go undetected for four years despite this practice is alarming.”

My teammates and I had similar experiences while implementing the Java AWT libraries on Mac OS 9 and 10.0. We kept running into weird concurrency bugs, fixing them (which often meant restructuring code and making it more complex), and then running into more. By the time we were done, threading didn’t seem like such a good idea anymore.

Cocoa (and the underlying CFNetwork framework) instead make the asynchrony explicit, by using an event- and callback-based model. When you invoke a network operation, the call returns immediately; but you set up a delegate object or callback function that will later be invoked when the operation completes. A fancy event loop called a “runloop” at the top level takes care of dispatching events in order. For the most part, you can write your code using only a single thread and still let your app perform tasks in parallel without blocking the UI.

The drawback is that your code gets more complex, since the high-level control flow no longer matches the semantics of the programming language. A multi-step operation now involves a separate function to implement each step, and any state has to be stored externally in instance variables. Explicit state machines often pop up. There’s a lot of boilerplate for setting delegates, adding and removing observers, parsing notification dictionaries, and so forth, which obscures the actual logic of the code.

As you can guess, I’m knee-deep in this sort of thing right now. Just like many times before, I’m wishing there were a third way. I’d like to be able to keep each operation’s flow of control simple, as with threads, but at the same time limit the interactions between operations to keep the overall flow of control from turning into race-condition spaghetti.

Oh, and I want to keep writing in Objective-C. There are intriguing multiprocessing techniques in some higher-level languages, like Lua coroutines and Io actors, but I don’t think I’m ready to start writing the core of my app in one of them. I wonder if there’s a way to implement some of those techniques cleanly in Objective-C.

I’m not offering any solutions, just describing the problem I see. Maybe I’ll get one of those great “What, you’re not using XYZ? It does exactly what you want” comments! Or maybe not. Anyway, here are some things I’ve run across that offer useful techniques:

  • Higher-Order Messaging framework—adds some higher-level functional primitives for Cocoa programming, that makes delegation and callbacks simpler to use. ( Update 3PM: Appears to be incompatible with 10.5. It compiles, with warnings, but the self-tests quickly fail, with exceptions raised by NSInvocation. Dang!)
  • libcoroutine, a cross-platform implementation of coroutines (similar to cooperative threads) in C. (There are several of these; this is a newish one by Steve Dekorte which, unlike others I’ve tried, works correctly on Mac OS X.)
  • Actors, as found in the Io language and others. An actor is basically an object that runs a private event loop and thread: you communicate with it by sending it messages. This helps encapsulate state, since the object itself is only doing one thing at a time, and its internal state is hidden from other threads.
  • Update: I forgot to list NSOperation and NSOperationQueue, new classes in OS X 10.5. These aren’t “magic” in the way the above are, they’re just a little framework for managing simultaneous tasks, but they’re useful. I’m just getting started with NSOperation: it’s what I’m using for now to manage the nasty asynchronous bits.

Got any more useful links or ideas? Post them, and I’ll add ‘em here.

Dear Lazyweb: Certificates in RDF?
Jan 27th, 2008 by jens

Dear Lazyweb,

The project I’m working on will be using cryptographic certificates in a distributed web-of-trust model a little like that of PGP. It will also use certs as more than just proofs of identity. Given that I’ll be writing a lot of code using certs, I want to avoid the nastiness of X.509 whenever possible.

After thinking about this a while, it seems to me that RDF ought to be a good way to represent certs, since it describes arbitrary types of relationships between entities (e.g. FOAF), and allows them to be composed in complex ways. And there are a lot of tools available for parsing/storing/querying RDF.

Unfortunately, I know very little about RDF so far, or about the uses to which it’s being put. I’ve been looking, but I haven’t found any existing schema yet for using RDF for cryptographic certificates. Does anyone know of such a thing, or something related?

(The closest thing I know of is SDSI, a Simple Distributed Security Architecture, which was inspirational to me in showing how one can use general-purpose data structures like S-expressions to describe certs and form a web of trust. But SDSI and its successor SPKI seem to be dead, sadly, and nothing comparable has replaced them.)

Thanks,
—Jens

Update, 30 January:

No answer being forthcoming, and given the learning curve of RDF, I’m now pursuing the approach of representing certs in YAML. I also considered JSON, but YAML is essentially a superset of JSON that has some very useful features like tagging and aliasing.

The Gnostic argument for agnosticism
Dec 10th, 2007 by jens

In some online forums I list as interests both gnosticism and agnosticism, which is a bit of a joke since the two words are literally contradictory, but is true in that both are interesting and important to me. Agnosticism as my attitude toward religion: that the existence of a God or gods is fundamentally unknowable, undecidable, unprovable. Gnosticism as a mystic tradition, a suppressed early fork of Christianity, whose beliefs have more recently had a large impact on the literature of the fantastic and on postmodern philosophy (notably Philip K. Dick’s SF novels, the Matrix films, Philip Pullman’s His Dark Materials trilogy, and Jean Beaudrillard’s cultural theorizing.)

A few weeks ago I had the thought that you could combine Arthur Clarke’s famous Third Law with some of the ideas of Gnosticism, and arrive at a “proof” (which I’m aware is a contradiction in terms) of agnosticism. I’m sure this isn’t entirely original, but it amuses me.

Clarke’s Third Law states that “Any sufficiently advanced technology is indistinguishable from magic”. This idea has appeared in any number of science fiction plots, where time travelers from the future or astronauts visiting technologically-primitive planets are treated as wizards. It’s also been used in a way in mystery stories, by Dorothy Sayers and others, where a magical event appears to have happened — a murderer teleporting out of a locked room, a woman turning into a werewolf — but is discovered at the end to have been accomplished through mundane technological means. And of course, the professions of stage magicians and spirit mediums show that in some circumstances the technology doesn’t even have to be advanced.

So here’s a variant on that law: Any sufficiently advanced technology is indistinguishable from deity. History is full of real-world examples of this, when explorers from one civilization (usually European) made contact with a less technological civilization and were taken for gods or angels. The most significant such encounter may have been Cortés’s defeat of the Aztec empire, which (according to many accounts) was made considerably easier by the Aztecs — including their emperor — taking the conquistadors with their horses and guns to be emissaries of the god Quetzalcoatl (and Cortés to perhaps be the god himself.) More recently, the cargo cult religions on Pacific islands sprang up in response to the presence during World War II of American soldiers — although in this case it’s the technology, not the visitors, that was considered divine.

A key belief of the Gnostics was that the entire human race were on the receiving end of a similar kind of exploitation. The Gnostics believed the material world to be the product of a Demiurge, a lesser deity who was not omnipotent or omniscient but bound by the laws of nature. The demiurge was seen as good (if flawed) by some groups, but more often as evil. He was often identified with Satan, and sometimes even as the God of the Old Testament. His existence explained why the world was flawed and filled with evil, and put a new light on the jealous and vengeful actions attributed to God in the Old Testament.

From a 21st century perspective, informed by Clarke’s Law, we could see the demiurge as being entirely mundane, technological. A sufficiently advanced technology could undoubtedly assemble planets, design life forms, part seas, smite unbelievers, instill mystical visions and control thoughts. At the extreme end of speculation, our world could be a simulation fed into the sensory nerves of brains in vats, or our minds could be part of the simulation too. (There has even been recent argument, which I do not buy into, that this is a likely scenario.)

The Gnostics, as Christians, of course believed in a true omnipotent/omniscient God above the demiurge. Though of course, further intermediate deities could be interposed — the Wikipedia article describes “the introduction by emanation of further divine beings, which are nevertheless identifiable as aspects of the God from which they proceeded; the progressive emanations are often conceived metaphorically as a gradual and progressive distancing from the ultimate source, which brings about an instability in the fabric of the divine nature.” This puts me in mind of an infinite regress toward the final infinite God — a turtles all the way up cosmology.

In the end, unlike the Gnostics, I don’t see how there’s any way we could tell whether this is true or not. There’s nothing we can perceive as divine that couldn’t, possibly, be produced by some advanced technology. And any such “divinity” could conceivably, in turn, be eclipsed by something more advanced. We have no way of knowing.

But the Gnostics did believe that they had knowledge (_gnosis_) of the Word of the true infinite God. To me, this is their central mistake. Obviously, they had to believe they had a handle on the Truth, in order to be a religion. But most of their beliefs pointed to the inability of humans to discern such truth or tell it apart from the simulations/lies of the demiurge. The only way around this would be to posit that humans have an inbuilt mystic sense that can accurately tell the truth about religious beliefs … but the simultaneous existence of innumerable contradictory religious beliefs disproves this.

The only conclusion, to my mind, is to admit that we don’t know, and can’t know, no matter how compelled we may be by evidence or enlightenment or persuasion or insight. That’s agnosticism in a nutshell. Treat religious works, rituals, ideas as though they were stage plays or stage magic — draw from them delight, insight, compassion, wonder … even if you don’t believe for a moment that the lady was really cut in half and rejoined, the king really fell on his sword, the flowers were really transmuted into doves.

Holding a Program in One’s Head
Aug 27th, 2007 by jens

Paul Graham [who is obnoxiously elitist, but frequently insightful] has a new essay, “Holding a Program in One’s Head“, that is making me feel sad this morning.

“A good programmer working intensively on his own code can hold it in his mind the way a mathematician holds a problem he’s working on. Mathematicians don’t answer questions by working them out on paper the way schoolchildren are taught to. They do more in their heads: they try to understand a problem space well enough that they can walk around it the way you can walk around the memory of the house you grew up in. At its best programming is the same. You hold the whole program in your head, and you can manipulate it at will.”

I know that feeling so well, and I want to be back in that [non-Euclidean] space again.


Read the rest of this entry »

Hang on, I gotta take a call from the Archdemon Azazael
Jul 18th, 2007 by jens

37signals gripes about those annoying Bluetooth cellphone headsets with even-more-annoying blinky LEDs on them.

I once had the idea of a charity that would collect discarded headsets from yuppies and distribute them to mentally ill homeless people. Just by wearing the headsets, they would eliminate the social stigma attached to talking to themselves on the street; this would help re-integrate them into society.

»  Substance:WordPress   »  Style:Ahren Ahimsa