CocoaHeads Silicon Valley at Apple on Thursday, May 15, 2008

The next CocoaHeads Silicon Valley meeting will be on Thursday, May 15, 2008 — that’s tonight! — at 7:30 in the Garage 1 meeting room at Infinite Loop 4 on Apple’s main campus. That’s inside and upstairs at Apple’s Infinite Loop campus in Cupertino. See the web site for directions.

This month’s main presentation is on the Best of Both Worlds — an introduction to Cocoa development by Scott Stevenson.

This talk is a combination of an introduction to Cocoa, as well as a series of advanced tips and tricks that even relatively experienced Mac programmers may not know about.

The idea here is that we want to give all of the people who are new to Mac and iPhone development a chance to get started, but we also want to do something special for our advanced programmers. So rather than choosing one, we’re just going to go ahead and do both.

Joel Norvell will also be presenting on how to edit PDF forms using Cocoa — he’s done a lot of work with PDFKit and Cocoa, and I’m looking forward to learning from him.

Thanks a ton to Scott Stevenson, Steve Zyszkiewicz, Michael Jurewitz and Joar Wingfors for organizing!

In general, at a CocoaHeads meeting we do some introductions, have a presentation including Q&A time with the presenter, and then have an open Q&A and demo-your-cool-app period. After the meeting there’s more independent mingling and discussion until it’s time to go at 9:30. Often a subset of the meeting moves to BJ’s Brewhouse in Cupertino, which is right in front of the Apple Infinite Loop campus on De Anza Boulevard.

Build LLVM and clang!

I’ve talked about the LLVM Compiler Infrastructure in the past, but what I haven’t talked about yet is just how easy and quickly you can build it on your own Mac running Leopard! This is a great way to get into hacking on compiler lexical analyzers and parsers, code generators, optimizers, and so on.

What’s more, you can build both LLVM and the new C front-end clang very easily and in five to ten minutes.

First, create a work area to check them out into, wherever you normally create your projects.

[~]% cd /Projects
[/Projects]% mkdir LLVM
[/Projects]% cd LLVM

Then check out LLVM itself and clang from the LLVM Subversion repository.

[/Projects/LLVM]% svn checkout llvm
[/Projects/LLVM]% cd llvm/tools
[/Projects/LLVM/llvm/tools]% svn checkout clang
[/Projects/LLVM/llvm/tools]% cd ../..

Then edit the PARALLEL_DIRS definition in llvm/tools/Makefile to tell it about clang. Just add clang onto the end, like this:

PARALLEL_DIRS := llvm-config  \
                 opt llvm-as llvm-dis \
                 llc llvm-ranlib llvm-ar llvm-nm \
                 llvm-ld llvm-prof llvm-link \
                 lli gccas gccld llvm-extract llvm-db \
                 bugpoint llvm-bcanalyzer llvm-stub llvmc2 \

Now create a directory to build into, next to your llvm directory, and change into it.

[/Projects/LLVM]% mkdir build
[/Projects/LLVM]% cd build

This is where you’ll actually run configure. This will ensure your source tree isn’t polluted with build products, and that everything stays self-contained while you hack.

[/Projects/LLVM/build]% ../llvm/configure --enable-targets=host-only
# lots of logging

You’ll note that above I passed an argument to configure. This ensures that LLVM is only built to target the architecture I’m running on, to speed up the build process; this is generally fine for simple front-end development.

Now, to build LLVM as well as clang all I have to do is invoke make. LLVM is set up to correctly do parallel builds, so I’ll pass the number of CPUs I have in my machine via make -j 4.

[/Projects/LLVM/build]% make -j 4
# lots of logging

That’s it! LLVM is now (hopefully) successfully built. All of the pieces are in the build directory under Debug/bin and Debug/lib and so on; see the LLVM web site for details about what the various components are.

Copyright canonical form

One thing that’s nagged at me lately has been the series of applications I’ve seen lately with copyright statements that appear to be from the Bizarro universe. I don’t mean that they have weird license restrictions; rather, they have a copyright statement in their standard About panel that’s formatted strangely. It’s a minor pet peeve to be sure, but it’s a simple thing to get right and getting it wrong looks silly.

Note that the following is not legal advice on asserting or protecting your copyright — you’ll have to go to a lawyer for that — it’s just a suggestion on how to concisely format your statement that your work is covered under copyright.

In a Cocoa application, the standard About panel will show the copyright statement specified under the NSHumanReadableCopyright of its Info.plist file. This should generally be of the form

> Copyright © «YEARS» «HOLDERS». All rights reserved.

where «YEARS» represents the individual year, set of years, or range of years during which the application was authored and «HOLDERS» represent the authors of the application.

Thus if I were to start writing an application in 2007 and finish it in 2008, I would put

> Copyright © 2007–2008 Chris Hanson. All rights reserved.

in the NSHumanReadableCopyright key of its Info.plist file. (Yes, that’s an en-dash between the years, option-hyphen gets you one.) It wouldn’t have the year at the end, or random commas after things, or random abbreviations. Just one simple statement.

Someday I’ll figure out how to add

> Copyright © 2002–2008 Chris Hanson. All rights reserved.

to the bottom of my weblog, too. Hopefully in such a way that I can actually update it easily when the year rolls over…

CocoaHeads Silicon Valley at Apple on Thursday, Apple 17, 2008

The next CocoaHeads Silicon Valley meeting will be on Thursday, April 17, 2008 — that’s tonight! — at 7:30 in the De Anza 3 auditorium at Apple. That’s just inside the south side of De Anza 3, right across Mariani Avenue from Apple’s Infinite Loop campus in Cupertino. See the web site for directions.

This month’s presentation is all about designing and implementing your human interface. User experience and human interface design are critical for Mac OS X software to get right. To that end, there’s even going to be a UI makeover as Scott describes in his post on the meeting!

Thanks a ton to Scott Stevenson, Steve Zyszkiewicz, Michael Jurewitz and Joar Wingfors for organizing!

In general, at a CocoaHeads meeting we do some introductions, have a presentation including Q&A time with the presenter, and then have an open Q&A and demo-your-cool-app period. After the meeting there’s more independent mingling and discussion until it’s time to go at 9:30. Often a subset of the meeting moves to BJ’s Brewhouse in Cupertino, which is right in front of the Apple Infinite Loop campus on De Anza Boulevard.

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.


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.


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.