Structure and Interpretation of Computer Programmers

I make it easier and faster for you to write high-quality software.

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
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.

posted by Graham Lee at 10:53  

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.

posted by Graham Lee at 23:35  

Thursday, March 6, 2008

My discs have been Americanised!


p>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!

posted by Graham Lee at 21:45  

Powered by WordPress