Tuesday, December 23, 2008

Contractual Ranting

Microsoft extended Windows XP sales yet again, more or less.  But rather than rant about how the Vista user experience makes me want to tear my fingernails off or how brain-damaged it is to try to put DRM into drivers, let me instead focus on Windows as an example of the cost of contracts.

I have ranted in the past about how the boundary between X-Plane and a third party, or the plugin system and third parties, or even two third parties, is a contract.  Consider:
  • The named light list forms a contract between X-Plane and objects, e.g. X-Plane guarantees that there will be a named light called "airplane_landing" and that it is a good choice for landing lights.  (This implies that X-Plane won't change what it looks like to be inappropriate for landing lights, and that third parties won't use it for inappropriate uses, like airport apron lights.)
  • XPLMGetDataf forms a contract between the plugin SDK and plugins, guaranteeing that there will be a function in the XPLM called "XPLMGetDataf" that takes a dataref and returns its value.  (This implies that Sandy and I won't rename it or change its arguments or remove it all together, and that plugins won't pass non-datarefs in as arguments.)
  • Even a paint kit forms a contract - the airplane maker is essentially saying "the tail will be mapped to the upper left of the texture, and I won't remap my UV" and the livery maker is saying "I will put an image in the upper left corner that looks like a tail."
By comparison, the clouds are not a contract - there is no way third parties can customize the look of the clouds, so we can change the algorithm by which we create them pretty much at will. We could switch to a volumetric approach for all clouds or even go back to 2-d without worrying about third party interaction.

Okay - that's a lot of words about contracts...what does that have to do with Vista?  Well...

The Cost of Changing the Contract

Two major aspects of why Vista has been a worse experience for users than Windows XP come directly to the need for Microsoft to change contracts.
  • For years, applications have run on Windows with admin rights.  This is not good - it means that any process can do serious damage to the system if hijacked - and on Windows processes get hijacked on a fairly regular basis!
  • For years, audio and video drivers have run pretty much unprotected.  This was good from a performance perspective, but also caused a lot of BSODs.  On Windows, drivers are third party components and are quite possibly not checked by Microsoft (especially video drivers) so letting them run without protections is risky.
In both cases, the problem is that the old contract is both (1) poorly designed* and (2) being used by a lot of third parties.  What choice did Microsoft have?  Continue to let apps run in admin mode and hijack the whole machine any time the user picked up a virus?  Or change apps to run in user mode and hope that the applications didn't depend on this guarantee?

(At this point, Raymond might go ballistic and point out that the Windows API doesn't really promise admin rights and apps should not have been doing all of these naughty behaviors in the first place.  I don't know what the Win32 API declares...the difference between what a platform declares and what it does is important enough to warrant another post.  Certainly with X-Plane we have to worry a lot about third parties depending on behavior that was unintentional but turned out to be useful.)

Vista has been a difficult transition because it changed a bunch of rules (that needed to be changed).  In the long term, I am sure that both of these decisions are for the better -- eventually applications won't be counting on administrator rights, so we won't have to fume about UAC (or shut it off), and a hijacked web browser won't be nearly as dangerous.

On the video driver front, the Vista experience is pretty reasonable now - there has been a lot of improvement since Vista first came out.  I expect applications and UAC to take a lot longer - video drivers get revised quite frequently; applications seem to linger around forever.

I'm Not Signing That

If we end up with a situation like this in X-Plane (the contract is used heavily by third parties and not well designed) we only have two options, and they're both bad:
  1. Break the contract.  Third party content stops working, users are angry, authors are angry.
  2. Stick with the contract and mitigate as best we can.  Usually this means writing more code (slows down new features), using a less optimal implementation (lowers frame rate), etc.
This is why my first reaction to any file format extension is: "is this going to be a PITA in a year"?  The benefit might be visible now, but the cost could plague us indefinitely.

What You Want, Not Where You Want It

If you would like to request a feature, tell me what you want, not where you want it implemented.  I bring this up because many of the feature requests I get are very specific and describe an implementation, not a goal.  (To draw an analogy, it's as if I call a general contractor and say "dig a big hole right here" without telling him "it is for a swimming pool".)

The reason "what not how" is so important is because many of the "how" implementations that people send me involve creating new contracts with third parties.  I am going to try to design the feature with the minimum contractual obligations - that is, to do just what is intended and hopefully not much more.  

But if I can't tell what you are trying to do, I can only say "I won't code this implementation - the cost of long term support due to contractual obligations outweighs the usefulness."  It might be that there is another way to implement the feature that would not put a long term burden on the scenery system or airplane SDK and still provide all of the benefits.

* Poorly designed?  Or perhaps well designed for a previous problem - if the problem changes, the design might not be appropriate.  Or perhaps not even designed at all - sometimes contracts evolve without a lot of central planning.  All of these things have happened in X-Plane.  In the case of Windows, I suspect it's the previous-problem case -- that is, what made sense for much smaller computers where the scope of what could be done was quite limited no longer makes sense for big modern computers that are capable of a more expensive and robust solution...just my speculation.

No comments: