Flipping Out

I've seen quite a few people comment in blogs that the endian issue I mentioned yesterday won't turn out to be much of an issue. Well, you can't say I didn't warn you about drinking the Kool-Aid, but it you still have some lingering doubts that there isn't a significant number of developers out there who are going to have issues, go wade your way through this stuff.

For a more concrete example, Apple have produced documentation for developers who use PowerPlant. PowerPlant uses various resources to describe the UI objects that are created--windows, menus, dialog boxes, etc. Reading these resources correctly in the context of a universal binary will be crucial. They've included some sample code to flip bytes in PowerPlant resources. It's more than 780 lines of code--780 lines of tedious, byte flipping code.

Now, there are quite a few people who are likely to say that this is really just an extreme example of where byte-swapping is problematic; that, if developers followed all the "rules" they will have no problem. The fact is that these "rules" are nothing more than rules-of-thumb--general guidelines that many developers will disregard for very legitimate reasons.

Consider a drawing program like Adobe Illustrator (I almost said FreeHand--does that date me?). Undo is an important feature in a drawing program. There are two ways to do Undo: save off an entire copy of an object for each user action, or encode user actions as operation codes that can be transacted. In the latter case, you save the object in its original state plus all of the changes the user made to the object as opcodes. Chances are that the opcode solution will result in much smaller files. It does, however, break the "rules" that unknowing people tend to tout when these kinds of discussions arise.

No. The PowerPlant resource example isn't extreme. It's just a common, specific example for which Apple have been kind enough to provide a solution. Anyone shipping serious applications that have not already had to solve this problem for cross-platform scenarios has quite a bit of tedious work to do. While I've welcomed this change for my own circumstances, I don't envy the position in which a number of my compatriots down in San Jose find themselves.

 

Rick

Currently playing in iTunes: If 6 Was 9 by Jimi Hendrix