Monday, April 21, 2008

Tracking the invisible, moving, unpredictable target

An idea which has been creeping up on me from the side over the last couple of weeks hit me square in the face today. No matter what standards we Cocoa types use to create our user interfaces, the official Aqua HIG, the seemingly-defunct IndieHIG, or whatever, ultimately producing what is considered a usable (or humane, if you like) interface for Mac OS X is not only difficult, but certainly unrepeatable over time.


The "interface" part of a Cocoa user interface is already hard enough to define, being a mash-up of sorts, and to differing degrees, between the Platinum HIG which directs the default behaviour of some of the *Manager controls and the OpenStep HIG which describes the default behaviour of most, if not all, of the AppKit controls. If that isn't enough, there is an inexact intersection - some controls work differently in (what are loosely called, and I'm not getting into the debate) Cocoa apps than in Carbon apps. There have also been innovative additions on top of the aforementioned guides, such as sheets, unified toolbars and (the already legacy) textured interfaces. There have been subtractions from both - miniwindows still exist but nobody uses 'em, and window shading went west with Rhapsody.


But all of that is related to the user interface, not to user interaction (I'm in the middle of reading Cooper's The Inmates Are Running the Asylum, I'm going to borrow some terminology but studiously avoid discussing any of the conclusions he presents until I'm done reading it). It's possible to make HIG-compliant inspectors, or HIG-compliant master-detail views, or HIG-compliant browser views and so on. It's also possible to make non-compliant but entirely Mac HID views, coverflow views, sidebars and so on. But which is correct? Well, whichever people want to use. But how do you know which people want to use? Well, you could get them to use them, but as that's typically left until the beta phase you could ask usability gurus instead. Or you could take the reference implementation approach - what would Apple (or Omni, or Red Sweater, or whoever) do?


Well, what Apple would do can, I think, be summed up thus: Apple will continue doing whatever Apple were previously doing, until the Master User takes an interest in the project, then they do whatever the Master User currently thinks is the pinnacle of interaction design. The Master User acts a little like an eXtreme Programming user proxy, only with less frequent synchronisation, and without actually consulting with any of the other 26M users. The Master User is like a reference for userkind, if it all works for the Master User then at least it all works for one user, so everyone else will find it consistent, and if they don't find it painful they should enjoy that. The official job title of the Master User role is Steve.


All of this means that even inside Apple, the "ideal" usability experience is only sporadically visited, changes every time you ask and doesn't follow any obvious trend such as would be gained by normalisation over the 26M users. Maybe one day, the Master User likes inspectors. Then another day he likes multi-paned, MDI-esque interaction. On a third day he likes master-detail control, in fact so much so that he doesn't want to leave the application even when it's time to do unrelated work. Of course you don't rewrite every application on each day, so only the ones that he actually sees get the modernisation treatment.


So now we come back to the obvious, and also dangerous, usability tactics which are so prevalent on the Windows platform, and one which I consciously abhor but subconsciously employ all the time: "I'm the developer, so I'll do it my way". Luckily there are usability, QA and other rational people around to point out that I'm talking shite most of the time, but the reasoning goes like this. I'm a Mac user, and have been for a long time. In fact, I might know more about how this platform works than anyone within a couple of miles of here, therefore(?) I know what makes a good application. One problem which affects my personal decisions when trying to control the usability is that I'm only tangentially a Mac person, I'm really a very young NeXTStep person who just keeps current with software and hardware updates. That means I have a tendency to inspector my way out of any problem, and to eschew custom views and Core Animation in favour of "HIG is king" standard controls, even when other applications don't. And the great thing is that due to Moving Target reference implementation, I can find an application which does something "my" way, if that will lend credence to my irrational interface.


The trick is simply to observe that taking pride in your work and expressing humility at your capabilities are not mutually exclusive. If tens of other Mac users are telling me they don't like the way it works, and I'm saying it's right, apply Occam's razor.


And if there isn't enough fun for you in one usability experience, a bunch of us are presumably going to be providing the iPhone HIG-compliant V on top of our Ms and Cs before long.

Thursday, April 10, 2008

Come back, purple button, all is forgiven!

As a great philosopher once wrote: don't it always seem to go, that you don't know what you got 'til it's gone? Previews of Mac OS X had a user interface feature, known by all who saw it as the Purple Button. Look at this screenshot from System Preferences:



The boiled sweet on the top-right of the window would go purple, hence the name. Clicking on it activated a single-window mode. All documents except the one that you were working on would be minimised into the Dock, and switching between them would minimise the earlier one before restoring the newly-focused document. Of course, the problem with this in the developer previews/public beta which rendered it unusable were performance-related. The "lickable" eye-candy in Aqua was ambitious even on the top-end G4 systems available at the time, and so time spent in the Genie or Scale effects was really noticable. Add to that the effect of applications being slow enough not to update their views in time - the System Preferences application you can see above is a Cocoa-Java app, and back then the JVM wasn't amazing for performance - and you have a really sucky single-window experience.


On the other hand, it's really bloody useful. Look at apps like WriteRoom or GLTerminal, which go out of their way to get rid of all that other clutter. Or Spaces (or CDE virtual desktops, WindowMaker virtual desktops... you get the idea), also designed to let you forget all those other apps are there. Well, spaces is quite nice (and a little more flexible than purple button was), but playing spaces ping-pong tends to make me a bit seasick. Not to mention the time it wastes being about as great as the unperformant purple button switching...so please, purple button, come back!


Some environments provided the same user experience out of a lack of choice - for instance, OZ couldn't show more than one application if it wanted to, and certainly running more than one at once was out of the question (it would simulate multi-tasking by suspending background tasks).

Thursday, April 03, 2008

How exciting

Today I was pleasantly surprised by Interface Builder. Not shiny, new, where the hell have they put that buttonstreamlined IB3, but boring old IB2 which even Slowlaris users could work out how to use. I dragged a header defining a category with an IBAction onto IB, and lo, nay even behold, it did the right thing.


That may seem unexciting and even expected, but it's one of those nice cases where it's pleasing that everything just works. I thought category headers might be edge-case enough to confuse the thing; many people would put their IBAction definitions in the "regular" @interface header so that the IBOutlets are in the same place.

Sunday, March 23, 2008

Broke track mounting

For some reason, CDs occasionally don't automount for me on my iMac. Luckily that's easy to work around:
kalevala:~ leeg$ diskutil list
[...]
/dev/disk3
#: TYPE NAME SIZE IDENTIFIER
0: CD_partition_scheme Audio CD *620.3 Mi disk3
[...]
kalevala:~ leeg$ diskutil mountDisk disk3
Volume(s) mounted successfully

Job is, as they say, a good 'un.

Friday, March 14, 2008

Nice things about ObjC

Title linkies to a post by an F-Script guy (the F-Script guy? I'm not sure, I don't really follow F-Script development) about nice things he likes about the Objective-C language. Remembering that he wrote a Smalltalk scripting environment for Cocoa, some of the list is fairly unsurprising, much is made of the dynamic runtime, multiple-level dispatch and so on. I think the article is mainly bang on, though I do disagree with the author in a few places. The next paragraph is not one of those places.


Classes are objects. ++ This is the coolest thing ever about proper object-oriented languages, and one of my strongest arguments for design patterns are not language independent. Do patterns such as Prototype need to exist in ObjC code, when the Factory Method +new will give you an unconfigured typical instance?


Dynamic typing... Optional static typing. This is one of those slippery slopes where both edges are sharp enough to give you the rope required to shoot yourself in the foot. Duck typing (i.e. if an object looks like a duck, and quacks like a duck...) is useful in some cases and damned annoying in others. To avoid runtime exceptions with duck typing you either have to [i]mentally assert correctness in your code, [ii]perform all the runtime introspection needed to ensure your messages will be handled, or [iii]eschew the duck type completely and downcast to either an instance of a class or a conformant of a protocol (or both; you could do something like GLModelObject <NSCoding> * if you really felt like it). Another issue with the ObjC implementation of duck typing is that it doesn't always work as you'd think. When it does work, it's very powerful - when it doesn't, you probably won't find out until runtime, and could be spending a long while working out what happened.


Categories. No, afraid not. Nice idea, badly implemented. The point of categories is to let you decorate a class with additional functionality by adding methods - currently not ivars - in additional code objects, not all of which need be present at launch. This lets you work around the visibility contract of the class (can't see an @private ivar? Just chuck an instance method in!), though in fairness so does KVC. But perhaps the worst crime a category can commit is killing someone else's category. Or overwriting an "undecorated" method.


I still love Objective-C, mainly because I love Cocoa and GNUstep and making code that works like them, it's definitely powerful and fun too. But it's not without its rough edges and sharp spiky bits.

Thursday, March 06, 2008

My discs have been Americanised!

For some reason, even though l10n and i18n have been fashionable terms in computing for the last few years, no-one seems able to localise properly into the lingua franca of computing, English. It may surprise some readers to learn that there's more than one dialect of english, and some of these even have their own ISO codes (such as en_GB, en_US and so on...I'm ignoring the "ang" language for now). Some words in these different dialects are not spelled in the same way. I live in the United Kingdom of Great Britain and Northern Ireland (Land of hope and glory, mother of the free...) and therefore those round things are known as discs. Indeed, when I insert my Mac OS X installer disc, it is called "Mac OS X Install Disc 1". Then I launch the Firmware Password application, which tells me: "The firmware password is used to prevent others from starting your computer with a different disk." Gah!

Sunday, February 24, 2008

"Patently" obvious

Due to a lack of digit extraction I'm not at FOSDEM this weekend. That's unfortunate because as well as catching up with my friends at Brainstorm and on GNUstep, I really enjoyed the weekend last year and drank plenty of great Belgian beer and ate plenty of nice moules-frites.



