Apple TV 2.0.1

A new version of the Apple TV software is available! And what’s more, after updating to Apple TV 2.0.1, I found that I can actually use my YouTube favorites and subscriptions on my Apple TV!

This is great, because I mark videos that I’ll want to watch again as favorites, and I have a number of subscriptions set up to interesting videos — like those from the Computer History Museum and Zendulo — that aren’t yet available as video podcasts.

YouTube favorites and subscriptions hadn’t worked for me in the past because I have a YouTube account that’s linked to my Google account — that is, a YouTube account that ends in @gmail.com. After updating to Apple TV 2.0.1, I just had to log out from my YouTube account and log in again, and everything came up just fine.

peterb hits it out of the park

peterb of Tea Leaves, in Game Developer To World: Please Revolve Around Me! summarizes the position taken by Tim Sweeny of Epic during an interview thusly:

  1. People aren’t buying expensive enough PCs.
  2. Even the expensive PCs aren’t good enough to run his games.
  3. People who buy cheaper machines with Intel integrated graphics are giving their money to Blizzard instead of Epic.
  4. This aggression cannot stand. The solution is that everyone except us should change what they’re doing and buy machines with more expensive graphics hardware.

This problem is endemic in the game industry.

The most recent example, I was going to buy my girlfriend The Sims 2 for Valentine’s Day to play on her MacBook. Oops! Her MacBook has the dread Intel integrated graphics and therefore can’t run it! Or, indeed, any of the other games ported to the Mac using the same technology! Thanks a bunch, it’s not like anybody has a MacBook! (Except, of course, everybody these days.)

But wait, what are the actual system requirements for The Sims 2 on Windows? 800 MHz CPU and a T&L-capable video card, or 2GHz CPU and non-T&L-capable video card. Her MacBook definitely meets those criteria, and it’s also a huge portion of the Mac customer base for a game like that. I wonder if the PowerPC build would run acceptably under Rosetta — the original Sims ran fine on an iBook DV a half-decade ago, after all, and it’s not like The Sims 2 is new.

I also heard a lot of commentary around the time the iMac G5 debuted about its “terrible” 5200FX video chipset. After all, it meant that a lot of games people were working on for then-high-end machines wouldn’t run! Except, uh, why wouldn’t they run? Because developers didn’t actually design for what users were buying! They were designing for some ideal system that very few people had, and beyond that they had the gall to complain that they weren’t selling many games. Hmm. I wonder why. If you limit your market to people with beefy dual-G5 systems with high-end video cards who are allowed to install games on them, maybe that’s not such a big market… On the other hand, if you design for the iMac G4, and the iMac G5 comes out, chances are you’ll be able to sell to a lot more people…

Game developers should be targeting the systems people are using rather than systems with every feature under the sun. No wonder casual games do so well — nobody else is willing to serve that vast majority of the market!

So if you’re writing a game, or thinking about writing a game, or any other performance-sensitive application, look at what the bulk of the users you want to target are currently using and design for that. Neither you nor your users are likely to be disappointed with the results.

Free font happiness! Inconsolata, Kaffeesatz and Tagesschrift

I love good fonts. It’s one of the things that I enjoy most about Mac OS X — the font rendering is *wonderful*.

Lately for programming and Terminal use, I’ve used [Inconsolata][1] by [Raph Levien][2]. It’s a very clean monospaced font that renders really well at 12 points and higher, and is perfectly usable for coding at that size. It avoids the [Vera Sans Mono][3] problems with too-thin horizontal lines at common sizes.

Tonight — thanks to [Jens Alfke][4] and his [logo design][5] for the [Mercurial][6] distributed SCM system — I’ve discovered the free fonts from [Yanone][7], specifically [Kaffeesatz][8] and [Tagesschrift][9]. Kaffeesatz in particular is a pretty slick font; hopefully I can find a use for it in something.

Any other free & open font suggestions? Let me know in the comments. I can always use more great fonts.

