Friday, May 13, 2005

A brief history of purity at Apple  

I was reading Ben Goodger's take on the recent Safari-KHTML kerfuffle. He's basically right. What I find particularly amusing is that ten years ago Apple would have been on the opposite side of the debate... with Apple fighting for purity and the open-source guys just putting in a quick hack to make it work.

It took Apple quite a while to get over its obsessions with purity in software design. Don't get me wrong; purity isn't a bad thing at all. In fact it's an important goal to strive for. But you have to make compromises to ship a useful product sometimes.

Ten years ago, more or less, Mac programmers like me were trying to deal with lovely gems that came out of Apple like these:

  • Apple Events -- in theory a great concept which used an incredibly flexible and extensible tagged-data interface. Problem was that its API and implementation were so annoyingly pure that they required allocation of a lot of temporary objects and a lot of memory got copied around needlessly. In the end it was much slower than any contemporary RPC/IPC call you could imagine.

    (Today: Apple Events have been kept alive, although with the implementation optimized and the API expanded to be faster and less pure. Several even-less-elegant but faster-and-easier methods of RPC/IPC became available with OSX and were quickly adopted by many grateful programmers.)

  • AppleScript -- in theory another great concept, designed around an abstracted open scripting architecture which could support multiple scripting dialects, and which allowed those flexible and extensible bits of tagged data from the Apple Event manager to be passed around. But only one dialect was ever completed, and the architecture wound up making it painful to implement from the developer's point of view. Heck, even the one-and-only dialect was fairly clunky from the user's point of view. This might make you wonder whom exactly it was designed for.

    (Today: AppleScript has stayed alive too, although the way developers and users actually use it in practice frequently disobeys the pure object-verb syntax of the original design. And what AppleScript support is out there generally comes for free from AppKit these days. Do you know anyone who's actually written code to properly parse a 'whose' clause lately?)

  • AOCE, or Apple Open Collaboration Environment -- in theory a great concept, trying to create a system that integrated mail, address books, digital signatures, networking, and more before all of these things were widespread. Its problem was that rather than attacking each problem individually, it tried to do them all at once. And it had a nicely object oriented design, but rather than allowing direct access to any of the dozens of classes or hundreds of members, it created accessors for every single operation. Ultimately it collapsed under its own weight. It was monolithic, huge, and incredibly difficult to understand. One of the Inside Macintosh: AOCE books was almost 1400 pages long -- big, 8.5" x 11" pages too. My phone book was smaller. And that book was only one of at least three...

    (Today: Deceased, just like all those trees.)

  • Open Transport -- a networking stack and API that had a very theoretically pure design and was supposed to, in theory and if you used it right, deliver rockin' performance. It did deliver better performance than the older MacTCP, but it was generally much too obnoxious for most developers to use directly. The most popular way to use it was via a wrapper library such as GUSI that made it more socket-like.

    (Today: Deceased. On OSX, Apple re-implemented the APIs with glue that calls through to Unix sockets.)

  • Newton -- another very pure concept. A tablet that you can just write on, and it will just recognize your handwriting! Cool! Electronic book! Electronic paper! The problem is that the technology and/or design clearly wasn't quite up to the task. It was big, clunky, expensive, and slow. The handwriting recognition technology was good in theory but notoriously imperfect in practice, but Apple stuck with it anyway.

    (Today: Deceased. A few years later, when Palm did basically the same product, they put in a hack called Graffiti so that they didn't have to solve the problem of generalized handwriting recognition.)

  • OpenDoc -- a very nice idea that was (and probably still is) ahead of its time. Rather than documents being things created by applications, they were just collections of objects which were essentially peers and had defined relationships to each other. If anything, OpenDoc was less a victim of its design and probably a victim of its circumstances: it was C++ and required COM, which was burdensome in terms of both performance and licensing, and it had to run on a rather lackluster and nonstandard OS which limited its portability.

    (Today: Deceased. But interestingly, Apple is just now starting to regain OpenDoc-like functionality with things like KVC, bindings, and CoreData. Thirteen years later.)

I think you can see what I'm getting at here. Apple being chastised for putting in quick hacks to make things work, rather than going for purity? By a bunch of Linux coders? Ah, sweet sweet irony.

Branching and Integration

I definitely feel the pain of the KHTML guys. But in the end what happened was inevitable.

See, one way or another Apple wound up on a branch. I don't know whether Apple chose to deliberately make incompatible changes, or if KHTML refused to accept some of their changes and forced them out on a branch. But regardless of your interpretation that's the way it ended up. And that was the first step towards KHTML's problems.

There should be (but probably isn't) a lesson in Software Engineering 101 about what happens when you have work proceeding on two different branches of a source tree. Integration -- the unpopular gruntwork everyone loves to hate -- starts to rear its ugly head. As long as the teams devote roughly the same amount of time to developing their branches, the branches grow in parallel and each spends a roughly equal amount of time integrating changes back and forth.

But what happens when one of those branches suddenly has a great deal of work invested in it, and the other doesn't? The team maintaining the less-vigorous branch starts spending more and more of their time on integration and less on development. Integration sucks; it's a necessary evil, but nobody likes doing it. Quickly it becomes less like fun and more like work. So the less-vigorous branch is in danger of withering even further.

It's made exponentially worse if the less-vigorous branch ever refuses some of the changes in the more-vigorous branch, because that causes the source bases to diverge even further. Now not only is there more integration work, but it's harder too. If the team is made up of part-time volunteers it can kill their enthusiasm for the project completely.

In a nutshell, that's pretty much what is happening (or has happened) with Apple's full-time engineering team and KHTML's part-time engineering team. Apple exacerbated the problem with what some are calling "code bombs", ie releases of an entire tree at once, but you're fooling yourself if you think the same problem would not exist regardless. The problem is really in the quantity of changes being made. Is it Apple's obligation to go back and do all the work to make their changes work on Konqueror? Not at all.

It kinda sucks for the KHTML guys, but the solution is clear even if they don't want to admit it: transition the upper levels over from the less-vigorous branch over to the more-vigorous branch. Rather than always integrating lots of changes from B back into A, start using B and port a few changes from A forward into B. It sounds like this is what Maciej suggested.

Happily, it sounds like they are pursuing something like this even as we speak.

Sunday, April 10, 2005

Hey check me out -- I'm Dancin'! I'm Dancin'!  

Get Perpendicular

Hitachi recently announced perpendicular recording technology, which is meant to improve the density at which bits can be put down on hard disks.

Storage density is exactly that -- the density at which information can be packed onto a storage medium like a hard disk. As density increases, that means that you can fit more data into the same size space, or fit the same amount of data into a smaller space, or both.

Over the years storage density has been increasing steadily. This has led to larger-capacity drives in physically smaller containers. Twenty years ago hard disks were clunkier and held a lot less data. 20MiB hard disks could be purchased but were expensive and rare. Today if you purchase a computer you'll probably get a 50GiB or larger hard disk, or over 2500 times the capacity, and it will take up a much smaller space. That's why the tiny little iPod mini can hold 6GiB of data.

But this rapidly increasing density has led to a problem. Magnetic storage technology is nearing its limits; today we are making bits so small and packing them so closely together that if we go any smaller, bits are in danger of flipping spontaneously from external factors. Since the bits are where your data is stored, you can't have them flipping arbitrarily -- because then you can't read what you just wrote. It'd be like trying to write on an etch-a-sketch that someone is shaking.

The arbitrary point at which this starts to happen and data is lost is called the superparamagnetic limit. Storage technology is getting very close to the superparamagnetic limit. Since bits need to be kept large enough that this doesn't happen, that in turn means that magnetic hard drives are close to their theoretical maximum density.

Hitachi has come up with a dodge that avoids the superparamagnetic limit for a little while longer. Rather than arranging data bits so that their magnetic poles aligned linearly along the surface of the disk pointing at each other (longitudinal recording), Hitachi is arranging them so that their magnetic poles are aligned parallel to each other and pointing away from the surface of the disk (perpendicular recording), with corresponding innovations in how the bits are read and written. This vertical alignment makes them less vulnerable to flipping and again increases the possible storage density. The result is that magnetic bits can be packed several times more densely than before, which means that drives will continue to be able to be made even smaller and higher-capacity than before. For example, rather than 6GiB iPod minis this will eventually make it possible to have 60GiB iPod minis.

It's all very serious and interesting and geeky.

So why exactly did they chose to promote this technology with a crazy Schoolhouse-Rock-style video including "Actuator Man" and little rectangular bits disco dancing?

Good question. Don't get me wrong, I think the video's great... I'm just a little baffled. Then again, it fits right in with Sanyo's HD-BURN promotion. Mr. CD-R, doubling of charming points!

Sometimes this is a bizarre industry I work in. But I'm glad people have a sense of humor about it.

Tuesday, April 05, 2005

Google Satellite Maps  

Google Maps just added an option for satellite photos. And I have to say ... wow. That is just wicked cool.

Not every location is covered by a high-resolution satellite photo, but a lot of places are. In particular, my town of Brecksville is available at the highest zoom level. I can see my house!

Play around with it for a while. Zoom in and out. It's incredibly fun. Here are a few neat locations to start with:

I'm incredibly stoked to see this feature in Google Maps. Yes, there are other sources for satellite and aerial imagery... but up until now it's either been slow and clunky, or a pay service. Integrating it with Google's terrific map interface makes all of that data extremely accessible for the first time.

Got any neat satellite image finds of your own? Let me know in the comments!

Monday, April 04, 2005

Nixon Approval Ratings  

From time to time as I look at current Presidential approval ratings, I find myself wanting to look at the week-by-week job approval ratings of former President Nixon. They are out there and available, of course, but they're surprisingly hard to find.

The best source I've found so far is the Roper Center at the University of Connecticut. They have a page with the data, but their graph quite frankly stinks. The value axis is compressed, there aren't any gridlines, and it just doesn't tell you much. So I compiled their data and made my own graphs, which I'll share with you now.

First, some background and the raw data:

And now the charts:

  • Stacked charts showing the poll results (click to zoom):
    Nixon job approval stacked poll results, base = approval Nixon job approval stacked poll results, base = disapproval
  • Approval only for Nixon's entire presidency (click to zoom):
    Nixon approval-only ratings, full Presidency
  • Approval only for Nixon's second term (click to zoom):
    Nixon approval-only ratings, second term
  • Net approval rating (approve minus disapprove) for Nixon's entire presidency (click to zoom):
    Nixon net approval ratings, full Presidency
  • Net approval rating (approve minus disapprove) for Nixon's entire presidency, annotated (click to zoom):
    Nixon net approval ratings, full Presidency, annotated
  • Net approval rating (approve minus disapprove) for Nixon's second term (click to zoom):
    Nixon net approval ratings, second term
  • Net approval rating (approve minus disapprove) for Nixon's second term, annotated (click to zoom):
    Nixon net approval ratings, second term, annotated

I think there are a few very interesting points that are visible in the raw data.

First of all, Nixon started with a substantial number of "no opinion" ratings -- as high as 35%. But the ambivalence quickly disappeared. There was substantial movement from "no opinion" to "disapprove" during the first few months of his Presidency. I haven't done a thorough analysis, but from the few others I've checked it looks like other presidents show the same trend in their approval. This doesn't seem to be specific to Nixon.

Second, Nixon was much more popular than Bush throughout most of his Presidency. President Bush's approval shot up after 9/11, but has steadily eroded ever since. Bush spent most of 2004 hovering under 50% approval and with a net approval of less than zero. Nixon didn't get that low until his former counsel was testifying before the special Senate Watergate panel describing the political espionage that he'd personally taken part in.

Third, to me it looks like Nixon was seen as "above the fray" at the start of Watergate. Everything was somebody else's fault and he didn't know about any of it. His approval rating was at an all-time high as the Watergate burglars were convicted, despite the fact that it was a fairly high profile case and some of them were former Nixon aides. It wasn't until one of the convicted former aides, James McCord, started to make allegations of obstruction of justice and point fingers higher up that things started to take a turn for the worse.

Fourth, July 1973 was an incredibly bad month for Nixon. His net approval rating dropped by a whopping 25%. At the end of June, his former counsel testified that he was involved personally in the Watergate break-in and was involved in the obstruction of justice. Then in July he refused to testify before the Watergate committee, citing executive privilege; the existence of the White House tapes was revealed; and he refused to hand over the tapes. All this contributed to a serious drop in public approval from which he never recovered.

Fifth, even as the worst came out there was still a solid core of about 25% of the country who never abandoned Nixon and continued to approve of him.

All in all, a very interesting set of data indeed.

[Update: December 1st, 2005] Probably because of the plight of our current president, a whole lot of people have been coming here to look at the gory details of Nixon's approval ratings. I should point out that Professor Pollkatz has a pretty nice chart up comparing raw numbers from Bush, Nixon, and Clinton. And he updates his Bush numbers regularly so you can keep track of the progress. Go check it out!

And keep in mind that despite all the recent indictments, President Bush himself has not really had a decisive Watergate moment yet, and probably won't while the Republicans control Congress.