• Dumb Money

    I love this phrase. Dumb Money. As in:

    a lot of “dumb money” will be pumped into the MMOG market by investors hoping to cash in on the next big thing…

    The next time I have the chance to berate some obviously stupid business idea, I can just say “dumb money”. Schweet.

    (The quote’s from a short news article by Inside Mac Games, if you’re really interested.)

  • Los Angeles and New York

    After the inspiration and buzz experienced at WWDC in San Francisco, chilling out in Los Angeles and New York was a welcome (and much needed) change! I stayed with my cousins in Beverly Hills in Los Angeles, and was thus exposed to the privileged, the luxurious, and the affluent. I’m not exaggerating when I say that practically every car you see is a Lexus, Mercedes, BMW, Porsche, Ferrari, Maserati, Bentley, Lamborghini, or something equally upmarket, expensive, and very sexy. Even the humble Ben Sherman’s presence in the Beverly Center is quite a bit more styled than what you would find in Sydney. I had a taste of the Ermenegildo Zegna and Prada stores along Rodeo Drive and Beverly Drive, the former of which had a beautiful suede jacket for the mere price of USD$4600. Driving up Coldwater Canyon in Bel Air revealed enormous houses, each of which is at least as majestic as the biggest properties in Rose Bay and Bellevue Hill in Sydney; all of them are replete with lush gardens and fountains that they look like miniature ecosystems from the outside. It’s another world over there.

    So, Los Angeles turned out to be a wonderful unreality of luxury, and seeing my cousins and family again after the intense week of San Francisco was great! I did my usual shopping rounds, dropping by Banana Republic, Borders, Barnes and Nobles, Club Monaco, Baby Gap (for my two cute nephews, not me!), Fry’s Electronics, the Apple Store, Best Buy, and more. Thanks to me being in holiday mode, I am now the proud owner of:

    … amongst other goodies that I probably shouldn’t reveal in public. (No, nothing from Victoria’s Secret…)

    The one thing that struck me on this trip was the sheer amount of stuff the USA offers, from clothes to gadgets to media content. Australia certainly offers a reasonable amount of variety and choice in its shops, but it’s nothing compared to the USA. You are simply overwhelmed the first time you walk into a Borders that occupies the entire building; it’s six floors full of nothing but books. I looked around for a long time in Australia for a book on the history of mathematics and found one or two; in a single Borders or Barnes and Nobles in the USA, I was spoiled for choice, having found no less than a dozen at every store. Fry’s Electronics features more than sixty cash register checkouts; the CDs at Amoeba Music in San Francisco has shelves and shelves of just movie soundtracks, and it’s mind-boggling to browse just the TV Shows section of any large store that sells DVDs and wonder where the section actually ends. Every satellite city in Los Angeles will have a mammoth shopping centre bristling with mini-economies, and every block in New York will be home to one or two major brand label stores, stacked full of Yet More Stuff.

    And then, of course, there’s the crazy-go-nuts 24-hour Apple Store in New York, which I visited with Isaac at the excellent time of 1am. The culture that Apple have managed to create at this place is amazing: the store was full at 1am. It wasn’t like a can of sardines, but it was full enough that almost every single iPod, MacBook and iMac stand was being used by someone, and you had to avoid bumping into other people when you were browsing the shelves. I’m sure the live DJ playing reasonable dance music was part of the reason people flocked to the store at 1am, but there were also a ton of people who were just there sitting around just to be there and wanting to be seen there (in somewhat typical New York fashion). The Genius Bar, where people go to for support and service, really is like a bar: people sit down and start chatting up their neighbour, and since there’s no beer in the way, it actually is easier to start conversations with strangers. It’s all a slightly surreal experience if you haven’t been there before. (I was most amazed that I actually left there without buying a single thing…)

    Outside of shopping, that week was time well spent indeed: I got to catch up with my cousins in Los Angeles very well (though spending three days there was far from enough), and my time in New York staying with Manuel and Gabi was wonderful: I managed to catch up with them a lot, found some to finish some projects I’ve had in the works for months since I finally had some time to myself, caught up with a few other friends in the two cities, and even babysat for them for the first time ever so they could have a night off. One highlight of the trip was visiting the absolutely spectacular New York City Museum of Natural History, which I highly recommend for any visitors: you could spend more than two days in there, and it’s one of those shrines that has been constructed with such thought and love that it really does inspire you to become a marine biologist, astronaut or geologist. In a time when the world is increasingly perceiving the USA as a country that’s somewhat fallen from grace, the Museum is a smiling reminder that the United States has also contributed so greatly to the advance of science and human civilisation.

    As a small aside, I find it quite interesting that all the progressive cities and states tend to reside on the coast of the USA, with the inland states all being conservative (sometimes to a rather scary extent). Apparently the coastal folks like to distinguish between “America” and “Central America”. I dunno, maybe seeing chicks in bikinis swimming at oceanic beaches makes people more progressive or something. That sounds all good to me.

    So now I’m back in the land of take-away instead of to-gos; back in a land where you can actually distinguish a $50 from a $5 by its colour (thank God), and back in a land where I can walk into most coffee shops and expect a good coffee instead of hunting around for Illy logos. The R&R in Los Angeles and New York has been wonderful, and a great wind-down to an intense week in San Francisco. I’m looking forward to getting back to reality and normality now that I’ve had my fair share of excessive consumerism and opulence!

    (Go to my WWDC 2006 gallery to find all my photos from Los Angeles and New York).

    Los Angeles to New York Playlist

    • Zauron: Lovelight
    • Thievery Corporation: Marching The Hate Machines Into The Sun (Featuring The Flaming Lips)
    • Way Out West: Mindcircus
    • Queens Of The Stone Age: No one knows (U.N.K.L.E. reconstruction)
    • Necros: Orchard Street
    • Chuck Biscuits: Outlands
    • Chicane: Overture
    • Tool: Parabol
    • Tool: Parabola
    • Underworld: Pearl’s Girl
    • Cass and Slide: Perception (New Vocal Mix)
    • Layo and Bushwacka!: Ladies & Gentlemen
    • Baby D: Let Me Be Your Fantasy
    • Radiohead: Karma Police
    • Bedrock: Heaven Scent
    • Faithless: God Is A DJ
    • Tool: Forty Six and Two
    • Badmarsh & Shri: Day By Day
    • Sunscreem: Change (Angelic Remix)
    • New Order: Blue Monday (Hardfloor mix edit)
    • The Seatbelts: Butterfly
    • Massive Attack: A Prayer For England
    • Itch-E & Scratch-E: Transit
    • Vision 4/5: Stormtrooper
  • Everybody Loves Eric Raymond

    A web comic about everybody’s favourite open-source evangelists: Richard Stallman, Linus Torvalds, and, of course, Eric Raymond. (Occasionally even starring John Dvorak).

    (Kudos to Chuck for the heads-up.)

  • Sexlessness in Movies

    David Poland writes about the lack of sex in recent movies:

    The Devil Wear Prada is the poster child for the sexlessness of Summer 2006. Here is a movie about women who want are obsessed with their bodies, about men who are obsessed with these women, and the things people do under stress. Directed by a Sex & The City director, starring the rare lead actress who isn’t shy about showing her stuff, who is “living with” Entourage’s Adrian Grenier, who still ends up sleeping with Simon Baker in ParisÖ and yet the film is a chaste as Monster House (less than Monster House in 3D).

    Note to USA censors: hey you guys, how about you introduce this brilliant new idea named having an MA-15 rating, so you don’t have to tone down the fun stuff so much that you’re forcing your movie to be PG-13?

    (To all the anti-censorship zealots out there, please don’t take this as a statement that I’m in favour of legally restricted censorship.)

  • How to Coordinate a War

    If you had to run a war and wished to communicate something to your generals, why not just use PowerPoint slides with bullet points? It does save you from writing all those pesky “report” things, after all.

  • WWDC 2006

    Right, I believe I have found a no-frills formula for how to make your body think it’s going to self-destruct in an imminent fashion:

    1. Attend Apple’s World Wide Developer Conference (WWDC) thing
    2. Attempt to socialise and meet up with as many people as possible
    3. Attempt to keep up with all the latest and greatest tech news and world news whilst at WWDC
    4. Have three to four coffees per day thanks to the surprisingly excellent (and free) espresso service at WWDC
    5. Combine said three or four coffees per day with beer, wine, and beer (in that order — yes, ouch, me dumb dumb) at night.
    6. After having coffee, coffee, coffee, beer, wine, and beer, we then attempt to stay up at night to:
      • catch up on the deluge of urgent email (as opposed to merely the important emails, which I can deal with later),
      • install beta Apple operating systems,
      • attempt to actually do some coding (ha ha ha),
      • catch up with the folks back home, and
      • rip those 15 new CDs you bought at Amoeba records to your bling iPod (fo sheezy, yo)
    7. Repeat everything the next day

    It has been a full-on week indeed. This is the third World Wide Developer Conference that I’ve attended, and it’s by far the best one I’ve been to so far. It was interesting seeing the Internet’s lukewarm response to Steve Jobs’s keynote on Monday morning, although the excellent Presentation Zen site gave it some credit. As the Macintosh developers who attended the conference know, there’s actually a monstrous number of changes under the hood not spoken of in Jobs’s keynote that are really cool (which would be all that “top secret” stuff in the keynote); Mac OS X is truly coming into its own, both as a user experience and a developer’s haven. Apple’s confidence is starting to shine; let’s just hope that it doesn’t turn into arrogance. (I’m praying that Windows Vista doesn’t suck too much and actually gives Mac OS X some serious competition.)

    And, of course, it wasn’t just the daytime that providing intellectual nourishment: I met up and chatted to dozens of people outside the conference, from successful Mac shareware developers, to low-level Darwin guys, folks from the LLVM and gcc compiler teams, other Australian students from the AUC, passionate open-source developers, visual effects industry folks, a ton of Apple engineers, oldskool NeXTSTEP folks, and even second cousins.

    While the food at WWDC wasn’t particularly stellar this year, they did have a ton of these things:

    Yeah baby, bananas! $12/kg back at home? How about take-as-many-as-you-frigging-stuff-into-your-backpack over here. I’m sure it was the Australians that were responsible for the entire table of bananas vanishing in around 90 seconds. (Not to mention the free Ghirardelli chocholate :).

    There was something to keep me occupied every night of the week: even before WWDC started, there were Australia and New Zealand drinks organised on Sunday night, where I met up with a huge host of other Australian students and professional developers (some of whom got really, really drunk, and weren’t representing Australiasia particularly well in the international arena, I might add). On Monday I headed out to have the best burritos ever at La Taqueria on 25th and Mission with Dominic and Zoe, headed to the Apple Store and Virgin Megastore (oh dear Lord they are such evil shops to have in such near proximity to the conference centre), and met up with the one and only Chuck Biscuits from my old demogroup along with the Darbat crew to catch up on old times. Tuesday and Wednesday night was spent heading to dinner with some fellow RapidWeaver developers that featured some bloody good steak, and Thursday was the big-ass Apple Campus Bash, where I had wine, bananas and chocolate for dinner, and then proceeded to raid the Apple Mothership Store of far too many goods. (Put it this way: I travelled to the USA with one half-full bag, and now, uhh, I have two bags that are kinda full… oops.)

    During the week I ended up discovering the totally awesome Samovar Tea Lounge in the Yerba Buena gardens thanks to Isaiah, where I not only had some Monkey Picked Iron Goddess of Mercy tea (seriously, how freakin’ awesome is that name?), but also snarfed up a handful of Scharffen Berger chocolate. (Hey RSR/RSP folks back home, have you guys finished those damn chocolate blocks on my office desk yet? Of course you have!) Amit Singh of Mac OS X Internals fame was also at the Apple Store at Thursday lunchtime giving a talk about his excellent 3kg 1600-page book, which I briefly attended before deciding that an afternoon of live true American jazz with Dominic was a much more tasty option on the platter.

    And, just as I thought the outings were about to calm down when the conference finished on Friday at midday, I end up meeting a like-minded video metadata fellow in the lobby of the W Hotel San Francisco of all places (swanky as hell lobby, by the way), and ended up hanging out of a cablecar on the way to Fisherman’s Wharf and Ghirardelli Square, where a bunch of NeXTSTEP folks were having dinner. I seriously don’t understand how my body’s managed to cope with all the activity so far. But hey, at least I managed to avoid San Francisco’s rather dodgy Tenderloin district (warning: highly amusing but possibly offensive image on that page) :).

    So, now that the week’s over, I currently have 31 draft emails that I need to finish writing: time to get cracking (sorry friends and enemies, I’ll get to you shortly!). Of course, clever me managed to get an entire hour of sleep before heading off to SFO airport for the next stop in my trip: Los Angeles. Stay tuned, same bat time, same bat channel…

  • Battlestar Galactica Soundtrack

    Holy crap, this is excellent music. It’s up there with Yoko Kanno’s fantastic work for Cowboy Bebop and Ghost in the Shell: Standalone Complex, and as interesting as Cliff Martinez’s movie soundtracks for Solaris, Narc, and others. No cheesy John Williams stuff here. (Seriously, the themes from Star Wars, Superman and Indiana Jones could all blend into each other and you just wouldn’t notice.)

    The Battlestar Galactica soundtrack has also made me fall in love with baroque music again. Oooh, those sweet sweet violas and reeds…

  • Ejecting a stuck CD

    If your CD won’t eject from your Mac (for example, say, if you’re running the Leopard developer preview and the stupid mdimport process is locking files inappropriately…), the good ol’ -f (force) flag on umount will be your saviour:

    • sudo umount -f /Volumes/"AUDIO CD" (or whatever the volume name is)
    • Press the Eject key
  • Welcome to UTC -7

    Ah, Berkeley: the quintessential American student town, where the young gather on the road’s median strip to sit on the grass (in cheery violation of the “Keep off the median strip” signs). Berkeley’s also home to Dominic and Zoe Glynn, my dear friends who I haven’t seen in far too long and have had an excellent time re-acquanting myself with again. It’s been a perfect warmup to the intense and crazy week that will be the Apple World Wide Developer Conference.

    So, Friday was spent re-exploring Berkeley with Dom: for those who remember, I was here at the start of 2004, and it brought back good, good memories seeing the University of California at Berkeley, and the intersection of Bancroft Ave and Telegraph where all the froody 60s peace-out stalls are. Mahreen, if you’re reading this, you’ll be pleased to know that everything was pretty much exactly like we remember, except it’s a bit warmer right now!

    After grabbing some lunch at Saul’s where I was reintroduced to American-size portions in the form of a West End Massive Corned Beef Sandwich, we stopped by the very dangerous and evil Amoeba records on Trafalgar, where I picked up no less than 15 CDs:

    • Propellerheads: Propellerheads (the prequel to Decksanddrumsandrockandroll: a collector’s item, and I got it for an entire $1)
    • Propellerheads: Spybreak!
    • Sasha and John Digweed: Communicate
    • James Lavelle: Fabriclive 01
    • Future Sound of London: Lifeforms EP
    • Future Sound of London: Lifeforms
    • Photek: Modus Operandi
    • Rˆyksopp: Melody A.M.
    • Thievery Corporation: Babylon Rewound
    • Monk and Canatella: Do Community Service
    • Lamb: Remixed
    • DJ Shadow: Preemptive Strike
    • U.N.K.L.E.: Never Never Land
    • Battlestar Galactica Season 1 soundtrack
    • Battlestar Galactica Season 2 soundtrack

    See, despite spending $150, I actually ended up saving money because for the price of those fifteen CDs, I could have bought a mere five CDs back at home. YA RLY! Hey music industry: price your stuff reasonably and people will buy them! Screw this $35 for an album crap back in Australia; I quite like the $8 I pay for a CD at Amoeba. I should add that I only looked at the Electronica section too; the damage to Dinga would have been far worse if I had bothered to wander through the House section, not to mention all the DVDs.

    For dinner, we dropped in to none other than Pho Hoa, the famous Vietnamese Pho Bo shop on Shattuck St. Mahreen, no doubt your memory will be triggered by this as well: you’ll be pleased to know that I did, in fact, get the crazy-big serve of Pho Bo and finished all of it, and I of course had to have some Taro Bubble Tea. After that it was time for some beer and a good catch-up chat with Zoe and her cousin Andrew, which ended up going until about 5:30am when we all reluctantly crashed.

    Saturday was even better: we had a cruisy late morning double-falafel for breakfast at the Fertile Grounds cafe in conjunction with some genuine Illy coffee. This was followed by an afternoon consisting of insanely great Cheeseboard Pizza, white wine, and hours of conversation up at Indian Rock, which provides a beautiful scenic view of Berkeley and the Bay Area. I love summer.

    Meanwhile, Dom and Zoe’s place here rocks. The rent they’re paying is unbelievable good considering how nice the place is, and they even have the same comfortable futon that I slept on while I was staying with them in Toronto. Dom’s love for gadgetry shows: their Robot vacuum cleaner means they never bother vacuuming the house normally, and their little Prius automobile is awesome. I am so getting one of those as my next car: any car that has a Power button, voice recognise for GPS and telephone dialling, and does 5 litres per 100 kilometres has my vote.

    Later today I’ll be meeting up with Yannis and Violette for Yum Cha, and after that it’ll be time to check in to the Courtyard Marriott at San Francisco, where I’ll be heading off to the Australia and New Zealand pre-WWDC drinks. Oh yeah, life is good right now!

    (You can find all the photos from the first few days of my Berkeley expedition in the gallery.)

    Sydney to San Francisco and Berkeley Playlist

    • James Brown: Ain’t it Funky Now
    • Massive Attack: Angel
    • Seal: Crazy
    • Rˆyksopp: Eple
    • Tears for Fears: Everybody Wants to Rule the World
    • U.N.K.L.E.: Lonely Soul
    • Tool: Stinkfist
    • Yoko Kanno: Fish-Silent Cruise Part 2
    • The Wallflowers: One Headlight
    • U2: All I Want Is You
    • Vogue: Ambient Energy
    • Freeland: Big Wednesday
    • Yoko Kanno, The Seatbelts and Steve Conte: Call Me Call Me
    • Faithless: Bring my Family Back
    • Propellerheads: Cominagetcha
    • Sunscreem: Cover Me (Trouser Enthusiasts mix)
    • Yoko Kanno: Dujurido
    • Decoder Ring: Escape Pod
    • Tool: Eulogy
    • Jazzanova: Fedimes Flight (Kyoto Jazz Massive remix)
    • Starsailor: Four to the Floor (Thin White Duke mix)
    • Lamb: Gabriel
    • Handel: Lascia Ch’io Pianga (performed by Single Gun Theory)
    • Cliff Martinez: Helicopter
    • Mono: Hello Cleveland!
    • Radiohead: Where I End and You Begin
    • Thievery Corporation: Warning Shots
    • U.N.K.L.E.: Unreal
    • Depeche Mode: Useless (Kruder and Dorfmeister mix)
    • Radiohead: Planet Telex
    • Shpongle: …But Nothing is Lost
    • Zauron: Lovelight
    • NuBreed: One Day
    • Way Out West: Pulse of Life
    • Leftfield: Release the Pressure
    • Sting: Shape of my Heart
    • Yoko Kanno: Some Other Time
    • Barakka: Song to the Siren
    • Lamb: Trans Fatty Acid (Kruder and Dorfmeister remix)
  • Erlang and Concurrency

    Here, you can download the slides for a talk I presented to the Sydney Linux Users’ Group on the 28th of July 2006, named “Erlang and Concurrency”. Note that the PDF file I’ve linked to here is quite large, since there’s a lot of images in there.

    Download: Adobe Acrobat PDF (~7MB)

    Some things to note about the presentation:

    • There were two short videos presented: a tech demo of the Unreal Engine 3, and snippets from the totally groovy Erlang the Movie, which has also been transcoded to the Ogg Theora video format thanks to Silvia Pfeiffer. These movies didn’t make it to the PDF intact.
    • I’m very proud that there wasn’t a single slide there with bullet points :).

    There’s an excellent blog by Garr Reynolds named Presentation Zen that led me to doing it in the style that I did. In particular, check out the Steve Jobs vs Bill Gates comparison that Reynolds did; no prizes for guessing who Reynolds prefers as a presenter.

    There’s a number of resources you can check out on Erlang:

    Update: I found another Erlang tutorial named Erlang in Real Time. There’s also a good Erlang FAQ.

    Update: Jay Nelson also has some great material on his Erlang web site, including some presentations at ICFP.

  • Mount Lambda

    Maybe this is why there’s a crazy-good bunch of functional programmers in Japan:

    That’s right, it’s Mount Lambda baby.

    (Props to kfish for the link.)

  • A History of Haskell Commentary

    There’s a draft paper named “A History of Haskell” on the Haskell Wiki right now, which will be submitted to the History of Programming Languages conference (HoPL) in 2007. I wasn’t even aware there was a conference dedicated to programming language history, and the idea is a great one: after reading the paper, I’ll be tracking down papers about other significant languages, such as LISP, Smalltalk and C++. (Hey, whatever your opinion of C++, it seems to be universally respected that Stroustrup’s The Design and Evolution of C++ is a title worthy of being on every serious programmer’s bookshelf. Seeing why a language is the way it is today is a huge key in understanding how to wield it.) The paper’s a long read (~40 pages) but a very easy read (no Greek in the entire thing!), and it’s fascinating hearing the inside stories from some obviously incredibly clever people. I’m also glad the authors mixed in some humour into the paper, which abounds in the Haskell community: not enough papers dare to inject (and successfully deliver) humour into their materials.

    So, here’s some of my commentary on quotes that I particularly liked from the paper. First, it looks like the authors of the paper agree with me about Haskell’s problem with unpredictable performance:

    The extreme sensitivity of Haskellís space use to evaluation order is a two-edged sword. Tiny changes—the addition or removal of a in one placeócan dramatically change space requirements. On the one hand, it is very hard for programmers to anticipate their programís space behaviour and place calls of correctly when the program is first written… As designers who believe in reasoning, we are a little ashamed that reasoning about space use in Haskell is so intractable.

    Mind you, they do also point out something I didn’t mention in my writings at all:

    On the other hand, given sufficiently good profiling information, space performance can be improved dramatically by very small changes in just the right place—without changing the overall structure of the program… Yet Haskell encourages programmers—even forces them—to forget space optimisation until after the code is written, profiled, and the major space leaks found, and at that point puts powerful tools at the programmerís disposal to fix them. Maybe this is nothing to be ashamed of, after all.

    Note that Don Stewart’s incredible Data.ByteString library has pretty much nailed the performance gap between Haskell and C for string processing and binary I/O, which is one area where Haskell was notoriously weak at. (Haskell’s also risen to the top of the heap in the Great Language Shootout as well, largely thanks to Don’s efforts.)

    There’s one paragraph on the great importance of profiling tools in finding the cause of performance problems, in one case leading to an absolutely amazing reduction in heap usage:

    … there was no practical way of finding the causes of space leaks in large programs. Runciman and Wakeling developed a profiler that could display a graph of heap contents over time, classified by the function that allocated the data, the top-level constructor of the data, or even combinations of the two (for example, ìshow the allocating functions of all the cons cells in the heap over the entire program runî). The detailed information now available enabled lazy programmers to make dramatic improvements to space efficiency: as the first case study, Runciman and Wakeling reduced the peak space requirements of a clausification program for propositional logic by two orders of magnitude, from 1.3 megabytes to only 10K (Runciman and Wakeling, 1993)… A further extension introduced retainer profiling, which could explain why data was not garbage collected… With information at this level of detail, Runciman and Rˆjemo were able to improve the peak space requirements of their clausify program to less than 1K—three orders of magnitude better than the original version. They also achieved a factor of two improvement in the compiler itself, which had already been optimised using their earlier tools.

    And, two paragraphs that lend more credence to the idea that Haskell really does lead to less lines of code:

    Darcs was originally written in C++ but, as Roundy puts it, “after working on it for a while I had an essentially solid mass of bugs” (Stosberg, 2005). He came across Haskell and, after a few experiments in 2002, rewrote Darcs in Haskell. Four years later, the source code is still a relatively compact 28,000 lines of literate Haskell (thus including the source for the 100 page manual). Roundy reports that some developers now are learning Haskell specifically in order to contribute to darcs.

    One of these programmers was Audrey Tang. She came across Darcs, spent a month learning Haskell, and jumped from there to Pierceís book Types and Programming Languages (Pierce, 2002). The book suggests implementing a toy language as an exercise, so Audrey picked Perl 6. At the time there were no implementations of Perl 6, at least partly because it is a ferociously difficult language to implement. Audrey started her project on 1 February 2005. A year later there were 200 developers contributing to it; perhaps amazingly (considering this number) the compiler is only 18,000 lines of Haskell (including comments) (Tang, 2005). Pugs makes heavy use of parser combinators (to support a dynamically-changable parser), and several more sophisticated Haskell idioms, including GADTs (Section 6.6) and delimited continuations (Dybvig et al., 2005).

    For verification and comparison, here’s a very rough lines-of-code count generated using David A. Wheeler’s ‘sloccount’ for Darcs, Bazaar-NG, Mercurial, Arch and Subversion. Note that I excluded test cases, supporting libraries and other non-essentials, which can be massive (e.g. total omission of hackerlab for Arch, which comprises another 50,000 lines, and the Apache Portable Runtime for Subversion, which is another 85,000 lines):

    • Darcs: 21,135 lines
    • Bazaar-NG: 47,084 lines
    • Mercurial: 20,537 lines
    • Arch: 48,639 lines (~100,000 with hackerlab)
    • Subversion: 98,736 lines (~185,000 with APR and APR-util)

    So Darcs and Mercurial are pretty similar, Bazaar-NG and Arch are nearly around the same size code base now (and it’s written in Python rather than C!), and Subversion is, well, a crapload bigger than all the others.

    Plus, I didn’t realise that Pugs was a mere 18,000 lines of code, which is quite amazing. I’m not sure whether I’m more impressed by that figure, or that Erlang’s incredible Mnesia distributed database is a mere ~30,000 lines of code…

  • /etc/rc.local on Mac OS X

    I’ve been wanting to run a couple of trivial commands during my system startup, which would’ve been perfect if Mac OS X had an /etc/rc.local file. Of course, since Mac OS X uses the (kick-ass) launchd and the nice StartupItems infrastructure, I didn’t quite expect it to have an rc.local file — Google wasn’t much help with this either.

    Of course, after I actually looked at the /etc/rc file (which launchd invokes), lo and behold, I find this near the end of the file:

    if [ -f /etc/rc.local ]; then
            sh /etc/rc.local
    fi

    So, Mac OS X does indeed have an rc.local, contrary to what I first expected. Hopefully this saves at least one other UNIX geek a couple of minutes of Googling around on the Web…

  • Subclassing a non-existent Objective-C class

    Let’s say you’re a Mac OS X developer, and you have the following scenario:

    • You have an application that’s required to start up without a particular Mac OS X class, framework or function definition, because it may not be installed yet on the user’s system, or they’re running an older version of Mac OS X that doesn’t have the relevant library installed. (Note that this requirement may only be there so that you can check for the presence of a particular framework, and throwing up a simple error message to the user when your application starts that tells the user to install the framework, rather than simply terminate with some obscure output to stderr.)
    • On the other hand, your application also uses some features of the potentially missing class/framework/function on Mac OS X. This is normally pretty easy to do by using weak linking and checking for undefined functional calls (or using Objective-C’s -respondsToSelector method), except when…
    • You need to subclass one of the Cocoa classes that may not be present on the user’s system.

    The problem here is that if you subclass an existing class that may not be present on the user’s system, the Objective-C runtime terminates your application as it starts up, because it tries to look up the superclass of your subclass when your application launches, and then proceeds to panic when it can’t find the superclass. The poor user has no idea what has happened: all they see is your application’s icon bouncing in the dock for the short time before it quits.

    Here’s some examples where I’ve needed to do this in real-life applications:

    • You use Apple’s QTKit framework, and you’re subclassing one of the QTKit classes such as QTMovie or QTMovieView. QTKit is installed only if the user has QuickTime 7 or later installed, and you’d like to tell the user to install QuickTime 7 when the application starts up, rather than dying a usability-unfriendly death.
    • You need to use all-mighty +poseAsClass: in a +load method to override the behaviour of existing class, but the class you’re posing as only exists on some versions of Mac OS X.

    There are several potential solutions to this (skip past this paragraph if you just want a solution that works): the first one I thought of was to use a class handler callback, which gets called when the Objective-C runtime tries to lookup a class and can’t find it. The class handler callback should then be able to create a dummy superclass so that your subclass will successfully be loaded: as long as you don’t use the dummy superclass, your application should still work OK. Unfortunately this approach encountered SIGSEGVs and SIGBUSs, and I ended up giving up on it after half an hour of trying to figure out what was going on. Another method is to actually make your subclass a subclass of NSObject, and then try to detect whether the superclass exists at runtime and then swizzle your class object’s superclass pointer to the real superclass if it does. This causes major headaches though, since you can’t access your class’s instance variables easily (since the compiler thinks you’re inheriting from NSObject rather than the real superclass)… and it doesn’t work anyway, also evoking SIGSEGVs and SIGBUSs. One other possibility is to simply create a fake superclass with the same name as the real Objective-C class, and pray that the runtime choses the real superclass rather than your fake class if your application’s run on a system that does have the class.

    The solution that I eventually settled on is far less fragile than all of the above suggestions, and is actually quite elegant: what you do is compile your subclass into a loadable bundle rather than the main application, detect for the presence of the superclass at runtime via NSClassFromString or objc_getClass, load up your bundle if it’s present, and finally call your class’s initialisers.

    Practically, this means that you have to:

    • add a new target to your project that’s a Cocoa loadable bundle,
    • compile the relevant subclass’s source code files into the bundle rather than the main application,
    • ensure that the bundle is copied to your application’s main bundle, and
    • detect for the presence of the superclass at runtime, and if it’s present, load your bundle, and then initialise the classes in the bundle via the +initialize method.

    Here’s some example code to load the bundle assuming it’s simply in the Resources/ directory of your application’s main bundle:

        NSString* pathToBundle = [[NSBundle mainBundle] pathForResource:@"MyExtraClasses"
                                                                 ofType:@"bundle"];
        NSBundle* bundle = [NSBundle bundleWithPath:pathToBundle];
        
        Class myClass = [bundle classNamed:@"MyClass"];
        NSAssert(myClass != nil, @"Couldn't load MyClass");
        [myClass initialize];

    You will also have to end up specifying using the -weak* parameters to the linker (such as -weak_framework or -weak-l) for your main application if you’re still using normal methods from that class. That’s about it though, and conceptually this technique is quite robust.

    Credit goes to Josh Ferguson for suggesting this method, by the way, not me. I’m merely evangelising it…

  • Apple Mail and Self-Signed SSL Certificates

    For those of you getting sick of Apple Mail pestering you about your beautiful self-signed SSL certificates running on your home-brew Gentoo 386SX/16 imaps/pop3s server, check out Apple’s knowledge base article 25593 to fix the problem once and for all.

    After that:

    • double-click on your newly-imported certificate in the Keychain Access utility,
    • scroll down to the bottom of the window and click on the “Trust Settings” disclosure triangle,
    • and finally, set the “When using this certificate” selector to “Always Trust”.

    Huzzah, no more SSL shenanigans.

  • Mashup Maps Australia

    Alastair Tse finally got fed up with Google Maps — despite having a Sydney development branch — not having Google Maps in Australia. As such, he’s put an incredible amount of work into fixing this anomaly, and announced his little Mashup Maps project yesterday. Nice work liquidx: that’ll be going on my browser toolbar indeed!

  • Controlled Chaos: Linux in the Visual Effects Industry

    “Controlled Chaos: Linux in the Visual Effects Industry” was a talk I presented at the Linux.conf.au 2006 Digital Arts miniconf, with Anthony Menasse of Rising Sun Pictures. We discuss using Linux in the VFX industry, of course, but also talk about problems encountered in VFX in general (e.g. mammoth data storage requirements), and how we manage the day-to-day technical issues that crop up. The slides are now available online, for those interested!

    Download: Adobe Acrobat PDF

  • MacBook Pro First Impressions

    It’s been about a week since I got my shiny new MacBook Pro. Since then, I’ve used it for both work and play, so I think it’s about time I put more crap on the Internet and blogged about my very important personal feelings on this issue.

    First, this thing screams. It’s fast as hell. Mac OS X zips along even more smoothly than the Dual 2.3GHz Power Mac G5 I have at work, and the interface generally feels snappier than a G5, which is already reasonably teh snappy. To my amazement, some stuff on the MacBook Pro is way faster than on the G5. As an example, here’s how long it took to compile a debug version of cineSync, our little project at work:

    • Dual 2.3GHz Power Mac G5: 5m10s
    • MacBook Pro: 1m40s

    That’s a 3x speed improvement — versus a 2.3GHz G5, which is a pretty blazing fast machine already. (I didn’t believe the performance difference that I ran the test three times!) I really don’t understand the performance discrepancy here: the G5 is at least the equal of the fastest x86 chips in raw processing power, so where’s this 3x difference coming from? Even fork(2)/exec(2) speed in Darwin is an order of magnitude quicker on the MacBook Pro than on the G5, so running those one terabyte ./configure scripts finally doesn’t look so paltry compared to Linux. My only thought is that x86 code generator for gcc is an order of magnitude better than the code generator for the PPC. I guess this is a feasible possibility, but it does seem somewhat unlikely. Can a compiler that generates better code really be responsible for that much of a speed difference? Maybe indeed (quiet you Gentoo fanboys down the back)… thoughts on this issue would be welcome!

    Rosetta, the JIT PPC-to-x86 code translator, also works amazingly well. While the technology in Rosetta is already an extremely remarkable achievement, its greatest achievement is that you don’t have to worry about it: I downloaded some Mac OS X binaries of Subversion a while ago, and only realised later that they were PPC binaries. So Rosetta works completely transparently, even for UNIX command-line programs. I suspect that part of the reason Apple haven’t open-sourced the Intel xnu kernel for Mac OS X/Darwin is because Rosetta may be tightly integrated with the kernel, and it’s technology that they don’t want to (or perhaps cannot legally) give away.

    The whole Windows-on-Mac thing also works rather well. Windows XP running via Boot Camp is, well, the same as Windows XP running on a vanilla PC, except that it’s running on a very pretty silver box (with very pretty ambient keyboard lighting). It does have some slightly annoying issues (such as Fn-Delete on the internal keyboard not functioning as a proper Del key), but those issues will be solved with time. (Unfortunately, Counter-Strike isn’t all that playable with a trackpad :).

    Parallels Workstation is equally impressive: hardware-assisted virtualisation really does fly. It’s remarkable to see Windows XP running in a window inside Mac OS X, and have it run at more-or-less native CPU speed. Setting breakpoints in Visual C++ Express also works fine, so Parallels appears to be virtualising hardware breakpoints correctly too. There’s still a lot of work to be done in virtualising drivers, however: it would be mighty cool to see a virtualised PC game running at nearly native speeds, since that requires virtualised accelerated video and sound support.

    The upshot of the successful Windows-on-Mac stories are that I’ll never be buying a generic PC yum-cha box ever again. On the road, I finally have a machine that can actually run Mac OS X, Windows and Linux all side-by-side, both virtualised and “for real”. For my family, that means that I can actually buy them an iMac even though they need to run Windows. (The iMac really is a beautiful machine: there’s no single-box-with-built-in-display solution like an iMac at all in the PC world. Yeah, I’m sure there’s some cheapass Taiwanese knockoff of an iMac, but that certainly doesn’t count.)

    One nice touch to end of this story is that my local AppleCentre offered me no less than A$1000 to trade-in my faithful old 1GHz Titanium Powerbook, which I intend to follow-up on. (I’d have done it already if I didn’t have to head out-of-town so soon.) If you’re thinking about upgrading an old Mac to a new ICBM model, see whether your AppleCentre will accept trade-ins. I was very pleasantly surprised that I could get a four-digit figure from a trade-in of a three-and-a-bit year old laptop.

    So, overall first impressions of a MacBook Pro? I’m a pretty happy boy indeed. The only regret I have is that I already used the name shodan for another computer that’s much less deserving of the name. Seriously, I called a Dell box shodan? What the hell crack was I on?

  • MacBook Pro Fun

    I suspect that if you don’t know that Apple released their Boot Camp tool to enable normal PC operating systems to be installed on their shiny new ICBMs, you’re probably not a geek, and this article doesn’t really concern you…

    Since there have been plenty of other articles written about Boot Camp and its implications for the future of the Macintosh, I won’t say any more about it here. I just wanted to say the following:

    • Tuesday, April 4: Pick up shiny new MacBook Pro from my local AppleCentre.
    • Wednesday, April 5, ~8pm Australian CST: Apple announces Boot Camp.
    • Thursday, April 5, ~2am Australian CST: Windows XP SP2 installs on my Mac.
    • Thursday, April 5, ~3am Australian CST: Visual C++ Express 2005 and Counter-Strike are installed (the latter running at a rather nice 72.7fps in Valve’s Video Stress Test).
    • Thursday, April 5, sometime later: Parallels announces a beta of their Workstation product, enabling Macs to virtualise running guest operating systems. Hooray for x86 hardware virtualisation technology.

    Not bad for the first three days of owning a MacBook Pro, really. Bring on the tech!

  • For the functional programmers

    http://foldl.com/
    http://foldr.com/