[1]: http://www.levien.com/type/myfonts/inconsolata.html
[2]: http://www.levien.com/
[3]: http://www.bitstream.com/font_rendering/products/dev_fonts/vera.html
[4]: http://mooseyard.com/Jens/
[5]: http://mooseyard.com/Jens/2008/02/make-mine-mercurial/
[6]: http://www.selenic.com/mercurial/
[7]: http://www.yanone.de/
[8]: http://www.yanone.de/typedesign/kaffeesatz/
[9]: http://www.yanone.de/typedesign/tagesschrift/

Arc in a nutshell: It’s no Dylan (and that’s too bad)

What’s the point of [Arc][1]? Infix-syntax [Dylan][2] is a much, much better language, especially once you add in the changes and features from the [Dylan Design Notes][3] and the infix version (but keep the prefix syntax). Really, Dylan is pretty much the Ultimate Lisp in a lot of ways.

Arc is essentially `(decr Scheme)` with a couple of interesting additions to try and make up for the downsides. Downsides like a lack of international character support (what decade is it again?!) and an unhygienic macro system.

[Dylan — as designed in the **early 1990s**][4] — really is `(incr Scheme)`. It’s essentially Scheme re-hosted atop an enhanced CLOS-like object system. With the prefix syntax, it’s even very Scheme-like in actual use.

So, yeah. If you’re interested in Arc, check out Dylan. It’s a better language, and there have been implementations available for 15+ years.

PS – The original Dylan had a [``][5] class. In the early 1990s.

[1]: http://www.arclanguage.org/
[2]: http://www.opendylan.org/
[3]: http://amigos.rdsathene.org/other/prefix-dylan/design-notes/home.html
[4]: http://amigos.rdsathene.org/other/prefix-dylan/book.annotated/preface.html
[5]: http://amigos.rdsathene.org/other/prefix-dylan/book.annotated/ch12.html#unicode-string-class0

OLPC group in Silicon Valley

If you have an OLPC — or have set up VMWare or another environment to emulate one — and you’re in the Silicon Valley area, there’s a group of enthusiast hackers forming called [SV_OLPC][1].

I ran into the founder of the group completely randomly after leaving [NSCoder Night][2] a couple weeks back, and it’ll be interesting to see just who is doing what with the OLPC stack.

[1]: http://groups.google.com/group/sv_olpc
[2]: http://nscodernight.com/

Jon Harrop dives into OCaml on LLVM

As seen on the LLVMdev mailing list: Jon Harrop, Fibonacci example in OCaml:

Here is a complete 104-line native code compiler for a tiny subset of OCaml that is expressive enough to compile an external Fibonacci program: [...]

The compiler is itself written in OCaml, of course; for those who don’t know, OCaml or Objective Caml is an object-oriented dialect of Standard ML, a purely functional language.

Jon’s name rang a bell because I just listened to the second of two podcasts from .NET Rocks on the F# functional programming language — Jon Harrop Makes Us F# and F# Moves Forward — that Microsoft will be including with future versions of VIsual Studio. F# is itself a derivative of OCaml, runs atop the .NET Common Language Runtime, and can interoperate with other code

F# is interesting because, due to its functional and side-effect-free nature, one can get a huge amount of parallelism out of straightforward code. (It’s the lack of side effects that allow such analysis to be performed.) The Xbox Live matching service, for example, is using a TrueSkill engine developed in F# by Microsoft Research.

OCaml on LLVM is interesting in a lot of the same ways: You have a functional language that’s very amenable to all sorts of analysis and optimization, and an abstract platform that can run on an extremely wide variety of systems very efficiently. It’s really the best of both worlds, where you will be able to write the parts of your software that need to be highly parallel and mathematically rigorous in a language amenable to it, and interface that to the rest of your application in a very natural fashion.

It’s great to see that Jon is enjoying exploring OCaml atop LLVM and I can’t wait to see what kind of fun results!

NSCoder Night Silicon Valley (and hopefully elsewhere)

I’ve been toying with this idea for a while now, and now that Leopard is coming out, it’s finally time to make it happen! I call it NSCoder Night! (Major thanks to Scott Stevenson for coming up with the name!) Here’s the inaugural announcement:

> NSCoder Night Silicon Valley will be having its inaugural get-together between 7:00 and 9:00 PM on October 30, 2007 — next Tuesday night — at Orchard Valley Coffee in Campbell, CA. From then on, we’ll be getting together there every Tuesday!
>
> What’s the point? To get together with other folks who are also writing Cocoa code for Mac OS X, of course! There’s no formal structure, which is why I described it as a “get-together” rather than a meeting. There’s no need to RSVP, either; just show up if you like, or don’t if you can’t make it. Just bring your brain, laptop, and enthusiasm, pick up one of the tasty drinks available at Orchard Valley Coffee, and have a great time!
>
> Why did I pick Orchard Valley Coffee for the inaugural Silicon Valley get-together? I first went there one afternoon during a little vacation I took after WWDC, and I found it a nice, large, relaxing place. It has wireless connectivity, reasonable hours, plenty of room, and great drinks, and it’s also quite accessible since it’s right in the heart of downtown Campbell.
>
> So come on down, say hi, and see just how much fun it is to hang out and hack for a couple hours!

Want to hold your own NSCoder Night? Just let me know — here, on the NSCoder Night web site, or via email — and I’ll post the announcement. Hopefully we’ll have get-togethers across the world, even in places where there’s not yet a CocoaHeads chapter.

What’s the difference between NSCoder Night and CocoaHeads? CocoaHeads is a once-a-month user group meeting, typically with presentations and demos. NSCoder Night is a weekly get-together, a time to talk to your fellow hackers, to get help with issues you’re bumping into, to show off cool tricks, and to actually have some time specifically set aside for your side projects.

LLVM Developers’ Meeting 2007-05

The LLVM Compiler Infrastructure is a great technology that came out of the computer science research community and can be used to develop extensible compiler platforms. Among other things, it provides a platform-independent assembly and object code (the “low level virtual machine” that its name is taken from), and a great object-oriented compilation, linking, optimization and code-generation infrastructure that you can use to efficiently target real hardware. The main idea is that LLVM provides a comprehensive back-end that you can easily build a front-end to target.

There’s a huge amount of material available on the LLVM web site, including the LLVM Assembly Language Reference Manual and LLVM Programmer’s Manual, a wide variety of papers on LLVM, and a great walkthrough of the creation of Stacker, a Forth front-end that targets LLVM. It shows how the budding language creator might leverage the tools available as part of the LLVM infrastructure. I fully expect that in time, “little languages” will have no excuse not to be JIT compiled simply because targeting LLVM is actually easier than writing your own interpreter or bytecode engine! Just walk your AST and generate naïve LLVM code for what you encounter, and let the infrastructure handle the rest. (For those who aren’t developer tools weenies, an Abstract Syntax Tree is the internal representation of a program’s structure before it’s turned into instructions to execute.)

A couple months back, the May 2007 LLVM Developers’ Meeting was held at Apple. The proceedings from this meeting — the actual session content, both in slides and in video form — are available online, and I’ve even created an LLVM Developers’ Meeting podcast (including a subscribe-directly-in-iTunes version) for easy viewing. The video may be low bit rate, but it has a 16:9 aspect ratio so you can even pretend it’s HD. (I put together the podcast primarily so I could watch the sessions on my Apple TV, since I couldn’t attend the meeting.)

So if you’re at all interested in compilers, language design or development, optimization, or development platforms in general, you’ll be very well-served by checking out LLVM. It is a seriously cool enabling technology.

Unit testing Cocoa user interfaces: Cocoa Bindings

About a year ago, I wrote about unit testing target-action connections for Cocoa user interfaces. That covers the traditional mechanism by which user interfaces have typically been constructed in Cocoa since the NeXTstep days. However, with the release of Mac OS X 10.3 Panther we’ve had a newer interface technology available — Cocoa bindings — which has presented some interesting application design and testing challenges.

Among other hurdles, to properly use Cocoa bindings in your own applications, you need to ensure that the code you write properly supports key-value coding and key-value observing. However, since the release of Mac OS X 10.4 Tiger, the necessary APIs have been available to easily do test-driven development of your application’s use of Cocoa bindings, following a trust, but verify approach. (It’s also been quite easy from the start to test your support for key-value coding and key-value observing, to ensure that your code meets the necessary prerequisites for supporting bindings. I can write more on this topic in another post if anyone is interested.)