So I've been spiritually living the Free lifestyle by reading what RMS and Torvalds have to say. Mostly I've been going over the essays in Free Software, Free Society. I find it very easy to accept the premises RMS uses, easy to follow, comprehend and agree with the arguments he presents but then somehow (perhaps for illogical reasons on my part, his part or both) hard to agree that the conclusions he draws are inevitable.



For instance, I agree that copyright law exists directly to benefit the public, and indirectly to benefit the authors (by providing incentives for authors in the shape of limited term monopoly over their authored content) and not at all to benefit Industry Associations. It even says that here, in the first ever copyright law: ...for the Encouragement of Learned Men to Compose and Write useful Books; May it please Your Majesty, that it may be Enacted... certainly doesn't seem to mention greedy lawyers or management.



Letters patent were never created for the same reason, of course. But because it became clear that patents from the Crown were obtained uppon Misinformacions and untrue pretences of publique good, many such Graunts have bene undulie obteyned and unlawfullie putt in execucion, to the greate Greevance and Inconvenience of your Majesties Subjects, contrary to the Lawes of this your Realme, and contrary to your Majesties royall and blessed Intencion soe published, so the whole system was rebooted so that patents were only grantable ... to the true and first Inventor and Inventors of such Manufactures, [...] soe as alsoe they be not contrary to the Lawe nor mischievous to the State, by raisinge prices of Commodities at home, or hurt of Trade, or generallie inconvenient....



The situation we find ourselves in now is that industries claim copyrights and inventions from the authors and inventors and lobby for more and more restrictive variants of the above laws, ignoring the previously-granted rights of the public at large and extending the previously-ungranted rights of the rights-owners, simultaneously removing those rights from the people granted the rights in the first place. So why in the case of copyright do the FSF assume copyright, but in the case of patents they refuse to deal with them? That inconsistency I don't understand.

Monday, February 18, 2008

Don't go there

From the title linky: " Mobility is only available for Windows and Linux." Good job no-one bases their mobile appliances on Mac OS X ;-)

Saturday, February 16, 2008

Mach-OFS: aforementioned polish and functionality

It's getting there, now has the ability to display load commands (though it only reports useful information for LC_SEGMENT and LC_SEGMENT_64 commands):



Again the screenshot depicts the OmniDazzle binary for no reason other than it's a nontrivial file. The directions in which to take the filesystem are now numerous: I can add info about the remaining load commands (v. useful), the raw data for each segment (somewhat useful), and the sections in each segment (v. useful). Whether the filesystem will eventually get to the level of symbol resolution, I'm not sure :-).

Friday, February 15, 2008

Well, you could have told me

When looking through some of the configuration options on my laptop (well, it's either that or go to the pub and socialise with humans) I came across something I couldn't account — pardon the pun — for. A new user account on the system, short name messagebus, full name "Message\ Bus" user id 506. Now messagebus looks like the name of a system daemon user, but that full name looks like some clueless skiddie made a mistake creating the user account, especially as the uid is that of a regular user. That's the kind of mistake no self-respecting installer would make.


So, what had this phantom user done? Well, thankfully, nothing. Neither the shell nor home directory was real, and wtmp/utmp showed no activity. Neither did the ssh logs - but in looking for them I realised that I don't actually use ssh on the box, so turned it off.


Anyway, it turned out to be an innocuous issue - the MacPorts installer for dbus creates this bogus user, which I've since deleted. This Apple forums discussion explains more.

Sunday, February 10, 2008

Mach-O FS (no really, MacFUSE does rule)


It needs some polishing and more functionality before I'd call it useful, then I have to find out whether I'm allowed to do anything with the source code ;-). But this is at least quite a cool hack; exploring a Mach-O file (thin or fat - in this case, I used the OmniDazzle executable which is a fat file) as if it's a file system. FUSE of course makes it easy, so thanks to Amit Singh for the port!

Saturday, February 09, 2008

MacFUSE rules

One reason that microkernels win over everything else (piss off, Linus) is that stability is better, because less stuff is running in the dangerous and all-powerful kernel environment. MacFUSE, like FUSE implementations on other UNIX-like operating systems, takes the microkernel approach to filesystems, hooking requests for information out of the kernel and passing them to user-space processes to handle. Here's the worst that can happen when screwing up a FUSE filesystem:



