-
Firewire and Robust Connectors
I read somewhere a long time ago that the cable connectors for IEEE 1394 (better known as Firewire) were inspired by the connectors that Nintendo used for their game consoles. This assertion now seems to be on Wikipedia, so it must be true:
The standard connectors used for FireWire are related to the connectors on the venerable Nintendo Game Boy. While not especially glamorous, the Game Boy connectors have proven reliable, solid, easy to use and immune to assault by small children.
Clever. The 6-pin design for Firewire cables is great: absolutely impossible to plug in the wrong way, and you won’t damage a thing even if you try really hard to plug it in the wrong way. There are no pins exposed on the connector that can be broken, unlike, say, those damn 9-pin serial or VGA cables (or even worse, SCSI cables, ugh). It’s like the Firewire was designed by Jonathan Ive. (I dunno if Ive designed the iPod dock connector, but that’s definitely not as robust as a Firewire one.)
Yay for good industrial design.
-
Dodgy blank DVDs
Note to self: Before thinking your DVD drive is broken because it apparently can’t burn data DVDs properly, try another brand of recordable DVDs!
-
Video iPod Can Do Better Than 640x480
One of the features of the new video iPod (the “Generation 5.5” one) is that it handles videos bigger than 640×480 just fine. This shouldn’t be surprising for geeks who own the older video iPod that plays 320×240 video, since the alpha geeks will know that the older video iPods could play some videos bigger than 320×240 just fine.
A nice side-effect of this is that if you are ripping DVDs to MPEG-4, you can very likely rip them at native resolution: I had zero problems playing Season 2 of Battlestar Galactica on a new video iPod, and it had a native resolution of 704×400. (Note: This is with a standard MPEG-4 video profile, not H.264 baseline low-complexity.) This is pretty cool, since you can now hook up a little video iPod direct to a big-ass TV and know that video resolution is no longer a differentiating factor between DVDs and MPEG-4 video. Now if only the iPod had component video connectors available…
-
rcp in Erlang in 5 lines of code
Joe Armstrong, the Main Man behind Erlang, shows how to write an FTP client in Erlang in a couple of lines of code. Some of my own points:
- People on his blog who comment that “what operating system comes without an FTP server?” are totally missing the point, which is that Erlang makes it easy to write network programs. How many lines of code do you think it would have taken to do that in C? That file transfer program he wrote is less than half a dozen lines.
- Yes, it’s not a real FTP client, duh. Erlang does actually come with an FTP module which you can use in your own program, though.
-
Extensible Design in C++
Namespaces vs Static Methods
In C++, if you want a bunch of plain functions that you can put into a library, you can either do this:
class UtilityFunctions { public: static void Foo(); static void Bar(); };
or this:
namespace UtilityFunctions { void Foo(); void Bar(); }
Either way, you call the functions with the same syntax:
void SomeFunction() { UtilityFunctions::Foo(); UtilityFunctions::Bar(); }
So, what’s the difference between using a class full of static methods vs using namespaces? While I’m sure there’s plenty of differences about how they’re implemented internally, the big difference is that namespaces are extensible, while a class full of static methods isn’t. That means that in another file, you can just add more functions to the namespace:
namespace UtilityFunctions { void Baz(); void Quux(); }
but you can’t add more static methods to the class.
The Expression Problem
This is rather handy, since it means that C++ can quite nicely solve the expression problem, a problem that plagues nearly all modern programming languages, even ones with expressive type systems such as Haskell and Ocaml. (Note that the expression problem specifically concerns statically typed languages, so while there are solutions for it in modern dynamic languages such as Python, Perl and Ruby, they don’t really count since they’re not statically typed. It’s easy to solve the problem if you’re prepared to throw away all notions of type safety at compile time!)
The expression problem is basically this:
- You want to able to add new data types, and have existing functions work on those data types. This is easy in an object-oriented language: just subclass the existing data types, and all existing functions will work just fine with your new subclass. This is (very) hard in a functional language, because if you add new cases to a variant type, you must update every pattern match to work properly with the new case.
- However, you also want to add new functions that will work with those data types. This is very easy in a functional language: just define a new function. This is solvable in an object-oriented language, but isn’t very elegant, because most object-oriented languages can’t add new methods to existing classes (Objective-C is a notable exception; see the footnote below). This means that you are forced to declare a function when you really wanted to add a new method to the class, or, in OO languages which don’t even have normal functions (e.g. Java), you have to declare a totally new class with a static method instead. Ouch.
However, since C++ provides (1) objects, (2) normal functions, and (3) extensible namespaces, this means that you solve the expression problem nicely using the above techniques. It still requires some forethought by planning to use a namespace for sets of functions that you expect to be able to extend, but it’s an elegant solution to the expression problem, as opposed to no solution or a crappy solution. (And I thought I’d never say “C++” and “elegant” in the same sentence).
Extensible Object Factories
There’s one more piece to the puzzle, however. If you’re making your own new subclass, you also want to be able to create objects of that class. However, what if you only know the exact type of object you want to create at runtime? Use a runtime-extensible object factory instead.
Let’s say you’re designing an extensible image library, to read a bunch of image formats such as JPG, PNG, GIF, etc. You can design an abstract Image class that a JPGImage, PNGImage, or GIFImage can then subclass. If you want a uniform interface to create such images, you can use the factory design pattern:
Image* image = ImageFactory::CreateImage("/path/to/image");
In this case,
CreateImage()
is a factory function that will return you an appropriateImage*
object. (Well, if you’re really disciplined, you’ll be using the wonderful boost::shared_ptr rather than an evil raw pointer, but I digress…)Now, let’s say you want to make this library extensible, so users could add in their own
JPEG2000Image
subclass outside of your library. How, then, do you let theCreateImage()
function know about the user’s newJPEG2000Image
class?There are plenty of solutions to this, but since this is meant to be a didactic post, here’s a cheap’n’cheery solution for you: use a data structure to hold references to functions that are responsible for creating each different type of JPGImage, PNGImage, etc. You can then add to the data structure at runtime (usually called registering the creation function). The
CreateImage()
function can then look up the registered functions in the extensible data structure and call the appropriate function, no matter whether the image class is provided by your library (JPG, PNG), or by the user (JPEG2000).If you put together all the above techniques, what you have is a fully extensible framework. A user can:
- register new data types with the library at run-time,
- use exactly the same interface to create new types of objects,
- add new functions to your library without the awkwardness of using a different namespace,
- … and still retain complete static type safety.
Footnote: Objective-C has a particularly interesting solution to the expression problem, via categories, which are statically type-checked despite Objective-C being a “dynamic” language.
-
Insights into AppleScript
I recently encountered a paper written by William Cook about a mysterious little programming language that even many programming languages researchers don’t know about: AppleScript. Yep, that’d be the humble, notoriously English-like Mac scripting language that’s renown to be slow and annoying more than anything else. The paper is a fascinating look at the history of AppleScript, and details many insights and innovations that were largely unknown. Here’s some things that I was pleasantly surprised about.
Cook had never used a Mac before he was employed to work on AppleScript: in fact, he had a very strong UNIX background, and had a great amount of experience with UNIX shell scripting. So, one can instantly dismiss the notion that whoever designed AppleScript had “no idea about the elegance of interoperating UNIX tools”: a remark that I’m sure many would have made about the language (myself included). Cook even remarks that Apple’s Automator tool, introduced in Mac OS 10.4 Tiger, was quite similar to UNIX pipes:
The most interesting thing about Automator is that each action has an input and an output, much like a command in a Unix pipe. The resulting model is quite intuitive and easy to use for simple automation tasks.
More on UNIX pipes, he writes that
the sed stream editor can create the customized text file, which is then piped into the mail command for delivery. This new script can be saved as a mail-merge command, which is now available for manual execution or invocation from other scripts.
He then continues with something seemingly obvious, but is nevertheless something I have never thought about UNIX scripts:
One appealing aspect of this model is its compositionality [emphasis mine]: users can create new commands that are invoked in the same way as built-in commands.”
Indeed! In a way, the ability to save executable shell scripts is the equivalent of writing a named function to denote function composition in a functional programming language: it enables that composed code to be re-used and re-executed. It’s no coincidence that the Haskell scripts used in Don Stewart’s h4sh project are semantically quite similar to their equivalent Bourne shell scripts, where Haskell’s laziness emulates the blocking nature of pipes.
More on UNIX: Cook later writes that
A second side effect of pervasive scripting is uniform access to all system data. With Unix, access to information in a machine is idiosyncratic, in the sense that one program was used to list print jobs, another to list users, another for files, and another for hardware configuration. I envisioned a way in which all these different kinds of information could be referenced uniformly… A uniform naming model allows every piece of information anywhere in the system, be it an application or the operating system, to be accessed and updated uniformly.
The uniform naming model sounds eerily familiar who had read Hans Reiser’s white paper about unified namespaces. Has the UNIX world recognised yet just how powerful a unified namespace can be? (For all the warts of the Windows registry, providing the one structure for manipulating configuration data can be a huge benefit.)
Cook was also quite aware of formal programming language theory and other advanced programming languages: his Ph.D thesis was in fact on “A Denotational Semantics of Inheritance”, and his biography includes papers on subtyping and F-bounded polymorphism. Scratch another urban myth that AppleScript was designed by someone who had no idea about programming language theory. He makes references to Self and Common LISP as design influences when talking about AppleScript’s design. However,
No formal semantics was created for the language, despite an awareness that such tools existed. One reason was that only one person on the team was familiar with these tools, so writing a formal semantics would not be an effective means of communication… Sketches of a formal semantics were developed, but the primary guidance for language design came from solving practical problems and user studies, rather than a-priori formal analysis.
(There’s some interesting notes regarding user studies later in this post.) Speaking of programming language influences,
HyperCard, originally released in 1987, was the most direct influence on AppleScript.
Ah, HyperCard… I still remember writing little programs on HyperCard stacks in high school programming camps when I was a young(er) lad. It’s undoubtedly one of the great programming environment gems of the late 80s (and was enormously accessible to kids at the same time), but that’s an entire story unto itself…
The Dylan programming language is also mentioned at one point, as part of an Apple project to create a new Macintosh development environment (named Family Farm). ICFPers will be familiar with Dylan since it’s consistently in the top places for the judge’s prize each year; if you’re not familiar with it, think of it as Common LISP with a saner syntax.
AppleScript also had a different approach to inter-appication messaging. Due to a design flaw in the classic MacOS, AppleScript had to package as much information into its inter-application data-passing as possible, because context switches between applications on early MacOS systems were very costly:
A fine-grained communication model, at the level of individual procedure or method calls between remote objects, would be far too slow… it would take several seconds to perform this script if every method call required a remote message and process switch. As a result, traditional RPC and CORBA were not appropriate… For many years I believed that COM and CORBA would beat the AppleScript communication model in the long run. However, COM and CORBA are now being overwhelmed by web services, which are loosely coupled and use large granularity objects.
Web Services, eh? Later in the paper, Cook mentions:
There may also be lessons from AppleScript for the design of web services. Both are loosely coupled and support large-granularity communication. Apple Events data descriptors are similar to XML, in that they describe arbitrary labeled tree structures without fixed semantics. AppleScript terminologies are similar to web service description language (WDSL) files. One difference is that AppleScript includes a standard query model for identifying remote objects. A similar approach could be useful for web services.
As for interesting programming language features,
AppleScript also supports objects and a simple transaction mechanism.
A transaction mechanism? Nice. When was the last time you saw a transaction mechanism built into a programming language (besides SQL)? Speaking of SQL and domain-specific languages, do you like embedded domain-specific languages, as is the vogue in the programming language research community these days? Well, AppleScript did it over a decade ago:
The AppleScript parser integrates the terminology of applications with its built-in language constructs. For example, when targeting the Microsoft Excel application, spreadsheet terms are known by the parser—nouns like cell and formula, and verbs like recalculate. The statement tell application “Excel” introduces a block in which the Excel terminology is available.
Plus, if you’ve ever toyed with the idea of a programming language that could be written with different syntaxes, AppleScript beat you to that idea as well (and actually implemented it, although see the caveat later in this note):
A dialect defines a presentation for the internal language. Dialects contain lexing and parsing tables, and printing routines. A script can be presented using any dialect—so a script written using the English dialect can be viewed in Japanese… Apple developed dialects for Japanese and French. A “professional” dialect which resembled Java was created but not released… There are numerous difficulties in parsing a programming language that resembles a natural language. For example, Japanese does not have explicit separation between words. This is not a problem for language keywords and names from the terminology, but special conventions were required to recognize user-defined identifiers. Other languages have complex conjugation and agreement rules, which are difficult to implement. Nonetheless, the internal representation of AppleScript and the terminology resources contain information to support these features. A terminology can define names as plural or masculine/feminine, and this information can be used by the custom parser in a dialect.
Jesus, support for masculine and feminine nouns in a programming language? Hell yeah, check this out:
How cool is that? Unfortunately, Apple dropped support for multiple dialects in 1998:
The experiment in designing a language that resembled natural languages (English and Japanese) was not successful. It was assume that scripts should be presented in “natural language” so that average people could read and write them. This lead to the invention of multi-token keywords and the ability to disambiguate tokens without spaces for Japanese Kanji. In the end the syntactic variations and flexibility did more to confuse programmers than help them out. The main problem is that AppleScript only appears to be a natural language on the surface. In fact is an artificial language, like any other programming language… It is very easy to read AppleScript, but quite hard to write it… When writing programs or scripts, users prefer a more conventional programming language structure. Later versions of AppleScript dropped support for dialects. In hindsight, we believe that AppleScript should have adopted the Programmerís Dialect that was developed but never shipped.
A sad end to a truly innovative language feature—even if the feature didn’t work out. I wonder how much more AppleScript would be respected by programmers if it did use a more conventional programming language syntax rather than being based on English. Cook seems to share these sentiments: he states in the closing paragraph to the paper that
Many of the current problems in AppleScript can be traced to the use of syntax based on natural language; however, the ability to create pluggable dialects may provide a solution in the future, by creating a new syntax based on more conventional programming language styles.
Indeed, it’s possible to write Perl and Python code right now to construct and send AppleEvents. Some of you will know that AppleScript is just one of the languages supported by the Open Scripting Architecture (OSA) present in Mac OS X. The story leading to this though, is rather interesting:
In February of 1992, just before the first AppleScript alpha release, Dave Winer convinced Apple management that having one scripting language would not be good for the Macintosh… Dave had created an alternative scripting language, called Frontier… when Dave complained that the impending release of AppleScript was interfering with his product, Apple decided the AppleScript should be opened up to multiple scripting languages. The AppleScript team modified the OSA APIs so that they could be implemented by multiple scripting systems, not just AppleScript… Frontier, created by Dave Winer, is a complete scripting and application development environment. It is also available as an Open Scripting component. Dave went on to participate in the design of web services and SOAP. Tcl, JavaScript, Python and Perl have also been packaged as Open Scripting components.
Well done, Dave!
As for AppleScript’s actual development, there’s an interesting reference to a SubEthaEdit/Gobby/Wiki-like tool that was used for their internal documentation:
The team made extensive use of a nearly collaborative document management/writing tool called Instant Update. It was used in a very wiki-like fashion, a living document constantly updated with the current design. Instant Update provides a shared space of multiple documents that could be viewed and edited simultaneously by any number of users. Each userís text was color-coded and time-stamped.
And also,
Mitch worked during the entire project to provide that documentation, and in the process managed to be a significant communication point for the entire team.
Interesting that their main documentation writer was the communication point for the team, no?
Finally, AppleScript went through usability testing, a practice practically unheard of for programming languages. (Perl 6’s apocalypses and exegeses are probably the closest thing that I know of to getting feedback from users, as opposed to the language designers or committee simply deciding on everything without feedback from their actual userbase!)
Following Appleís standard practice, we user-tested the language in a variety of ways. We identified novice users and asked them “what do you think this script does?” As an example, it turned out that the average user thought that after the command put x into y the variable x no longer retained its old value. The language was changed to use copy x into y instead.
Even more interesting:
We also conducted interviews and a round-table discussion about what kind of functionality users would like to see in the system.
The survey questions looked like this:
The other survey questions in the paper were even more interesting; I’ve omitted them in this article due to lack of space.
So, those were the interesting points that I picked up when I read the paper. I encourage you to read it if you’re interested in programming languages: AppleScript’s focus on pragmatics, ease of use for non-programmers, and its role in a very heavily-based GUI environment makes it a very interesting case study. Thankfully, many Mac OS X applications are now scriptable so that fluent users can automate them effectively with Automator, AppleScript, or even Perl, Python and Ruby and the UNIX shell these days.
Honestly, the more I discover about Apple’s development technologies, the more impressed I am with their technological prowess and know-how: Cocoa, Carbon, CoreFoundation, CoreVideo, QuickTime, vecLib and Accelerate, CoreAudio, CoreData, DiscRecording, SyncServices, Quartz, FSEvents, WebKit, Core Animation, IOKit… their developer frameworks are, for the most part, superbly architectured, layered, and implemented. I used to view AppleScript as a little hack that Apple brought to the table to satisfy the Mac OS X power users, but reading the paper has changed my opinion on that. I now view AppleScript in the same way as QuickTime: incredible architecture and power, with an outside interface that’s draconian and slightly evil because it’s been around and largely unchanged for 15 freaking years.
-
Pushing the Limits
OK, this is both ridiculous and cool at the same time. I need to write code for Mac OS X, Windows and Linux for work, and I like to work offline at cafes since I actually tend to get more work done when I’m not on the Internet (totally amazing, I know). This presents two problems:
- I need a laptop that will run Windows, Mac OS X and Linux.
- I need to work offline when we use Subversion for our revision control system at work.
Solving problem #1 turns out to be quite easy: get a MacBook (Pro), and run Mac OS X on it. Our server runs fine on Darwin (Mac OS X’s UNIX layer), and I can always run Windows and Linux with Parallels Desktop if I need to.
For serious Windows coding and testing, though, I actually need to boot into real Windows from time to time (since the program I work on, cineSync, requires decent video card support, which Parallels doesn’t virtualise very well yet). Again, no problem: use Apple’s Boot Camp to boot into Windows XP. Ah, but our server requires a UNIX environment and won’t run under Windows! Again, no problem: just install coLinux, a not very well known but truly awesome port of the Linux kernel that runs as a process on Windows at blazing speeds (with full networking support!).
Problem #2 — working offline with Subversion — is also easily solved. Download and install svk, and bingo, you have a fully distributed Subversion repository. Hack offline, commit your changes offline, and push them back to the master repository when you’re back online. Done.
Where it starts to get stupid is when I want to:
- check in changes locally to the SVK repository on my laptop when I’m on Mac OS X…
- and use those changes from the Mac partition’s SVK repository while I’m booted in Windows.
Stumped, eh? Not quite! Simply:
- purchase one copy of MacDrive 6, which lets you read Mac OS X’s HFS partitions from Windows XP,
- install SVK for Windows, and
- set the
%SVKROOT%
environment variable in Windows to point to my home directory on the Mac partition.
Boom! I get full access to my local SVK repository from Windows, can commit back to it, and push those changes back to our main Subversion server whenever I get my lazy cafe-loving arse back online. So now, I can code up and commit changes for both Windows and the Mac while accessing a local test server when I’m totally offline. Beautiful!
But, the thing is… I’m using svk — a distributed front-end to a non-distributed revision control system — on a MacBook Pro running Windows XP — a machine intended to run Mac OS X — while Windows is merrily accessing my Mac HFS partition, and oh yeah, I need to run our server in Linux, which is actually coLinux running in Windows… which is, again, running on Mac. If I said this a year ago, people would have given me a crazy look. (Then again, I suppose I’m saying it today and people still give me crazy looks.) Somehow, somewhere, I think this is somewhat toward the evil end of the scale.
-
Add Cmd-1 and Cmd-2 back to iTunes 7
iTunes 7.0 removed the Cmd-1 and Cmd-2 shortcuts to access the iTunes window and the equaliser, for whatever reason. You can add them back in via the Keyboard preference in System Preferences:
- launch System Preferences,
- go to the Keyboard & Mouse preference,
- click on the Keyboard Shortcuts tab,
- hit the + button, pick iTunes as the application, type in “Show Equalizer” as the menu title, and use Cmd-2 for the keyboard shortcut.
- hit the + button, pick iTunes as the application, type in “Hide Equalizer” as the menu title, and use Cmd-2 for the keyboard shortcut.
- hit the + button, pick iTunes as the application, type in “iTunes” as the menu title, and use Cmd-1 for the keyboard shortcut.
Done.
-
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:
- a crazy-small Sony Micro Vault 2GB memory stick,
- the entire Robotech collection,
- Ghost in the Shell: Standalone Complex, 2nd gig
- Samurai Champloo
… 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:
- Attend Apple’s World Wide Developer Conference (WWDC) thing
- Attempt to socialise and meet up with as many people as possible
- Attempt to keep up with all the latest and greatest tech news and world news whilst at WWDC
- Have three to four coffees per day thanks to the surprisingly excellent (and free) espresso service at WWDC
- Combine said three or four coffees per day with beer, wine, and beer (in that order — yes, ouch, me dumb dumb) at night.
- 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)
- 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:
- The unofficial and official Erlang Web sites.
- An Erlang tutorial.
- Another Erlang tutorial.
- How to interpret Erlang crash dumps.
- Writing Low-Pain Massively Scalable Multiplayer Servers, by Joel Reymont.
- Haskell vs Erlang, and Haskell vs Erlang Reloaded.
- An introduction to Erlang on informit.com.
- A Slashdot article about moving toward distributed computing.
- trapexit.org, an online Erlang community site.
- The documentation for Mnesia, Erlang’s awesome distributed, soft-real-time database.
- Joel Reymont on his dream language being a combination of Erlang and Ocaml.
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…