The key to writing unit tests for Cocoa bindings is the -infoForBinding: method in AppKit’s NSKeyValueBindingCreation informal protocol. Using this simple method, you can interrogate any object that has a binding for all of the information about that binding! It simply returns a dictionary with three keys:

  1. NSObservedObjectKey, which is the object that the binding is bound to;
  2. NSObservedKeyPathKey, which is the key path that is bound — in Interface Builder terms, this is the controller key path combined with the model key path, with a dot in between them; and
  3. NSOptionsKey, which is a dictionary of additional binding options unique to the binding. These are all of those additional checkboxes and pop-ups in the Interface Builder bindings inspector for setting things like a value transformer.

By specifying what this dictionary should contain for a particular binding, you can describe the binding itself and thus start doing test-driven development of your Cocoa bindings-based user interface. Note that all of the system-supported binding names — as well as the binding option names — are specified in <AppKit/NSKeyValueBinding.h> and are documented, too!

Let’s take a simple example, like the one in last year’s target-action example, of a window controller whose window has a static text field in it. The field should have its value bound to the name of a person through an object controller for that person. Assume that I’ve already created the test case and set up some internal methods on my window controller to refer to the contents of the window via outlets, and to load the window (without displaying it) in -setUp just like in the target-action example.

First, to see that my text field has a value binding, I might write something like this:

- (void)testPersonNameFieldHasValueBinding {
    NSTextField *personNameField = [_windowController personNameField];

    NSDictionary *valueBindingInfo = [personNameField infoForBinding:NSValueBinding];
    STAssertNotNil(valueBindingInfo,
        @"The person name field's value should be bound.");
}

Of course, this tells us nothing about how the binding should be configured, so it needs some fleshing out…

Let’s check the object and key path for the binding.

- (void)testPersonNameFieldHasValueBinding {
    NSTextField *personNameField = [_windowController personNameField];

    NSDictionary *valueBindingInfo = [personNameField infoForBinding:NSValueBinding];
    STAssertNotNil(valueBindingInfo,
        @"The person name field's value should be bound.");

    NSObjectController *personController = [_windowController personController];
    STAssertEquals([valueBindingInfo objectForKey:NSObservedObjectKey], personController,
        @"The person name field should be bound to the person controller.");

    STAssertEqualObjects([valueBindingInfo objectForKey:NSObservedKeyPathKey], @"name",
        @"The person name field's value should be bound to the 'name' key.");
}

Not very exciting, and a little verbose, but it'll easily lead us through what needs to be set up in Interface Builder for this binding to work. If you want to cut down the verbosity, you can of course extract a method to do the basic checking...

- (BOOL)object:(id)object shouldHaveBinding:(NSString *)binding
            to:(id)boundObject throughKeyPath:(NSString *)keyPath
{
    NSDictionary *info = [object infoForBinding:binding];

    return ([info objectForKey:NSObservedObjectKey] == boundObject)
            && [[info objectForKey:NSObservedKeyPathKey] isEqualToString:keyPath];
}

- (void)testPersonNameFieldHasValueBinding {
    NSTextField *personNameField = [_windowController personNameField];
    NSObjectController *personController = [_windowController personController];
    
    STAssertTrue([self object:personNameField shouldHaveBinding:NSValue
                           to:personController throughKeyPath:@"name"],
    @"Bind person name field's value to the person controller's 'name' key path.");
}

If you're writing code that needs, say, a value transformer, it's a simple matter to extend this model to also check that the correct value transformer class name is specified for the NSValueTransformerNameBindingOption key in the binding options dictionary returned for NSOptionsKey.

You can even extract these kinds of checks into your own subclass of SenTestCase that you use as the basis for all of your application test cases. This will let you write very concise specifications for how your user interface should be wired to the rest of the code, that you can use to just walk through Interface Builder and connect things together — as well as use to ensure that you don't break it accidentally by making changes to other items in Interface Builder.

This is the real power of test-driven development when combined with Cocoa: Because you can trust that the framework will do the right thing as long as it's set up right, you simply need to write tests that specify how your application's interface should be set up. You don't need to figure out how to create events manually, push them through the run loop or through the window's -sendEvent: method, how to deal with showing or not showing the window during tests, or anything like that. Just ensure that your user interface is wired up correctly and Cocoa will take care of the rest.