Now that might sound not only like a recipe for lower-quality code, but also like I'm extolling the capability to create lower-quality code. Well no it isn't, and yes I am. The advantage is that now the develop-debug-fix cycle for filesystems is just as short as it is for other userland applications (and HURD translators and the like). This provides a lower barrier to entry (meaning that it's more likely that interesting and innovative filesystems can be created), but also a faster turnaround on bugfixes (no panic, restart, try to salvage panic log... no two-machine debugging with kdb...) so ultimately higher-quality filesystems.

Friday, February 08, 2008

Non-subscription updates means charged?

The justification for the iPod Touch upgrade fee (to enable the new apps, which are actually deployed-but-disabled by a free firmware upgrade) is the same as the justification given for the MacBook wireless upgrade fee last year - that adding new features to a product that isn't sold as a subscription service needs to be charged for. That in itself is odd - it means that the regulators in the States get to set a price (if not the price) for hitherto free products offered by companies. But it raises a more interesting question - what constitutes a new feature? If a bugfix renders a previously-unusable feature usable, is that charged for? If a security fix makes it possible to use a system in a different environment, should that be charged for?

Thursday, February 07, 2008

From the no-man's-land of the format wars

About nine and a half years ago, a sixteen-year-old gadget boy in Weymouth made a simple mistake. Given the already near-complete shift of the music industry from the cassette tape to the Philips compact disc, and the superior portability and resilience of the Sony MiniDisc format, this boy decided that it was obvious the world was going to adopt this format. So our protagonist went out and bought a MZ-R35 walkman. Three years later, and although the writing was by now on the wall for the storage format, he added an MD-M3 to his collection.


I now believe I own all five pre-recorded MiniDisc albums ever made (though I don't remember when I bought Hours by Bowie, and can only think that I bought Recurring Dream because at the time I fancied a girl who liked Crowded House), and have swathes of my vinyl and tape collection "backed up" to recordable MDs. But the rest of the world forgot to catch up with me! Where are the Hi-MD drives built in to laptops? Even Sony don't offer that... Come to that, why do we still put up with crappy scratchable CDs? iPods may be a damn sight more convenient than my MD walkman is, but the bandwidth of an amazon package containing MiniDiscs is still far higher than the connection between my laptop and iTunes.


I still intend to find the required cable and port the rest of my LPs to the format though, as MDs are definitely more portable and resilient than is vinyl. And I haven't actually listened to Bauhaus' 1979-1983 in years.

Friday, February 01, 2008

We! Haven't! Thought! This! Through!

So almost the entire world has exploded with news that Microsoft haven't bought Yahoo!, but are at least waving ridiculous amounts of TEH CAHS under the noses of the shareholders. But what would be the outcome of such a takeover? Microsoft and Yahoo! are in pretty much the same position, they both have technologically acceptable "online presence" services which are marketed really badly such that a competitor virtually owns the market. The only example of a service between them I can think of which is vaguely market-leading is Flickr, although Yahoo! Groups (which was eGroups) might still be popular, I expect that Facebook and Google groups are at least comparable, if not larger than it. Hotmail and Yahoo! Mail are both familiar names, but then online mail is now a free and worthless commodity, and everyone has been playing catchup with Gmail for the last couple of years. People don't "Windows Live Search" a thing, they "Google" it. People don't "Yahoo! Video" their dogs on skateboards, they "Youtube" them.

So the post-acquisition world would go from two implementations to one, but one that's still being marketed into the ground and with a few fewer workers. And all the transitional pain that Microsoft will impose on Yahoo! services, when someone remembers that FreeBSD isn't a Microsoft solution. M$ seem to be of the opinion that with a market they don't lead and $45Bn, the best approach is to lose the $45Bn and hire some other people who don't lead the market. Not, like, take that $45Bn and make their stuff better.

Saturday, January 26, 2008

Permissions whee!

As in any good mystery, the question is who done it? MacNN reports a flaw in Tiger, Leopard in which an authenticated copy operation gives the destination files (the copies) the ownership of the logged-in user, not of the name they used to authenticate. The question is, which user did the copy?


Let's say there's a system with Alice Administrator and Richard Regular-User. Richard downloads a new application from the intarwebs, and wants to put it in /Applications (though why? Why can't he just put it in ~/Applications like a good little user? Never mind). The thing is, he doesn't have the right to do that. Finder presents him with an authentication dialogue, and no matter how many times he enters his username and password correctly, he can't acquire that right. However, he sees Alice walking past in the corridor and asks her to enter her admin credentials. For whatever reason, she agrees - now Alice has authenticated and Alice has acquired the right to copy the files. So even though Richard requested the copy, it was actually Alice who performed it. Therefore Alice created the files at the destination, so they should be owned by Alice.


The only thing which muddies the waters (and leads to the conflict of convenience vs. security which is described in that article) is that in many, or indeed most, cases on OS X where this will arise, Alice and Richard are actually the same person - Sammy the Single (Security-conscious, hence separating their use of the system into regular and admin accounts) User. It's a convenience that as Richard wanted the files copied, Richard now owns the copy - but this defeats the point of Richard existing, which is that Sammy doesn't want to be able to change /Applications without being warned.


Interestingly the same question doesn't get asked of the sudo command - it's clear that if I type sudo ditto Foobar.app /Applications/Foobar.app it's the super-user who does the work.

Thursday, January 24, 2008

Side-by-side

A frequently-heard rider on the statement that Mac OS X "is more secure than Windows" is that fewer people are prodding its weak spots, because it has fewer users. Well, Windows Vista has a market share comparative to Mac OS X (all versions), and this report describes the security statistics as being somewhat comparable, too. So there we go.

Wednesday, January 23, 2008

How to solve every problem in Cocoa

Yes, really, every problem. Don't think of Cocoa as "simple things simple, complex things possible" (actually, was it Cocoapenextstepsody or Perl who started with that tagline? Or someone else? I digress) but "simple things simple, complex things simple but you're looking at it wrong". With Objective-C 2.0 (particularly properties), Core Data, Cocoa Bindings and Cocoa Scripting, almost every "it doesn't work" moment comes down to getting something wrong with KVC or with KVO - either observing the wrong key, or typoing a method name such that you aren't KVC-compliant for a key you need to be, getting validation wrong or unexpectedly going down the -setNilValueForKey: path. So do yourself a favour:


#define GLInstanceMethodEntryLog(format, ...) NSLog(@"-[%@(%p) %@] entry: %@", NSStringFromClass([self class]), self, NSStringFromSelector(_cmd), [NSString stringWithFormat: format, ##__VA_ARGS__])

Now because all of the retain count bugs disappeared when you turned the garbage collector on, the remaining issues are with that bit of code the PHBs are paying for ;-)

Thursday, January 17, 2008

Project: Autonomous Revolutionary Goldfish

I was going to write, am still going to write, about how silly project names get bandied about in the software industry. But in researching this post (sorry blogosphere, I've let you down) I found that the Software-generated Gannt chart was patented by Fujitsu in the US in 1998, which to me just explains everything that is wrong with the way the US patent system is applied to software. For reference, Microsoft Project was written in 1987 (although is not strictly prior art for the patent. Project does everything in its power to prevent the user from creating a Gannt chart, in my experience).


Anyway, why is it that people care more about the fact that they're going to be using Leopard, Longhorn, Cairo, Barcelona or Niagara than about what any one of those is? As discussed in [1], naming software projects (though really I'm talking about projects in the general sense of collections of tasks in order to complete a particular goal) in the same way you might name your pet leads to an unhealthy psychological attachment to the project, causing it to develop its own (perceived) personality and vitality which can cause the project to continue long after it ought to have been killed. For every Cheetah, there's a Star Trek that didn't quite make it. And why should open source projects like Firefox or Ubuntu GNU/Linux need "code names" if their innards are supposed to be on public display?


I've decided that I know best, of course. My opinion is that, despite what people may say about project names being convenient shorthand to assist discussion, naming your project in an obtuse way splits us into the two groups which humanity adores: those of us who know, and those of you who don't. The circumstance I use to justify this is simple: if project names are mnemonics, why aren't the projects named in a mnemonic fashion? In what way does Rhapsody describe "port of OPENSTEP/Mach to PowerPC with the Platinum look and feel"? Such cultish behaviour of course leads directly to the point made in the citation; because we don't want to be the people in the know of something not worth knowing, we tend to keep our dubiously-named workflow in existence for far longer than could be dispassionately justified.


Of course, if I told you the name of the project I'm working on, you wouldn't have any idea what I'm working on ;-).


[1]Pulling the Plug: Software Project Management and the Problem of Project Escalation, Mark Keil. MIS Quarterly, Vol. 19, No. 4 (Dec., 1995), pp. 421-447

Saturday, December 08, 2007

Objective-C Design Patterns

Certain events at work have turned me into a bit of a design patterns geek of late, and as such I stumbled across this DDJ article from 1997 (the title of this post is the link). According to del.icio.us not many other people have stumbled across it, but it's a great article. The code listing links seem to 404 even though the listings are at the bottom of page 1 of the article.


Something very important can be learned from this article, which is at best covered tangentially in the GoF book: Design patterns are not language-independent. Calling the C++ and Objective-C ways of writing code "pattern idioms" ignores the point that actually, the code you come up with is more important than the design (customers don't typically want to pay the same cash for your UML diagrams that they do for your executables), and gasp different languages require different code! Different patterns can be used in ObjC and Smalltalk than in C++, and different patterns again in object-oriented Perl. Different patterns will be appropriate for working with Foundation than with the NeXTSTEP (pre 4.0) foundation kit or with ICPak101. Designing your solution independent of the language and framework you're going to use will get you a solution, but will not necessarily produce the easiest solution to maintain, the most efficient solution or one that makes any sense to an expert in the realm of that language and framework.

Tuesday, December 04, 2007

FSF membership

I am now an associate member of the FSF. This is a good way to support Free Software development (including GNUstep, and you don't even need to be able to code :-). I've added a referral link to the sidebar - I don't get a kickback obviously, although I do get gifts if enough people are referred by me, and it helps the FSF to track where donors are getting their information from. If you use Free Software, you might consider donating some cash - especially now that the dollar's so crap ;-).

Thursday, November 22, 2007

Post #100!

And to celebrate, we look at the differences between managers and humansprogrammers.

Upcoming Cocoa nerd stuff

I have organised a NSCoder Night for this coming Tuesday, November 27. It shall be in the Jericho Tavern pub at 8pm; bring yourself, bring an interest in Cocoa, and perhaps bring some code to talk about or work on. There won't be any agenda as such, just a group of NSCoders talking about NSCoding.


In January, PaulHR and I shall be entertaining OxMUG on the subject of Getting Things Done™ - in particular I have now started braindumping my many to-do lists into OmniFocus and I'm finding it very expressive and useful. In fact preparing that talk has just zoomed its way over to my OF inbox :-). That talk shall be Tuesday, January 8th.

Monday, October 29, 2007

Verify your backups

Apple shipped Mac OS X 10.5 this weekend, and three of the features are Time Machine, dtrace, and improved CHUD tools. Time Machine, dtrace, CHUD tools. iPod, mobile phone, web browser. Time Machine, dtrace, CHUD tools.


To spell that out in long hand, it's very easy now to see how various features in the Operating System behave. And in the case of Time Machine, we see that it walks through the source file system, copying the files to the destination. When I last gave a talk to OxMUG on the subject of data availability, it was interesting to notice how the people who had smugly put their hands up to indicate that they performed regular backups became crestfallen when I asked the second question: and how many of you have tested that backup in the last month?


Time Machine is no different in this regard. It makes copies of files, and that's all it does. It doesn't check that what it wrote at the other end matches what it saw in the first place, just like most other backup software doesn't. If the Carbon library reports that a file was successfully written to the destination, then it happily carries on to the next file. Just like any other backup software, you need to satisfy yourself that the backup Time Machine created is actually useful for some purpose.

Sunday, October 28, 2007

+1-415-312-0555

Back in 1992, Robert X. Cringely wrote in Accidental Empires: How the boys of Silicon Valley make their billions, battle foreign competition, and still can't get a date [Oxford comma sic]:


Fifteen years from now, we [Americans] won't be able to function without some sort of machine with a microprocessor and memory inside. Though we probably won't call it a personal computer, that's what it will be.

Of course, by and large that's true; the American economy depends on microcomputers and the networks connecting them in a very intimate way. It's not obvious in 2007 just how predictable that was in 1992, as the "networks connecting them" had nothing like the ubiquity which is now the case. When "Accidental Empires" was written, the impact of a personal computer in an office was to remove the typewriter and the person trained to type, replacing both with someone who had other work to be doing typing on a system thousands of times more complicated than a typewriter.


What's most interesting though is the (carefully guarded; well done Bob) statement that "we probably won't call it a personal computer," as that part is only partially true. All of the people who have Tivos, or TVs, also have a personal computer. All of the people who have mobile phones and digital cameras also have a personal computer. The people who have Playstation 3s and Nintendo Wiis also have personal computers. In business, the people who annoy everyone else by playing with their palmtops in meetings instead of listening to what the amazingly insightful Cocoa programmer has to say are also wasting time trying to work out how to sync them with, yup, the personal computer they also have on their desk.


So the question to be asked is not why Cringely got it wrong, because he didn't, but why hasn't the PC already disappeared, to be completely replaced with the "it is a PC but we won't call it that" technology? Both already exist, both are pervasive, and the main modern use of both is remote publishing and retrieval of information, so why do we still tie ourselves to a particular desk where a heavy lump of metal and plastic, which can't do very much else, sits disseminating information like some kind of [note to self: avoid using the terms Oracle or Delphi here] groupthink prophet?

Thursday, October 25, 2007

OmniWeb 5.6 tip of the day

defaults write com.omnigroup.OmniWeb5 WebKitOmitPDFSupport -bool TRUE

Sorry, but it doesn't view properly and doesn't print properly either :-(.

Tuesday, October 23, 2007

The times, they mainly stay the same

bbum displays a graph of the market capitalization (he's american, so the z sticks) of a few of the computer companies, noting that if after-hours trading isn't too surprising, then tomorrow (for Americans, again) the market will open with Apple being the biggest computer manufacturer on the planet. However, these figures fail to show something reasonably interesting.


What have IBM (up 24% y-o-y), HP (up 30 %) or Dell (up 21%) done to enamour you to their brand lately? If you're anything like me, then they've done nothing at all. Selling the same old Operating Systems on the same old hardware doesn't count as innovative. Compare them with Sun (up 13% year-on-year) or Apple (115%) and you'll see that there's basically no accounting for taste on the stock market. While Apple have been selling the shiny gadgets, Sun have been delivering the most observable operating environment on the planet and Dell have been doing, well, shit-all would be a polite phrase, and yet Dell have outstripped Sun in growing their stock price. In fact, HP have managed to blow up their stock price out of all proportion, while fighting scandals and the complete haemmorhaging of their management staff.

Saturday, October 13, 2007

Nice-looking LaTeX Unicode

Because there was no other single location with all of this written:



\usepackage{ucs} % Unicode support
\usepackage[utf8x]{inputenc} % UCS' UTF-8 driver is better than the LaTeX kernel's
\usepackage[T1]{fontenc} % The default font encoding only contains Latin characters
\usepackage{ae,aecompl} % Almost European fonts/hyphenation do a better job than Computer Modern

There are a couple of characters I need (Latin letter yogh, Latin letter wynn + capitals) which aren't known by UCS, and I don't yet know how to add them. But this is a pretty good start.

Saturday, September 15, 2007

Still trading as ClosedDarwin

It's not surprising, but while Apple's opensource page now includes a link to the iPhone software release (clicky the title), this only contains links to the WebCore and JavaScriptCore source, which is also available from the WebKit home on MacOSForge.org. While it is possible that the iPhone is distributed solely with software Apple can distribute without source, I wouldn't be surprised if there isn't just a teensy dollop of GPL code in there somewhere...

Wednesday, September 05, 2007

Old news

So the Inquirer thinks they've got a hot potato on their hands, with this "security flaw" in OS X. I've been using this approach for years (like, since NeXTSTEP): boot into single-user and launch NetInfo manually, then passwd root. Or in newer Mac OS X, nicl means you don't have to launch NetInfo.


Of course, if you give physical access to the computer without a Firmware password, then the 'attacker' may as well just boot from external media and do whatever they want from there. But the solution, as well as setting the Firmware password, is to edit the /etc/ttys file, change the line:



console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow" vt100 on secure onoption="/usr/libexec/getty std.9600"

to:



console "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow" vt100 on onoption="/usr/libexec/getty std.9600"

Now the root password is required in single-user mode (as the console is no longer considered a secure terminal).

Sunday, August 26, 2007

Holding a problem in your head

The linkied article (via Daring Fireball) describes the way that many programmers work - by loading the problem into their head - and techniques designed to manage and support working in such a way. Paul Graham makes the comparison with solving mathematics problems, which is something I can (and obviously have decided to) talk about due to the physics I studied and taught. Then I also have things to say about his specific recommendations.


In my (limited) experience, both the physicist in me and the programmer in me like to have a scratch model of the problem available to refer to. Constructing such a model in both cases acts as the aide memoire to bootstrap the prolem domain into my head, and as such should be as quick, and as nasty, as possible. Agile Design has a concept known as "just barely good enough", and it definitely applies at this stage. With this model in place I now have a structured layout in my head, which will aid the implementation, but I also have it scrawled out somewhere that I can refer to if in working on one component (writing one class, or solving one integral) I forget a detail about another.


Eventually it might be necessary to have a 'posh' layout of the domain model, but this is not yet the time. In maths as in computing, the solution to the problem actually contains the structure you came up with, so if someone wants to see just the structure (of which more in a later paragraph) it can be extracted easily. The above statement codifies why in both cases I (and most of the people I've worked with, in each field) prefer to use a whiteboard than a software tool for this bootstrap phase. It's impossible - repeat, impossible - to braindump as quickly onto a keyboard, mouse or even one of those funky tablet stylus things as it is with an instantly-erasable pen on a whiteboard. Actually, in the maths or physics realm, there's nothing really suitable anyway. Tools like Maple or Mathematica are designed to let you get the solution to a problem, and really only fit into the workflow once you've already defined the problem - there's no adequate way to have large chunks of "magic happens here, to be decided at a later date". In the software world, CASE tools cause you to spend so long thinking about use-cases, CRC definitions or whatever that you actually have to delve into nitty-gritty details while doing the design; great for software architects, bad for the problem bootstrap process. Even something like Omnigraffle can be overkill. it's very quick but I generally only switch to it if I think my boardwriting has become illegible. To give an example, I once 'designed' a tool I needed at Oxford Uni with boxes-and-clouds-and-lines on my whiteboard, then took a photo of the whiteboard which I set as the desktop image on my computer. If I got lost, then I was only one keystroke away from hiding Xcode and being able to see my scrawls. The tool in question was a WebObjects app, but I didn't even open EOModeler until after I'd taken the photo.




Incidentally, I expect that the widespread use of this technique contributes to "mythical man-month" problems in larger software projects. A single person can get to work really quickly with a mental bootstrap, but then any bad decisions made in planning the approach to the solution are unlikely to be adequately questioned during implementation. A small team is good because with even one other person present, I discuss things; even if the other person isn't giving feedback (because I'm too busy mouthing off, often) I find myself thinking "just why am I trying to justify this heap of crap?" and choosing another approach. Add a few more people, and actually the domain model does need to be well-designed (although hopefully they're then all given different tasks to work on, and those sub-problems can be mentally bootstrapped). This is where I disagree with Paul - in recommendation 6, he says that the smaller the team the better, and that a team of one is best. I think a team of one is less likely to have internal conflicts of the constructive kind, or even think past the first solution they get concensus on (which is of course the first solution any member thinks of). I believe that two is the workable minimum team size, and that larger teams should really be working as permutations (not combinations) of teams of two.


Paul's suggestion number 4 to rewrite often is almost directly from the gospel according to XP, except that in the XP world the recommendation is to identify things which can be refactored as early as possible, and then refactor them. Rewriting for the hell of it is not good from the pointy-haired perspective because it means time spent with no observable value - unless the rewrite is because the original was buggy, and the rewritten version is somehow better. It's bad for the coder because it takes focus away from solving the problem and onto trying to mentally map the entire project (or at least, all of it which depends on the rewritten code); once there's already implementation in place it's much harder to mentally bootstrap the problem, because the subconscious automatically pulls in all those things about APIs and design patterns that I was thinking about while writing the inital solution. It's also harder to separate the solution from the problem, once there already exists the solution.


The final sentence of the above paragraph leads nicely into discussion of suggestion 5, writing re-readable code. I'm a big fan of comment documentation like headerdoc or doxygen because not only does it impose readability on the code (albeit out-of-band readability), but also because if the problem-in-head approach works as well as I think, then it's going to be necessary to work backwards from the solution to the pointy-haired bits in the middle required by external observers, like the class relationship diagrams and the interface specifications. That's actually true in the maths/physics sphere too - very often in an exam I would go from the problem to the solution, then go back and show my working.

Saturday, August 25, 2007

Template change

I had to make some minor edits to the Blogger template used here anyway, so I decided to have a little monkey with the fonts. Here's what you used to get:


And here's what you now get:


I think that's much better. Good old Helvetica! I don't understand anything about typography at all, but I think that the latter doesn't look as messy, perhaps because of the spacing being tighter. Interestingly the title actually takes up more space, because the bold font is heavier. Marvellous.

Friday, August 24, 2007

Random collection of amazing stuff

The most cool thing that I noticed today ever is that Google Maps now allows you to add custom waypoints by dragging-and-dropping the route line onto a given road. This is great! I'm going to a charity biker raffle thing in Pensford next weekend, and Google's usual recommendation is that I stay on the M4 to Bristol, and drive through Bristol towards Shepton Mallet. This is, frankly, ludicrous. It's much more sensible to go through Bath and attack the A37 from the South, and now I can let Google know that.


Trusted JDS is über-cool. Not so much the actual functionality, which is somewhere between being pointy-haired enterprisey nonsense and NSA-derived "we require this feature, we can't tell you why, or what it is, or how it should work, but implement it because I'm authorised to shoot you and move in with your wife" fun. But implementing Mandatory Access Control in a GUI, and having it work, and make sense, is one hell of an achievement. Seven hells, in the case of Trusted Openlook, of which none are achievement. My favourite part of TJDS is that the access controls are checked by pasteboard actions, so trying to paste Top Secret text into an Unrestricted e-mail becomes a no-no.


There does exist Mac MAC (sorry, I've also written "do DO" this week) support, in the form of SEDarwin, but (as with SELinux) most of the time spent in designing policies for SEDarwin actually boils down to opening up enough permissions to stop from breaking stuff - and that stuff mainly breaks because the applications (or even the libraries on which those applications are based) don't expect to not be allowed to, for instance, talk to the pasteboard server. In fact, I'm going to save this post as a draft, then kill pbs and see what happens.


Hmmm... that isn't what I expected. I can actually still copy and paste text (probably uses a different pasteboard mechanism). pbs is a zombie, though. Killed an app by trying to copy an image out of it, too, and both of these symptoms would seem to fit with my assumption above; Cocoa just doesn't know what to do if the pasteboard server isn't available. If you started restricting access to it (and probably the DO name servers and distributed notification centres too) then you'd be in a right mess.

Saturday, August 18, 2007

It's update o'clock

In other words, it's "Graham remembers that someone needs to write the interwebs, too" time. The main reason I haven't written in a while is that I'm enjoying the new job, so it's satiating my hacking desires. No hacking projects = nothing to talk about. I can't really talk about the work stuff, either; this is unfortunate because I did some really cool KVC-cheating in a prototype app I wrote, and it'd be a good article to describe that.


I've more or less dropped off the GNUstep radar recently. I still need to talk to the employers' legal eagles in order to update my FSF copyright assignment, and then find something to hack on. Currently I only have a Mac OS X machine so I'd probably switch to some app-level stuff. I have half a plan in my mind for a SOPE app, but despite reading all the documentation I still haven't worked out how to get started :-|. The code isn't too much of a problem, I've used WebObejcts before, but WebObjects has a 'hit this button to build and run your WebObjects code' button, and there's no description AFAICT for SOPE of what to put in the GNUmakefile to get built and running SOPE code, even whether you're supposed to provide your own main() or anything. Hmmm...I wonder if there's a sample project around...

Saturday, July 14, 2007

Ich habe mein Handy verloren

Ooops. Left my mobile phone on holiday in Germany when I came back. This may explain why some people who were expecting to hear from me in Germany didn't...anyway, could anyone who thinks I ought to know their phone number please either leave a private comment on this livejournal entry (all comments are private by default on that post), or e-mail me? Thankyou! I promise to buy a filofax which I won't leave in foreign parts.

Thursday, June 21, 2007

The new netiquette

It used to be that netiquette was all about TURNING OFF THE CAPS LOCK, making sure that the subject matched the content, that you didn't go off the wall if someone didn't reply to your e-mail in a few minutes, that sort of thing. In fact, this (RFC1855) sort of thing. But now there are different netiquette requirements, and no obvious guidelines, nor seemingly any common practices. Now I'm just the kind of person who thinks that some de facto ruleset would be useful, so that everyone knows what to expect from everyone else.



For instance, take social networking sites like LinkedIn or Facebook. How well do you know someone before you 'add' them as a friend? Once met at a conference, once read their blog, cohabited for two years? Do you talk to them first, to let them know who you are and that you're not a crazy stalker? If someone adds you, and you don't know who they are, do you accept or reject by default? Do you ask them who they are? If they claim to have met you at $conference or in $pub, do you accept that, ask for a photo, or what?

Tuesday, June 19, 2007

A bit late for that, isn't it?

Just won the above-linkied item on eBay: the Amiga SDK :-) I'm probably slightly late to make any money out of Amiga development, but I'm glad I finally get to tinker. Might have to crack open the AROS if I get sufficiently involved...

I could probably write a three-page rant about how great the Amiga was and how badly Commodore stuffed up. But of course, none of it would be new ;-).

Wednesday, June 13, 2007

Apple and Google sitting in a tree, f-i-g-h...erm...t-i-ng

This really came out of a throwaway comment I made on Daniel, but it seems popular to pick apart every last iota of Steveness from the WWDC keynote, and I'm nothing if not popular. So here we go.


What is WebClip? In fact, that's not really the question I want to be asking. We know what WebClip is; it's a technology which lets users see only the bits of web pages that those users want to see. The real question is what does that mean? Well, I know which bits of a web page I usually want to see; they're the bits which aren't adverts.


I'm going to go out on a bit of a limb, and guess that the way WebClip works (I'm not a WWDC bod so I don't have any more access to the new stuff than anyone else; in fact I haven't even downloaded the Safari 3 beta) is by observing which DOM elements are within the clipped region, and downloading only media relevant to those elements. If that's the case, then you can ignore the fact that the ads on the page don't get seen; they don't even get downloaded. Therefore if I'm reading, say, the Dilbert strip in a WebClip, I'm effectively getting free Dilbert, even more free than the free website because I'm not upping their ad impression count.


One thing I noticed about the various sites that Steve clipped is that as far as I can remember, none of them features 'Ads by Google'. It would be quite embarrassing for Apple's CEO to demonstrate how to reduce revenue for one of Apple's most prominent board members in a world-broadcast keynote talk. As over 99% of Google's revenue is from online ads, and Eric Schmidt (CEO of Google) is on the Apple board, that is exactly what Steve was showing us, though. There'll be a doughnut fight back at Infinite Loop over that, I expect.

Monday, June 11, 2007

Miniwindows

Maybe it's just me who gets annoyed by teeny-tiny miniaturised views which are completely illegible. Even so, I've just uploaded an article I wrote on Miniwindows which can be used in any OpenStep implementation such as Cocoa or GNUstep. It's based on the Hillegass TypingTutor example, but doesn't really use any code from that and isn't (I hope) otherwise reliant on that context, so it should be possible to see what's going on even if you haven't read Hillegass. Which you should ;-)

Wednesday, June 06, 2007

Moving on

There has been some cat-escaping-bagness, which is mainly my fault, but now that it's all official I'm going to 'announce' it myself: I've got a new job! From the end of July, I'll be working at Sophos as Senior Software Engineer, Mac (the post is still up at the linky in the title, for the moment).


This looks like being an exciting time - I've been enjoying the ObjC hacking I do with Brainstorm and this will be an opportunity to do even more of that, and the move from services to user-installed apps will bring its own changes and new experiences.


Erm, that really is all for now. More info as it becomes available, and all that.

Saturday, May 12, 2007

A bit of backup script

Good news - there's a handy tool in OS X called wait4path which can help when writing timed scripts to backup to removable media.


Bad news - it [at least in Tiger....] works slightly esoterically - if a path is already present, it will still wait for another mount kevent before exiting. It should therefore be used in a script like this:



#!/bin/sh

if [ ! -d /Volumes/Backups ]; then
echo "waiting for backup volume..."
/bin/wait4path /Volumes/Backups
fi

# do some backups


Note, however, that if you do this in a crontab job it could potentially wait for a very long time, so you should wrap all that with a /var/run style semaphore.

Friday, May 11, 2007

Official Google Mac Blog: Measuring performance of distributed notifications

Official Google Mac Blog: Measuring performance of distributed notifications on the performance of Google Update: "Just how expensive is it? How many notifications can you broadcast per second? As with all Google client products, we want to be good citizens and not bog down the client machine."



A noble sentiment, but dear Google, answer me this: just how many times per second is each app going to be checking for updates? When does this become an important factor, and not a question of premature optimisation? They decided to go for distributed notifications instead of distributed objects, which seems reasonable - not because of the overhead issues (in fact a DO is probably a lot cheaper, if written properly), but because of the kind of information they're trying to get through this IPC.

Thursday, May 03, 2007

Bye bye data, hello...the same data

Of course it happens to everyone, and yesterday evening it happened to me...my home directory became inaccessible. What seems to have happened is that the filevault image containing my ~ became corrupted upon unmounting (though notably, I didn't do the 'recover space' thing the last time I logged out before the failure, so it should just have been a straightforward unmount). so the simplest recovery route was to delete the user, re-create it then recover my data from the backups. I don't keep backups of the Library area so lost a few preference files, and of course have had to trawl around my email looking for licence keys and the like.


For the moment I've set up the replacement user without Filevault, and am using encrypted disk images for specific data I'd rather keep thus protected. This makes backups harder - I keep my backup drive unencrypted as it doesn't come out with me, so I now need to come up with a script to backup my home dir except for the encrypted images, mount the images and back up the content, then unmount them. This means that the backup will need to be manually triggered so that passwords don't have to be kept anywhere...or I write my own backup tool, which uses passwords stored in a keychain kept outside the target user account; and I need to make sure that keychain is also recoverable ;-).


A lot of my data was completely unaffected - work stuff is typically stored in subversion on their servers (as well as another local copy on my work laptop), my email is all on remote servers, my calendar is served by thaesofereode.info and so on. There are some improvements I could make - I could probably use an LDAP server and abxldap to remotify my contact list, and thaesofereode.info offers subversion hosting which I'm currently not making use of. But it happens that next Tuesday, I'll be talking about data security at the Oxford Mac Users Group, so I will expand on this tale in full and gory detail ;-). St. Cross College, Tuesday 8th May, 7:30 pm.


Update 20070503T1653Z+0000: actually, things look a little more serious than simply a trashed sparseimage:


mabinogi:~/Desktop leeg$ hdiutil attach OmniDazzle-1.0.1.dmg
load_hdi: timed out waiting for driver to load
load_hdi: timed out waiting for driver to load
load_hdi: timed out waiting for driver to load
load_hdi: timed out waiting for driver to load
load_hdi: timed out waiting for driver to load
[...]
2007-05-03 15:41:35.535 diskimages-helper[718] ERROR: unable to load disk image driver - 0xE00002C0/-536870208 - Device not configured.

Good news is that when that gets fixed, my old homedir will start working again. Bad news is: um, it looks fairly messed up to me :-(

Wednesday, April 11, 2007

All the more reason to like FOSDEM

So it seems that my half-attendance at FOSDEM paid off more than I could have hoped, as I won a year's subscription to GNU/Linux magazine. The publication is francophonic, so this will be a good chance to improve my command of la langue des grenouilles ;-).

Thursday, March 15, 2007

Summer of code

GNUstep has been approved for this year's Google Summer of Code. The title link goes to the GNUstep wiki page outlining possible projects, but I'm sure that if a student had another idea you'd be welcome to talk about it on the gnustep-discuss mailing list, and probably get a mentor!

Mail::Box++

When most perl developers (I believe there still are one or two in existence) talk of the "cool one-liner" that they wrote, what they actually mean is that they grabbed a crapload of packages from CPAN, invoked a few use directives and then, finally, could write one line of their own code which happens to invoke a few hundred lines of someone else's code, which they have neither read nor tested.


Modulo testing, my short script (below) to convert mbox mailboxes to maildirs is exactly like that. While it has three lines of meat, these call upon the (from what I can tell, fantastic) Mail::Box module to do the heavy lifting. That package itself is less svelte, with 775 lines of perl. Which is the interface to a C bundle, which is (single-arch) 92k. But never mind, I still wrote a three-liner ;-)



#!/usr/bin/perl -w

use strict;

use Mail::Box::Manager;

@ARGV = ("~/mail", "~/Maildir") unless @ARGV;


# open the existing (mbox) folders
my $mgr = new Mail::Box::Manager;
my ($srcPath, $dstPath) = @ARGV;
# expand tildes and stuff
$srcPath = glob $srcPath;
$dstPath = glob $dstPath;

opendir MBOXDIR, $srcPath or die "couldn't open source path: $!";

foreach my $file (grep !/^\./, readdir MBOXDIR)
{
my $mbox = $mgr->open(folder => "$srcPath/$file",
folderdir => "$srcPath");
# open a maildir to store the result
my $maildir = $mgr->open(folder => "$dstPath/$file",
type => "Mail::Box::Maildir",
access => 'rw',
folderdir => "$dstPath",
create => 1);

$mgr->copyMessage($maildir, $mbox->messages);
}

Monday, February 26, 2007

FOSDEM / GNUstep photos

Just came in on #gnustep. Many photos of the GNUstep booth, dev room and of course the famous GNUstep dinner.

Sunday, February 25, 2007

Apres ca, le FOSDEM

It appears that I'm sat in Terminal B of L'Aeroporte Nationale de Bruxelles, waiting for my flight to board. While there are wirelesses around, the ones to which I can connect seem not to be offering much in the way of DHCP so this update will come in later than it was written (which was at 13:35), as I will probably post it while I'm on the bus between Heathrow and Oxford. [Update: actually not until I got home]



Irrelevancies such as that aside, I had a great FOSDEM! In fact, a great half-FOSDEM, as I did my tourism today. I met a load of people (of which more below), went to some inspiring talks and discussed many exciting and interesting projects (in multiple languages - I spoke to one person in English, Dutch and French sometimes in the same sentence). It was a good exercise to see who wasn't present as much as who was - for instance RedHat didn't have an official presence although the Fedora Project had a booth (next to the CentOS one ;-), similarly Novell (one of the big sponsors) was absent but the OpenSUSE project had Yet Another Small Table. Sun were conspicuously present in that the OpenSolaris and OpenJDK table was being manned seemingly by Sun's salespeople rather than user group members...although maybe that's just my interpretation.



The overriding feeling I got was that the conference was running on l'espirit d'anarchie and that the resulting adrenaline and enthusiasm drove the conference on. The keynote speeches were really the only regimented aspect of FOSDEM - a necessity given the size of the auditorium and that was packed to the rafters with FLOSSers. I didn't go to the final keynote on open-sourcing Java as I was manning the GNUstep booth, but learned a lot on software patents and Free Software and Jim Gettys' description of the technical challenges in creating OLPC was very insightful.



So, GNUstep. GNUstep, GNUstep, Etoile [I'll add the accents in in a later update...this keyboard doesn't have dead keys :-(]. For a start it was great to meet all the other GNUsteppers, and have some good discussions and debates (as well as some good moule frites and Kwak beer). For anyone who doubts that GNUstep is still alive, the dev room at FOSDEM is one place to allay such suspicions with many developers, designers, users and supporters presenting their ideas to each other, asking each other questions and generally contributing to the GNUstep camaraderie. Even an improptu troll by Miguel de Icaza at the GNUstep booth wasn't enough to make us all throw Project Center away and buy a book on C# ;-). Presentations on GNUstep-make v2 (which I've described here before...), the Cairo graphics back-end (which I don't think Fred Kiefer was expecting to present, but made a very fine job of it anyway) and third-party use of GNUstep were all very useful and well-received...I expect today's presentations were too but I didn't get to go to them :-(. [Instead, I was significantly underwhelmed by the sight of the Mannekin Pis.]

Tuesday, February 20, 2007

Fairly cool update to GNUstep

GNUstep-make now supports arbitrary(-ish) filesystem layouts. While the default is still the /usr/GNUstep layout with the various domains, one of the bundled alternatives is to put everything in FHS-compliant locations. Once that hits a release (which I believe will be called gnustep-make 2.0), that should make newbie users and distributors much more comfortable with GNUstep. I also provided a NeXT-ish layout which doesn't clone the NeXT directory hierarchy, but rather mimics it sensitively.

My work laptop just earned itself a reinstall (I'd been uncomfortable with CentOS for a while, but the facts that hotplug isn't configured properly and every time I 'yum update' I have to fix a handful of drivers drove me over the edge), so when I re-create my GNUstep installation I'll do it with the new-style make. I'm currently wavering on the side of installing Midnight BSD, but I might wimp out and dual-boot Ubuntu ;-)

Thursday, February 15, 2007

Where are we going?

Recently, XML seems to have been playing an important role for me...I've been working with various XML-RPC frameworks, reviewing a book on XHTML (actually, a book on HTML 4 which occasionally reminds you to close elements) and also dealing with DocBook. For some reason, this means when I read something like Ten predictions for XML in 2007 I feel like I'm in a position to comment. Don't worry, I don't want to cover all ten points...



If I had to choose one big story for next year, it would be the Atom Publishing Protocol (APP). [...] APP is the first major protocol to be based on Representational State Transfer (REST), the architecture of the Web. Most systems to date have only used a subset of HTTP, usually GET and POST but not PUT or DELETE. Many systems like SOAP and Web-based Distributed Authoring and Versioning (WebDAV) have been actively contradictory to the design of HTTP. APP, by contrast, is working with HTTP rather than against it.


Well, this suits me...a complete bi-directional implementation of HTTP would certainly be pleasant to use. But the point is that you already can do bi-directional transactions with these ugly hack interfaces, which importantly are already in use. This isn't like moving from rcp to HTTP to do your file uploads, this is like moving from HTTP to a version of HTTP which IE doesn't recognise for doing your content publication. WebDAV might be ugly but it already allows people to run their Subversion or calendar (yes, I know...) servers over "the web". APP is good but the activation energy may be too high.



2007 is the make-or-break year for the Semantic Web.

s/make-or-//, I believe. I've talked to two people who considered themselves important in the world of the semantic web, and have attended a talk by Sir Tim on the subject. I still have yet to see anything beyond so-called blue skies proposals and views on how much better the web will be once everyone embraces semantics, which none of them appeared to have done. At least, there's nothing yet which has convinced me that Semantic Web is some kind of killer app, and that what it can do can't already be done with a bit of XML/XSLT and some good schemas. Maybe that's the point, that traditional web will just slide into Semanticism by dint of XQuery, XProc and the rest of the X* bunch. I don't think so.



2007 will be the first year in which almost every significant browser fully supports XSLT 1.0 [...] I predict that this will render many of the debates about HTML 5 and XHTML 2 moot. Sites will publish content in whatever XML vocabulary they like, and provide stylesheets that convert it to HTML for browser display.

Yup, this couldn't come too soon. I sorely hope that HTML 5 will be still-born; redundant as soon as it becomes available. I also hope that document-generating frameworks will become better at generating valid markup in the future (which is at least easier to do with XML than SGML)...of course if browsers really do make a good job of supporting XSLT then they won't really be able to generate invalid markup as they'll be doing it in their own format.



Apple will release Safari 3 along with Leopard. Although it will focus mostly on Apple proprietary extensions, Safari 3 will add support for Scalable Vector Graphics (SVG) for the first time.

That's not much of a prediction, unless predicting things means reading the WebKit changelog. What would be good is for a couple of the more popular also-ran browsers to support MathML (I think Firefox already does in some fashion, WebKit is at the "we're thinking about it" stage, and I really don't know about any others) so that it has a chance of being adopted. I speak here as an ex-physicist who was annoyed at seeing academics putting DVI or PostScript files on the web, or (and this is just as bad if not worse) HTML with graphics of the equations. If LaTeX could be transformed into HTML+MathML and published on the web then we'd be somewhere approaching the original goal of the Nexus.

Wednesday, February 14, 2007

FAQ update

Just a warning about @defs not necessarily being a good idea, some code from Mike Ash to add polish to the forwarding example and...um...I'm sure I added something else. Oh yes, the fact that _cmd is the name of the SEL argument in method definitions.



I'm quite inclined to refactor the FAQ (because the source is basically the XHTML), as something like a DocBook FAQ Article, which might explain any (further) hiatus in updates. I haven't started working on this yet but it seems more attractive, as I look at the horrendous car crash of formatting produced by a combination of different text editors I've been using.

Thursday, February 08, 2007

Why Java is so damned lame, part exp(I*M_PI)

Gah. Back when I used to work for Oxford University, I had to do the occasional bit of Java programming for a WebObjects app. Being quite a bit more familiar with ObjC than with Java, I always found this a bit of a headache...partly the way Java Foundation is semi-bridged with the "real" Java API meant I was constantly referring to my Tiger book (Java in a Nutshell, not Mac OS X Tiger), and partly because ironically Java required a lot more mystical casting voodoo than ObjC...seriously, if I never see the phrase Session session=(Session)session() again, I'll be a happy man.



Today's "gah, why can't Java be as easy as ObjC" moment came courtesy of an algorithmic problem I was attacking at TopCoder, just for the hell of it. Problem is, to get to their problem definitions you have to use their applet thingy, and while I'm there I decided that I may as well type the code into their thingy after all Java's not that bad is it? [They also accept VB, C# and C++ but my recollection of the C++ class syntax is slim and my knowledge of the STL is slimmer...I do know enough to try and avoid it though] So I think their problem definitions are proprietary, but suffice to say I wanted the ability to compare two strings, returning equal if the strings could be made the same by popping any arbitrary number of characters off the front and shifting them onto the back (i.e. treating them like rings of characters).



Well, that's simple isn't it? In ObjC I'd subclass NSString, override isEqual: and Robert is your parent's sibling. I even know how to do that in Java:



class CircularString extends String {
public boolean equals(Object otherObj) {
//....
}
}


Only...no. You're not allowed to do that, because for some unfathomable reason Gosling and the boys at Oak decided to inflict on us another voodoo keyword...final. This seems to have one purpose in existence: to stop me from subclassing the String class. In the words of Points of View, Why oh why oh why oh why?

Tuesday, January 30, 2007

TGD - expanding the field

Some primarily stochastic thought processes which occurred when I tried to apply Richard Dawkin's hypotheses to the Æsir. If your default browsing font doesn't contain a glyph for the ligature, well, tough ;-)


I suppose one of the first things to note is that whereas Xtianity is considered a religion, the Æsir and Vanir (the Norse pantheon) are thought more often as folklore or mythology.[1] In fact, upon reading the Eddas it's easy to have the impression that the sagas of Odin, Thor, Loki and chums have the same qualities as those associated with, for instance, Siegfried (of Das Niebelungenlied fame), King Arthur or Finn MCoul. Essentially, the gods have the air of being erstwhile real blokes (and of course blokesses), who have accumulated stories, feats and powers as people seek to glorify them, in order that when they later claim to be descended from same they can hope to persuade people of the existence of said powers.[2]



What I find interesting is that the only difference between a quirky set of historically interesting tales and gospel truth is how many people believe in what's said. For instance, it would be easy to apply the same distinction above between religion and folklore to the Roman pantheon, which equally was a major European religion relegated to providing saints and fables once Constantine got splashed in the font. Of course, to do so would be to ignore that there were multiple pre-Christian religions in the Roman Empire. Not merely in the same way that the Norse posh nobs worshipped Odin and the thains worshipped Thor, there were actually completely different mythological universes. I'm going to choose one, completely at random.



Between the second century BC and fourth (maybe fifth) century AD, a particular popular mythos in the Empire was Mithrainism.[3] If there are any modern Mithraists, I don't know about it. Which is not surprising, considering how wacky their religion was. [Update: apparently some Zoroastrians still venerate Mithras.]



Mithras was supposed to have been born around 270BC to a virgin Mother of God (the date of the celebration of his birth was December 25th). He was worshipped as a member of a trinity, as the mediating force between the heaven and earth. In fact, heaven was not only the celestial abode of God but also the place where atoned souls would go when they died, the true believers being absolved of their earthly sins. Those less fortunate were condemned to an infernal hell. Initiates (ceremonies were closed affairs, available only to men who had performed the appropriate rites) were baptised, and Sundays were a sacred time when the Mithraists ate bread, representing the body of their God, and drank wine, representing his blood; these were symbolic of the final supper he shared with his followers before ascending to heaven in about the 64th year of his life. Along with Odin and Osiris, he is supposed to have died and been resurrected before his final ascension.



You'd never get away with that rubbish these days, which is why this is clearly a deluded heathen folk tale as opposed to, um. You can clearly see why Dawkins didn't talk about this one in TGD...



[1] Actually, there is a religion with such a pantheon, called the Ásatrú - the word is Icelandic for Æsir faith. Despite widespread confusion, none of the major organisations of this faith are actually neo-Nazis or supremacy groups.


[2] I suppose this makes Finn and Aragorn the same being.


[3] Just through etymology I am reminded that I haven't yet covered Jainism. I need to.

Monday, January 29, 2007

That syncing feeling

So, ITunes tells me my iPod is up-to-date, and that it won't copy a few songs to my iPod because the iPod software needs updating first. The word which springs to mind is "erk".

Friday, January 26, 2007

Scary stuff

Possibly the scariest diagram anyone will ever have to look at. It's even less penetrable than that Eric Levenez history of unix thing.

Sacrilege!

As I wrote the @interface to an object today, I found myself wanting for but one thing:



- (NSArray <MyProtocol> *) foo;

Where - as if you hadn't guessed it - the pointy bracket bit (the lengths to which I go to avoid typing out HTML entity names) would specify that all of the objects in the array returned by -foo conform to @protocol(MyProtocol). I then realised that this wouldn't be quite as useful as I might think, but also decided that it wouldn't be too hard even on the existing ObjC runtimes to come up with a nightmare function such as:



(Protocol *) objc_class_to_protocol(Class *cls);

...therefore meaning that my hitherto unattainable pipe dream:



- (NSArray <MythicalNSStringProtocol> *) foo;

may indeed be somewhat closer to realisability. Of course, with all of this being compile-time type checking (as with the similar beasties on Java) there would be no need to frob the runtime.



Update 2007-01-26T13:22: yes, I realise that the snippits above read "an NSArray or subclass, which also conforms to the MyProtocol protocol". I also know what I mean.

Friday, January 12, 2007

Eating one's own dog food

I feel foolish for having made this error (especially after having so patiently explained how this stuff works on Mach), but today I did it. I reported the amount of free memory on a Linux system as being the amount reported by free as free.


My own opinion on this is that I suffer from a view of hardware management which was tainted by using micros like the Dragon 32 (Radio Shack/Tandy TRS-80 to my American readers) and the Amiga, where there were basically two types of memory usage: yes and no. A particular block was either in use by the system, or it wasn't. On the Dragon 32 it was even easier than that of course; all bytes were available for reading and writing, but what happened was context-dependent. Also because this was the MC6809E, whether such a peek/poke made sense depended on whether you were trying to hit an I/O address, and what was plugged in. The Amiga had a particularly lame memory allocator which quickly sucked performance like a vacuum of performance suckage +2; but a byte of RAM was either in use or it was available.


But I digress. The point is, that such a simple view of memory availability is no longer sensible but it's hard for me to think around it without a lot of work, just as it was hard for me to become a programmer after I'd been taught BASIC and Pascal. If I were involved in UNIX internals more (and indeed that would be fun, although I think maybe Linux wouldn't be my first choice to open up) I'd probably be able to think about these things properly, just as I had to throw myself into C programming in a big way before I lost my BASIC-isms.


For the record (and so that it looks like this post is going somewhere), both operating systems have an intermediate state for RAM to be in between "used" and "not used" (where I'm ignoring kernel wired memory, and Linux kernel buffers). On Mach, there's the "inactive" state which I've already described at el linko above. On Linux, it's used as an I/O cache for (mainly disk, mainly read-ahead) operations. This means that Linux will automatically take almost all (if not all) of the memory during the boot process. The way that inactive memory gets populated on Mach means that on that system (e.g. Darwin) actually the amount of free memory starts large and inactive starts small, but over time as the active and inactive counts go up, the free count goes down, and it's rare for memory to be re-freed. On both systems, free memory is really "memory it wasn't worth you buying" as it's not being put to any use at all.

Monday, December 18, 2006

客観的なc計算機言語

Just heard from someone who wants to translate the c.l.o-c FAQ into Japanese. Sweet!

Monday, December 11, 2006

Copyleft

It is complete:



I no longer even own all the code I write in my spare time, on my own equipment.  :-)

Thursday, December 07, 2006

TGD - John on acid

I'm about halfway through my OmniOutliner document of notes made while reading TGD now....


There's a paraphrase in TGD saying that if the epistles of Saint John the Apostle represent John on pot, then the book of Revelation is "John on acid". What makes this observation more interesting is that it may be literally true - or at least closer to the mark than the quip may at first appear.


There was a documentary by Tony Robinson on Revelation and the End of Days, called The Doomsday Code. The - frankly worrying - sentiments of some of the extreme christian right in America are the same as described in TGD; namely that the Middle East instability [inclusive] or global warming or the 2005 hurricane season herald the proximity of the rapture, and that rather than doing anything to help those caught up in these situations we should be actively encouraging the Apocalypse, and xtians should let their heathen friends know that, well, they told us so. In the course of describing modern End Timers, the documentary showed us where Revelation was penned.


There are tens of apocalyptic visions penned by post-Christ Jewish theologians, but only one has been included in what is now termed the canon of the New Testament. That book of the revelation of Jesus Christ to his disciple, John (which isn't accepted by the Eastern Orthodox as part of the divine liturgy) was written on the Greek island of Patmos sometime in the second half of the first Common Era century, and details two visions experienced by the John of the title (whether or not he be apostolic) while on the island. The other key fact to remember about Patmos is the abundance of fly agaric mushrooms, especially around the mouth of the cave of revelation.

TGD - begging the question

Many of the arguments pro-religious belief presented in TGD would form a nice corpus in a dictionary of critical analysis for the entry on "begging the question". However, Prof. Dawkins studiously avoids the phrase despite its rampant, repeated and some would say wanton applicability, and if I were ever asked to predict why (I haven't been, I just like the sound of my keyboard) I'd say that it's because the phrase is so frequently misused on both sides of the Atlantic ocean.


Indeed, when I was taught the phrase, the example I was given is that of proof of the existence of god: we can see the results of god's creation all around, therefore god created them, therefore god exists. That's about as short - and absurd - an example of the technique as can be demonstrated. In ordinary speech, people use the phrase "begging the question" to mean: the argument I have just heard is incomplete or fallacious, because it appears not to answer (or to directly raise) the following problem. Where the problem was not explicitly part of the argument. However, the meaning of the word "beg" should not be overlooked, and is key when calling an argument out as one that begs the question. In fact, it isn't the argument that begs the question: it's the conclusion which does so, and the conclusion is begged from the question. In other words, the meaning of the phrase is that an argument draws to a conclusion which already existed in its assumptions or axioms. My Latin isn't very good, but I might describe this kind of argument as QEQ - Said that which was said.


Let's look at, for example, the argument for the existence of purgatory (it's quite near the end of TGD which makes it easy for me to remember). The conclusion is that purgatory exists, and the justification is that people everywhere are praying for the souls of the dead because they believe that the souls are in purgatory, and surely prayer isn't pointless. I hope that going all slanty made the point in the argument where the conclusion was codified apparent - the reason we can be sure that purgatory exists because we are sure that purgatory exists. QEQ.


I realise that this had little to do with the thesis of TGD, but to beg the question is a cool phrase which should be used less, but with higher accuracy.

Tuesday, December 05, 2006

TGD - I'm not dead yet!

The title of this article is a quote from Monty Python and the Holy Grail - the body cart comes around the town to collect up the (presumably leprous) corpses, and along comes John Cleese with his ninepence and his cadaver. The only problem is that actually the corpse feels rather like he might pull through.


This is a situation which relates to the ever-decreasing sphere in which divine intervention can be invoked, such reduction being due to scientific advances. There are known cases where people have been thought dead and have "got better", or have been ruled out a long time before the actual event of their dying. As an example, a death through epilepsy can often cause the unfortunate to become unresponsive long before becoming dead, so that 'miraculous' events such as the body remaining warm for days after the death are recorded. While the meaning of the term "dead ringer" has nothing to do with the 19th Century safety coffin, such devices did exist. The whole purpose behind holding a wake was the hope that life might return to the deceased - because sometimes it did. Various poisons can lead to the body attaining a death-like state, while in fact the subject remains living; perhaps the most famous of these is TTX (the toxin carried by pufferfish); supposedly used by Vodou practitioners to create zombies. A good explanation of that is Ghosts, Vampires and Zombies: Cinema Fiction vs Physics Reality. The case of Wilfred Doricent, described in the arXiv paper, is recent: he died in March 1988 and was no longer displaying many of the symptoms of death by September 1989.


The point here is that there are modern cases where death is misdiagnosed. Given the modern equipment, techniques and advances in both theoretical and practical knowledge, one would assume that the rate of misdiagnosis of death has decreased over time (and in a related vein, the number of conditions which terminate terminally has decreased, too). How can we know, without even contemporary doctors' notes, whether a particular resurrection event was miraculous or just a case of mistaken interment? Pufferfish aren't particularly common around the middle East so perhaps Lazarus wasn't eating fugu but he may have had epilepsy, tetanus or a number of other conditions which were confused with fatality.


Returning to the parenthesis on terminal conditions, above, one can argue by progression that if there are fewer "terminal" conditions now in (kindof) 2000 than there were in 1800, then assuming no catastrophic dark age reversion there will be even fewer in 2200, fewer still in 2400 and so forth. So the ability to "miraculously" recover from a terminal condition should decrease over time too; not because the rate of miracles is decreasing but because the ability to explain the circumstances is increasing.

TGD - religion leaving the gene pool

If there was some kind of selection pressure which favoured, even in a roundabout way, predisposition toward religion, and if sexual selection naturally favours successful people (or those who exude success, anyway), then we have a (not too serious) quandary. Because the most high-profile adherents, the most apparently successful at religion, are often the clerics. Who are frequently celibate (or at least, are required to be: please do read the dictionary definition for nepotism though).

TGD Responses - selection for religion?

I'm going to do a few articles based on The God Delusion by Richard Dawkins. As this is a bit of a departure from the usual content of yon blog, I'll be sure to prefix the titles of each with TGD so that those so inclined can filter for/against them in their syndication readers. The articles will be a mixture of prose agreeing with parts of the book, arguing against parts, questions which the book made me ponder and for which I have no answer, and quips (I haven't yet decided whether to group these together or allow a post for each) answering specific ideas or even sentences. My only hope is that all of the articles - and the processes leading to their inception - are critical, in what I hope is the obvious intention of that word. Needless to say, I'll leave the punchline - my opinion of the binding theme of TGD and any changes it has had or not had on my views - until the final article.



I'll start this series by looking at his idea of religion having its roots in a "misfiring" of some advantageous trait which has been selected for. I would ask this question: why should that be so? In his description of evolution he explains the idea of a neutral mutation — one which overall has no positive nor negative effect on the fitness of the genome, but which can nevertheless become dominant (or at least prevalent). For instance, human earlobes either join at the bottom of the lobe to the face or they do not. I don't understand there to be any fitness advantage in either, yet at some time the allele(s) associated with earlobe stuck-to-facedness have, I presume, diverged from a common variant. Why couldn't theism be just one type of earlobe? What if the mean fitness of religious nonreligious "phenotypes" (I expect that's the wrong word…perhaps theotype is better) are not significantly different, and religious behaviour just happens to arise and have become common? I suppose there may be an answer to this, although if there is it wasn't presented in TGD.



There is a related argument in the book which I don't buy. In dismissing the idea of a straightforward selection pressure for evolution, Prof. Dawkins presents the Gedankenexperiment of a tribe who worship a war god, and whose religion dictates that they should go and fight the neighbouring tribes, in the course of which they acquire of course the resources of those other tribes, and propagate their seed further. The argument presented against this is that for any one individual it is more efficient to hang back while their companions do all the fighting, then to share a part in the spoils. Therefore the society would collapse, as no-one would want to do any fighting. This rather squarely misses the point of, for example Freya's D.Phil. thesis and the concept that a population based on cooperation (in this case the war-tribe, in Freya's case a biofilm) can in fact tolerate some fraction of "cheats" and that there is a stable state where proportion of cheats is non-zero but the population still thrives. Consider the British benefit system — some non-zero amount of money is spent on targeting benefit fraud, which keeps the fraud not at zero but at some level which both can be afforded and which leaves the spending justified. In fact, a canny war-tribe member would try to weasel their way out of the line of combat by arguing (rightly or otherwise) that they alone have some property that the average combatant does not possess, and would refer to the weaseling as "promotion" or officership.



Another potential explanation is an interpretation from Terry Pratchett, Jack Cohen and Ian Stewart's Science of Discworld series. In it, they describe the idea of "lies-to-children" in which various layers of falsehood are peeled back as a child becomes ready to accept the more complex, yet more accurate, explanations. What if this idea is extended to become lies-to-protoscientists? What if, as well as a moral Zeitgeist, there is a consensus of acceptable sophistication? So a society initially agrees that each tree, waterfall, star, planet etc. must have its own god, then finds that it can accept the god-of-concept ideas of the more recent polytheistic disciplines, then agrees that a single god, while more complex a solution, is palatable, all the while science is also working to provide the ultimate in sophisticated solutions: that which is born out of simple concepts, but which can be applied to give predictable and verifiable results.

Wednesday, November 29, 2006

e[Mac]s keyboard

It's about time someone made a UNIX keyboard for the Mac. I still love my Tactile Pro, and have obviously configured the caps lock key as an additional Control, but that key doesn't feel like the same buckling spring as the rest so it feels weird when I hit it. I just wonder now whether someone's going to make a keyboard with a Command key up there. Probably not, they never did for either the earlier Macs or the NeXT. It would be handy to be able to do cut/copy/paste without having to buckle my thumb or little finger under my hand...Matias' Optimise keyboard looks like it might be efficient but have a confusion curve.

Friday, November 17, 2006

Blasty from the pasty

Yesterday I had a little problem with the iBook, which was saved by some age-old knowledge from before the OS X release. Almost.



When I use an external USB mouse, I disable the internal trackpad. Now I wanted to take the computer into a different room in order to watch some TV (on the EyeTV), so unplugged all the USB stuff, plugged the EyeTV in....and the trackpad was still disabled. Now, a lesser person would have gone back into the original room, plugged the USB mouse in, and used it (or taken it with them). An equally lesser, but richer, person would own a Bluetooth mouse. But not I! I remembered a trick from the NeXT days, and returned my computer to trackpad-workingness in but a jiffy. Three jiffies.



The first thing to do is to log out - "as any fule kno" this is done from the keyboard by Command-Option-Shift-Q. At the loginwindow there still wasn't any trackpad activity, so I thought restarting the WindowServer might fix that. This is done by entering ">exit" as the username in loginwindow. Sadly, no joy. My next thought was to drop to a text console, unload the trackpad's driver kext, reload it and see what difference that made. Doing so requires entering ">console" as the username. However I decided not to pursue this as >console has been sadly broken throughout 10.4, and on some systems was broken in 10.3 too. It's annoying as occasional glitches where the graphical environment is FUBARed could probably be fixed in console mode. But this left one course of action. Enter ">restart" in the loginwindow and wait...



I should probably point out that I waited for the reboot longer than it would have taken to retrieve the mouse. But at least I wasn't defeated.

Wednesday, November 08, 2006

One reason multiple inheritance sucks

So I'm reviewing a book, and it happens to cover the way method lookups are performed in a particular language's object model. I'm not going to say what the book is because it's not relevant, and nothing discussed here has anything to do with that publication. But reading it made me realise just why even when the language allows it, my internal pain aversion system will always skip multiple inheritance as an option. Consider this Python code (with built-in python shell promptness):




>>> class One(object):
... def doStuff(self):
... print "One.doStuff()"
...
>>> class Two(One):
... pass
...
>>> class Three(One):
... def doStuff(self,x):
... print "Three.doStuff(%d)" % x
...
>>> class Four(Two,Three):
... pass
...
>>> class Five(Three,Two):
... pass
...
>>> a=Four()
>>> b=Five()


so, what is the method signature of a.doStuff() and b.doStuff()? Well, it depends entirely on the order in which the class hierarchy gets inspected, Python does things by leftright-bottomtop so both a and b inherit Three.doStuff(self,x). In the case of a, Four doesn't have doStuff() so it looks at Two, which doesn't so it looks at Three and finds it. However, Python also has another lookup mechanism (which was the only one available pre-2.3 or possibly 2.4, and can still be triggered by omitting the "object" superclass from One) which is left-bottomtop-right, so a inherits One's doStuff() and b inherits Three's. In the words of Peter Cook, that could confuse a stupid person...



So luckily Objective-C avoids this problem by only having an inheritance tree, and we can't add method implementations via protocols either. And my specific example is moot, because -doStuff and -doStuff: are different selectors.

Friday, November 03, 2006

if ([self isKindOfClass:[whore class]]) [self promote];

Bottom of the page, under Media Reviews. I've got another couple of review copies sat here, too...