Wednesday January 18, 2012

SOPA and PIPA

Today is a blackout day when many sites, like Wikipedia, are going down in protest of SOPA and PIPA, the two latest pieces of US Legislation that threaten the very nature of the internet. Today, Wikipedia has a nice and simple locator to look up your US Representatives by zip code in place of their home page. Use it.

Wednesday December 28, 2011

Real Software Engineering

At the Lone Star Ruby Conference in 2010, Glenn Vanderburg gave an excellent talk on how often we misunderstand the process and challenges that go into developing software. It’s a witty and vivid presentation that needs to be seen by anyone leading software teams.

Glenn talks about how the waterfall process was originally conceived as an anti pattern to be avoided; how the nature of code makes it more like a blueprint that we discuss than the raw materials we build with; and how the actual product we create isn’t the code, but what the code does.

I briefly mentioned this presentation toward the end of the NSBrief interview, but thought it was so important that I should bring it up here. Enjoy!

Tuesday December 27, 2011

✦ Running Your iOS App in the Simulator From The Command Line

While Apple doesn’t provide an “official” way to launch an app in the iOS Simulator from the command line, there’s a few private tricks we can employ. First, the iOS Simulator app itself is located in:

/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications

But running that will only bring up the simulator in the last state it was in. How do we install an application in there and then run it automatically like Xcode does?

The trick is in the private iPhoneSimulatorRemoteClient.framework. Now before you freak out, don’t worry! This isn’t something you compile your app against and submit to the store. This is a framework that we can use on our local machines to control the simulator just like Xcode does. The best part is, all the work of hooking into it has been done for us!

There are two command line utilities I’ve seen that do this best. I used to use iphonesim and it works great. But I recently switched to WaxSim since it also records video of the simulator in motion. They both are functionally equivalent and small enough to understand. It’s your call, but I recommend the later.1

The Recipe

First, we need to pull down the WaxSim source and install it. Run the following:

git clone https://github.com/square/WaxSim
cd WaxSim
xcodebuild install DSTROOT=/

Now, you have the waxsim binary in /usr/local/bin which should already be on your path. You can now invoke your application in the simulator like this:

waxsim [application path]

So, where is your application path? That depends on how you build it! First, we’ll need to do a quick walkthrough about building Xcode projects from the command line.

cd into your iOS application’s project directory (the one with the Xcode project file). Then, invoke the xcodebuild command like so:

xcodebuild -sdk iphonesimulator5.0 \
           -arch i386 \
           install DSTROOT=/tmp/MyApp

For most projects, this command will work just fine. However, if you have an explicit workspace set up, you’ll need to use man xcodebuild to learn how to teach the xcodebuild binary to interpret your setup. There’s a lot of good stuff in there about how to specify whether to build for the simulator or device, too.

The DSTROOT environment variable on the command above is the most important part. DSTROOT is used by Xcode when run with the “install” build action to figure out where to put the results. We’re specifying /tmp/MyApp explicitly so that we know where the resulting application bundle will be to hand in to waxsim.

Once the xcodebuild command completes, you should now have an *.app bundle in /tmp/MyApp/Applications/[YourAppName].app. Of course, subtitute your own application name in the path. Invoke waxsim and you’re up and running:

waxsim /tmp/MyApp/Applications/[YourAppName].app

This runs the iPhone simulator with the latest SDK that waxsim is aware of. Use waxsim -h to find out other options like running the iPad simulator or other using other available SDKs.

You can also record a low resolution video of the simulator like so

waxsim -v myvideo.mov /tmp/MyApp/Applications/[YourAppName].app

And now you’ll have myvideo.mov in the current directory. It’s a pretty low res and stuttery video, probably not something you’d use for a promotional demo, but it’s a nice feature if you need to review results of automated testing workflows.

Script It

So, for completeness sake, here’s a shell script that you can modify to build and run your application:

#!/bin/bash

# Tell bash to abort the script if any error happens
set -e

APPNAME=MyApp
DSTROOT=/tmp/MyApp

xcodebuild -sdk iphonesimulator5.0 \
           -arch i386 \
           install DSTROOT="$DSTROOT"

waxsim "$DSTROOT"/Applications/"$APPNAME".app

Drop this in your project directory and tweak to taste.

The End!

So, there you have it. We’ve built the waxsim binary, learned briefly how to build with xcodebuild, and learned how to launch your application in the iOS simulator on demand and from the command line. Vive la Unix!


  1. I like Square’s fork of WaxSim because they have a lot at stake to keep this working.

Monday December 26, 2011

"Cheap" and "Customizable"

More disappointment for non-technical customers hoping to see long term support for their still-fresh “flagship” Android phones. Vlad Savov at The Verge writes about Samsung’s decision:

…Samsung’s choice not to upgrade this phone to Ice Cream Sandwich is simply unacceptable. As an owner of a Galaxy S, I would feel betrayed. As a technology journalist, I am appalled.

It sees production and R&D costs in one column and it tries to balance them against sales revenue in the other, never raising its gaze to the long-term consideration of whether anyone would come back for a repeat purchase.

I’ve been asked many times when I would starting building software for Android. As a technical platform, it fascinates me, and I’m always on the lookout to learn something new. But as a consumer electronics platform, it still stinks.

Google, who dominates on the web, pushes Android out as fast as it can for fear of losing its window into our querying minds. Samsung is looking for a cheap and customizable software component to set-and-forget in it’s hardware. This leaves Android, as a philosophy, burdened with a schizophenic caretaker on the one hand and a race to the bottom on the other.

The customer is caught in the middle.

Friday December 23, 2011

Zucchini: Promising Cucumber-like Front End for UI Automation

As we approach the holiday break, I found this little gem. Zucchini looks to be a Cucumber-like runner that acts as a front end to UI Automation. You write feature files in it’s own Gherkin-ish syntax and write your step definitions in CoffeeScript. Zucchini automatically compiles the CoffeeScript down into Javascript, invokes UI Automation, and generates much better organized output. It even automatically handles screenshots of the app for you in the final report.

I haven’t had a chance to dig into this myself, yet. It looks very promising and I like what I see when I glance through the code. And it looks like they’ve thought through a good continuous integration workflow.

I like the idea behind this, but I advise caution when piling up layers, upon layers of testing abstraction. Debugging these scripts still requires knowledge of UI Automation and may be more a hassle than it’s worth. Personally, I’m still looking for a means to invoke the UI Automation mechanism directly and do that from Ruby. But there’s good stuff to learn from in this project.

(via Deallocated Objects)

Friday December 23, 2011

Apple Lossless Decoder...Written in JavaScript

It only works in Chrome and the the latest version of Firefox at the moment, but ofmlabs ported the recently open sourced Apple Lossless Audio Codec to Javascript. That’s an audio codec. In the browser. Without plugins. Javascript.

Take note: there’s quite a trend here.

Thursday December 22, 2011

Repeat Text Actions Like Vim In Any Cocoa Text Field

As Brett Terpstra channels unreal levels of productivity and Mac-hack goodness, he discovered a built in way to repeat text commands n times just like vim.

Besides the power of modal editing, one of the reasons I like vim is the ability to repeat text manipulation commands an arbirary number of times. Want to delete the next three lines of text? Type 3dd in normal mode. Want to move up 10 lines? Type 10k. And you can get more complicated from there.

Apparently, Cocoa has this kind of power built in, you just have to tweak a setting to turn it on. Brett is the one man repository of tweaks to get Cocoa text fields to do all kinds of amazing things. This repeat trick bumps it all to a whole new level. Check out his other tips for Cocoa editing fields, too.

Friday December 16, 2011

Yours Truly on the NSBrief Podcast

Saul Mora of the NSBrief podcast sat me down after CocoaConf Raleigh to chat about metaprogramming and Objectve C. We make off hand remarks about neckbeards, compare and contrast with Ruby, and Saul brings out the money quote: “This is not the podcast for C++ people.”

Monday December 12, 2011

Overwhelming List Of Good Cocoa Literature

I’m late to the party, as usual, but Jeff Biggus pointed out his massive Cocoa Literature List to me. He is trying to catalog every piece of important information on the web related to Cocoa and CocoaTouch development. It’s well organized, searchable, and grouped by topic. Impressive list. A must have on speed dial.

Saturday December 10, 2011

GAJavaScript - Objective C bridge to Javascript running in a web view

Andrew Goodale has a nifty library, GAJavaScript, that gives you an Objective C interface to invoke Javascript in your web views. It helps box and unbox parameters crossing the bridge and lets you invoke Javascript functions as if they were Objective C methods.

Even if the library itself is too bulky for your needs you’d do well to browse the code. Good examples of interfacing with web views and Objective C metaprogramming.

Thursday December 08, 2011

Remotely Debugging UIWebViews From The Desktop

Nathan de Vries walks through how to set up your app to debug UIWebViews from the Safari Web Inspector. A marvelous piece of investigative work. And a marvelous tip if you use UIWebViews for content display in your apps.

(Via Deallocated Objects)

Tuesday December 06, 2011

Want MacRuby on iOS?

While giving my MacRuby talk at CocoaConf 2011 in Raleigh, I half-jokingly said that we should file bug reports to Apple to help them realize just how much we would like to develop in MacRuby on iOS like we can on Mac OS X.

Then I thought, why not?

Monday December 05, 2011

✦ When GCD Isn't The Best Abstraction

While browsing Mugunth Kumar’s new MKNetworkKit network library, I came across this observation that got me thinking:

I purposefully didn’t use GCD because network operations need to be stopped and prioritized at will. GCD, while more efficient than NSOperationQueue cannot do this. I would recommend not to use GCD based queues for your network operations.

Grand Central Dispatch is an amazing piece of open source by Apple. With it you encapsulate “tasks” as simple blocks of code and run them in special queues. These queues can be concurrent or parallel and they can run on any number of threads. You get a lot of sensible defaults out of the box and there’s good customization if you want to queue things up in a custom way. Overall, it’s a very nice simplification of the standard threading model available on Unix.

The problems start when you want to treat these “tasks” as smarter encapsulations that you can start, stop, restart, or even save and try again later. That’s where using Apple’s NSOperation and NSOperationQueue still makes sense. Mugunth’s nifty new networking library offers the option to save a network operation to disk if it fails. Later, when the app is launched and has a network connection, it will automatically retry.1

Technically, you could still use GCD and just wrap the control of it in an NSOperation. And I wouldn’t be surprised if Apple reimplements NSOperationQueue using GCD. Just remember that you don’t have to reinvent the wheel if you want to encapsulate your “tasks” as objects. NSOperation is still just as robust as it ever was.

Updated Dec 6, 2011 1:00pm

As many kindly pointed out to me, Apple has already converted NSOperationQueues to use GCD under the hood, but only on Mac OSX.


  1. Mugunth’s library has a lot of other nify features, too. I’d recommend checking it out. It’s goal is to be slim and simple, like AFNetworking.

Friday December 02, 2011

Siri API May Be Far Off

Guy English summarizing his witty and reasonable argument that Siri’s API is far off:

Siri is a process of disambiguation, but installing random apps from the App Store that support Siri can only increase how ambiguous any request is.

I’ll bet on an API later rather than sooner. If only because the success of Siri is determined upon it generating the best possible results and the ranking of those results must be determined by the plug-ins it uses. Once you allow plug-ins that potentially lie then you’ve ruined the entire Siri experience.

Every iOS dev I talk to dreams about this mythical API. No doubt it will happen, but it’s tough to be realistic on when.

Wednesday November 30, 2011

✦ Changes to UI Automation in iOS 5

Since iOS 5 and Xcode 4.2 came out, I’ve been poking around in UI Automation and I’m starting to get impressed. You’ll want to read through the parts of my tutorial first. I assume you’ve already walked through those steps.

First off, they now let you invoke it from the terminal! Well…sort of. Observe:

instruments \
    -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate \
    /path/to/your/application \
    -e UIASCRIPT /path/to/your/javascript/file.js

I broke up the command parameters on separate lines for some sanity. That first parameter, -t [template file], lets you specify the specific template file you want to use when instruments is run. You can run any kind of instrument you want, but in this case I’m using the unbelievably long path to the default Automation template that is offered by the new document wizard. You could make your own template from within Instruments and specify that instead, but you get the idea.1

The second parameter is the path to the application binary that the simulator uses. You can find them by poking around in ~/Library/Application Support/iPhone Simulator/5.0. You’ll see a list of directories with guids for names. Look inside them to find the app bundle you are looking for and that’s the path you hand in here.

The last parameter is where you specify environment variables that are handed in to Instruments. In this case we set the environment variable UIASCRIPT to a path of a javascript file. That file will be executed and the output will be sent to standard out.

You can also specify other environment variables with subsequent -e arguments. These environment variables pass through to the application so you can have, say, a RESET_ALL_DATA variable that your application checks for to set itself up in a consistent state before the script is run.2

The New Look

The New Look

You’ll notice from the image above that you now have the ability to record, edit and run Javascript right from within the app! This makes exploring the possibilities much more fun and full of feedback than before. I would recommend still doing the bulk of your test organization in external files. You don’t want to have huge buckets of clutter that you have to maintain. But this script pane is great for the one off ideas.

Notice that you switch between the script and logging views by using the popup menu named “Script” above the main editor/logging pane.3

You can manage scripts in the editing pane by clicking the “Add” and “Remove” buttons in the sidebar. Choosing “Create” from the “Add” menu just gives you a blank script to play with.

Recording is a little weird. You can click the red record button at the bottom to start. Then, when interacting with the simulator, the events are reproduced as those long, ugly Javascript lines. Each of the blue bubbles is a popup menu that lets you choose different ways of accessing that particular screen element like so:

Choosing different element paths

In theory, it’s a pretty neat idea. It really helps while you’re exploring your application to see how best to automate it. But in practice, this is not how you’d want to organize your test suite for the long term. When you’ve got a lot of very common operations you want to perform, I argue that it’s better to encapsulate your screens as individual Javascript objects for you to interact with. This lets you build up a vocabulary of your own to reuse. Alas, I haven’t written part three of my tutorial yet where I explore this. For the moment, you’ll just have to take my word for it. :)

Logs and Trees

The new log

Finally we come to the log pane. You’ll notice that when logging an element tree we finally have a hierarchial representation! Much easier to read than before. And to the right we have screen captures of each of the individual elements that a line belongs to. Nice touch.

Continuous Integration?

I like where this is going. Since Apple claims to be using UI Automation internally, there’s solid hope it will keep improving. It’s not quite ready for prime time use in a continuous integration flow, yet. The fact that it doesn’t return a proper Unix status code on failure is surprising. You could capture the output and grep for failure messages and handle that if you need to, but unfortunately that’s effort to solve a problem that shouldn’t exist.

Apple, you’ve built your empire on top of Unix. Don’t be afraid to do it the Unix way. :)


  1. I plan to devote more attention to running instruments and xcodebuild from the terminal, soon. I have a couple of tricks up my sleeve to make them play better with Unix, but I’m testing a few things out, first.

  2. Get a dictionary of environment variables in your app with [[NSProcessInfo processInfo] environment]

  3. There’s also a quick shortcut to jump back and forth between the script and logging panes. See in the sidebar under the “Status” section where it says “Script is Capturing”? Double click that and you’ll toggle between the two panes on the right. Don’t ask me how I found that out. WYSIWYG for the win, right? :)

Wednesday November 30, 2011

So, What's A Good Practice With Groups And Directories In Xcode?

I asked the legendary Wil Shipley of Delicious Monster for his thoughts on whether to try to keep directories organized on the file system or just throw everything in the same place and use groups in Xcode. Here’s his advice:

I just use groups unless there’s an actual second or third target – separate targets get their own subdirs.

Xcode doesn’t care about where your source files are. If you rearrange files in the sidebar or put them in to groups, they aren’t moved around on the filesystem, even if your groups refer directly to directories. I think I understand the logic behind this. With Objective C’s heritage, directory structure isn’t that important for organization. Conventionally, each file has a unique name based on the class name. Since there is no namespacing in Objective C, it’s all done with prefixes.

When I first came to Objective C, I was meticulously grouping my source files in subdirectories and in Xcode groups. If I needed to move things around during a refactor or rewrite I had to move the file and then move the reference in the Xcode sidebar. Too much friction to evolve the organization of a code base, in my opinion.

So, recently I’ve been just letting Xcode handle all the grouping and organization for me and leaving my source files in a single directory. It works. And it’s good to hear that it’s a common practice, according to Wil. If I drop down to work in vim it isn’t a problem since I use a fuzzy file finder, anyway. It’s not ideal since I think we’re ignoring the file system as a very valid way of organization, but for the time being going with the flow lowers the friction for what is more important.

Tuesday November 29, 2011

Xcode 4 Keyboard Shortcuts

This is your annual reminder that mice and trackpads are for sissies. This list of Xcode 4 keyboard shortcuts is the best place to free yourself to move faster and get more organized. Learn how to hide and show the sidebars, the console/debugger pane, open and switch window splits…all with the comfortable clickity-clack of a keyboard.

Tuesday November 29, 2011

Browser Debugging Tools: Bonus Features

Andi Smith has an excellent roundup of the hidden tricks to make browser debugging a snap. Half of them were new to me. If you didn’t already know, Safari on the Mac is a great development environment for building and debugging Javascript for Webkit on iOS.

Saturday November 26, 2011

Rapture XML

Finally, a nice block based XML parsing library for Cocoa(Touch) that I would want to use! Thanks to John Blanco we’re getting a better peek at how the magic of blocks can revolutionize Objective C the way they make languages like Ruby sparkle. The query syntax is pretty slick, too.

Saturday November 26, 2011

Developing on an iPad with Vim

Mark O’Connor wrote up his experiences switching from a MacBook to using an iPad entirely for his development, system administration, and writing. He gets away with this because all of his development work can happen on a remote server in Vim (using iSSH as his terminal). While not a common setup for most of us, he loves the freedom these constraints give him.

I started this experiment because I fundamentally believe that most people don’t want to rearrange windows, babysit their own general purpose computers or back up their data. Sooner or later, almost everyone will work like this and I wanted a taste of what that might feel like. I expected to find something that didn’t work, but as the days turned into weeks and the weeks gathered into a month, I found I hadn’t returned to my laptop even once.

Now if only we could remap Capslock to control…

Wednesday November 23, 2011

Exception Backtraces in Xcode 4.2

I tweeted this Stackoverflow answer about getting exception backtraces yesterday and got so much favorite/retweet love that I figured I should mention it here, too.

In Xcode 4.2 and iOS 5, exceptions that crash your application are no longer breaking on the line where the exception occurred. The debugger just dumps you right in main() and no backtrace is printed out or navigatable on the left side panel. Well, as this answer demonstrates, that old out-of-the-box feature has been converted into exception breakpoints. You need to create one yourself and then you’ll get the old useful behavior back!

Tuesday November 22, 2011

How Xcode Optimizes PNGs

Jeff Lamarche has a nice write up on the way Xcode optimizes PNGs to make loading them much faster in the most common cases on the constrained resources of iOS devices. This also explains why the PNG files in iOS app bundles aren’t easily opened in Preview.

Monday November 14, 2011

How Would You Do That In Lisp?

The language nerd in me loves this kind of thing. Rosetta Code is a wiki where you can see algorithms ported to many different languages. What better way to learn a new language and dive deep into it’s idioms than to see a familiar result expressed in its flavor?

Every developer should seek to learn as many languages as time will allow. A programming language’s unique syntax can often lead to fascinating new workflows (witness Ruby’s block syntax and Rspec as the result).

So, when you curl up by the fire this autumn and want to look for some mind stretching activities, pull up Rosetta Code and learn how to implement Bubble Sort in COBOL.

Tuesday November 08, 2011

Hues - Invoke the Color Picker Anytime

Speaking of the nice UIColor picker plugin you might be wondering how you’d invoke the color picker from anywhere. Well, Hues is your app.

Tuesday November 08, 2011

Quickly Find Any UIColor

This is an oldie, but a goodie. The smart devs at Panic have kindly shared a nice custom color picker plugin that will let you copy an NSColor or UIColor representation to the clipboard. Since it’s part of the built in MacOSX color picker, you get all the nice color visualization options and the “color loupe” to pick a color out of any pixel on the screen.

Don’t be caught hunting and pecking for the right UIColor again.

Monday November 07, 2011

Debugging NSMutableURLRequests

Spotted this slick shortcut from Mugunth Kumar for debugging NSMutableURLRequests. Just include his two souce files and then when you NSLog() an NSMutableURLRequest, you’ll get a runnable curl command printed to the log. Paste into the terminal and you’ll see exactly what your app got in response.

This works great by itself or with any networking library like ASIHTTPRequest or AFNetworking as long as it exposes NSMutableURLRequests to you.

Friday November 04, 2011

AFNetworking

I’ve recently fallen in love with Gowalla’s AFNetworking library.

Choosing open source libraries is tough. I used to use ASIHTTPRequest since it has some nice content handling and functionality wrapping, but it’s large and can be difficult to follow if you want to extend it. I abandoned it and decided to go with raw NSURLRequests, which is already a pretty nice abstraction that Apple came up with.

But when it’s time to process content coming back from the server, I wanted to build a content type handler and found AFNetworking does pretty much what I would have made. It’s a thinner layer on top of NSURLRequest than ASIHTTPRequest which means a lot when you have to debug a library yourself.

Using an open source library in your code means you “own” it and have to support what it does for you. I prefer the simplest libraries. I don’t want to waste time messing with other peoples abstractions if I can get away with it.

Thursday November 03, 2011

Write Lua on the iPad

Codify is an iPad app that lets you write software in Lua…on the iPad. Very fun!

Now, if someone can just port Processing over, we’ll be all set!

Monday October 31, 2011

Avoiding View Controller Spaghetti

Matthijs Hollemans has an excellent three part tutorial on making your classes talk to each other in the Cocoa Touch idioms.

I’ve been brought in to help a lot of teams new to iOS as they try to figure out how to get view controllers to play together. Unfortunately, I see too many use the app delegate as a central repository that every view controller queries for all kinds of application state. Bad idea. Better idea: plain old dependency injection. Matthijs shows you the Cocoa way to pull that off.

If you’ve ever found yourself trying to figure out how to get two different view controllers to share a data model, or have updates from one influence another, you need to read these tutorials.

Tuesday October 25, 2011

Automatic Reference Counting

Great summary from Mike Ash on Automatic Reference Counting (ARC). Contrary to what many have speculated on Twitter, ARC is not garbage collection like we’re used to. Objects don’t stay alive until some other thread comes along at runtime looking to see what is no longer needed. ARC is still about retain and release…it’s just that the compiler does all the work to manage that for you. In essence, it inserts retain, release and autorelease at method and object boundaries at compile time.

Why? It’s faster. It’s more deterministic. The system doesn’t have to search for and syncrhonize object deallocation across threads anymore. There are a couple of edge cases that you’ll need to be aware of, but for the most part it works without any special intervention from you.

Still confused? That’s why Mike’s summary is so great. Read up on this. It is the future of Apple platform development.

Friday October 21, 2011

Think You're An Advanced iOS 5 Dev?

Looks like Mugunth Kumar and Rob Napier have a real winner here. Here’s Mugunth’s description of the new book, iOS 5 Programming Pushing the Limits, due to be published later this year.

This is not an introductory book and it focusses on advanced topics on iOS 5 programming and delves deep into the core Objective-C. It’s primary audience is iOS developers who have hands-on experience writing iOS apps and want to take their apps to the next level. If you’re ready to move beyond the basics, to learn the best practices and the secrets that the authors have learned from practical experience writing real applications, then this is the book for you.

Level up, baby!

Thursday October 20, 2011

Debug Your UIView Hierarchy

Patrick Richards has a marvelous library to aid you in debugging your UIView heirarchy.

Introspect is small set of tools for iOS that aid in debugging user interfaces built with UIKit. It’s especially useful for UI layouts that are dynamically created or can change during runtime, or for tuning performance by finding non-opaque views or views that are re-drawing unnecessarily. It’s designed for use in the iPhone simulator, but can also be used on a device.

Looks like a nice way to poke around UIViews and see how stuff is rendered.

Monday October 17, 2011

Namespacing Hack in Objective C

Dost my eyes deceive me? Mike Ash over at his blog has an interesting post about name spacing constants and functions in Objective C. Actually it’s raw C, but quite useful within in Objective C, too.

I’ve ranted at length about the lack of good name spacing in Objective C. Using character prefixes gives us such ungodly names as NSManagedObjectContextDidSaveNotification. Well, weep a bit less with this tip.

I’m hesitant to use this full throttle because it’s definitely not normal in the Apple world. Code must be written so that the humans who follow you up can edit it, you know. But, still, when Apple is done reinventing memory management on portible devices, I hope they have some cycles reserved to solve namespacing in their flagship programming language.

Friday October 14, 2011

New Features in GCD

Mike Ash uses his latest Friday Q&A to explore new features of Grand Central Dispatch in iOS 5 and OS X Lion. You can now have GCD wrap file descriptors to help manage IO operations at the application level. With a central brain asynchronously coordinating IO like this, it potentially reduces things like disk thrashing while not blocking UI operations. Clever stuff.

Thursday October 13, 2011

Dennis Ritchie

Dennis Ritchie, the creator of the C programming language and co-creator of Unix, passed away last night. Another pioneer in our field is gone.

Tim Bray has a marvelous list of things we take for granted that exist because of Dennis Ritchie. Did you know that he was the originator of “Hello World”?

Tuesday October 11, 2011

Who Are You?

Speaking of following the money, here’s my friend Josh Walsh on the tradeoffs of UX and privacy:

Ironically, the worse the privacy situation gets (Facebook owns all of our personal information), the better the overall experience becomes (we all have Facebook, and therefore have our single authentication solution). Creepy, but user friendly.

♫ But I’m a creep, I’m a weirdo… ♫

Tuesday October 11, 2011

✦ Customer Insight

Rene Ritchie over at TiPb writes about how Siri increases Apple’s insight into customer behavior:

But there’s more. If Apple chooses to adopt a Google-style business model, they can aggregate and anonymize that data and sell it to advertisers and marketers. That turns the customers into products, something they tried — and have thus far failed — to do with iAds in apps. Siri moves it to the OS level and while it won’t display ads, it will collect data that can be fed back into iAds, or other advertising and marketing platforms.

If you want to follow the privacy game going on today, make sure you follow the money.

Apple optimizes its business so that the money flows directly from the end users. This isn’t just a fly-by-night business move, this is a deliberate long term strategy that they’ve executed on for at least a decade. You could cynically say that they are trying to milk as much money from users as possible, and that would be technically true as any business would do. But don’t pretend that a business offering you “free” service isn’t going to maximize their income from you either.

Rene speculates that Apple may use the insights it gains from Siri as a new revenue stream by selling it. I hope not. And I doubt it, too. They suck at that game. They separate this customer data from app devs, in app subscribers and their ad network. Marketers are frustrated with it.

Apple became the most profitable company in the world through selling directly to the user. That’s very unusual in the consumer electronics space today. I find it fascinating that they are disrupting in business models as much as they are in technology.

There’s no guarantee they won’t shift their business model over time. Keep an eye on where the money comes from. In a world where we have tradeoffs between privacy and convenience, revenue streams will be key to understanding which businesses can be more trustworthy than others. Make sure you’re the customer. That gives you leverage.

Sunday October 09, 2011

Smalltalk Best Practice Patterns

I picked up a copy of Smalltalk Best Practice Patterns by Kent Beck because it’s generated quite a buzz in the Ruby circles I run in. It’s an excellent read and not just because Objective C inherits some traits from Smalltalk.

I can’t say it often enough—the bottlenecks throughout development come from limitations in human communication. Over and over in the patterns, you will read “You could do this or you could do that, but this over here communicates best, so that’s what you should do.” If there’s a radical thought here, that’s it; that when you program, you have to think about how someone will read your code, not just how a computer will interpret it.

Indeed, and that is why every Mac or iOS developer should give this book a chance. Kent goes out of his way to avoid condescention or tell you what must be done in every circumstance. He’s opinionated, sure, as any master of a trade should be. But he is so sensitive to context that you will find valuable tips and tricks even if what he describes doesn’t quite fit your problem domain or language.

Many of the software engineers I run with are a racous bunch. We’re self made, self taught, and don’t want to be told how to do things. But there’s a difference between blindly following the rules and foolishly reinventing the wheel. Kent knows his stuff. Trust me, get this book.

Thursday October 06, 2011

✦ Steve Jobs

I started out hacking on an Apple //c when I was 11 years old. Eventually, my father replaced it with an Apple IIgs. I hacked on that, too. Looking back on my life as a software engineer, audio engineer, musician, and businessman, I attribute so many of the skills I have to the lessons learned studying these machines.

I cut my teeth as a budding adolescent programmer in 65c816 assembly language, TML Pascal, and Orca/C trying to poke and prod at the “Toolbox”, Apple’s framework for making the IIgs the marvel that it was at the time. Here was a personal computer in the late 80’s that had an audio synthesizer chip built in. It was truly revolutionary and forward thinking for it’s time. And I knew that thing inside and out.

Just around the time I hit puberty, I had dreams of changing the world by writing software for these machines to make life easier. While I always have been a geek at heart giggling in delight at fantastically designed architecture under the hood, I wanted to write software for normal people. I wanted them to do extraordinairy things. Steve Wozniak fed my inner nerd. Steve Jobs fed my inner user.

Steve Jobs taught me that a doctor doesn’t have time to think about driver installs or interrupt request lines. That a mother of four would rather spend her time with her children than babysitting a machine during a full reinstall. That a veteran would video chat with his great grand children and have no idea what a codec or network protocol is.

In a world full of marketing about megahertz, gigawhatsits and package managers, Steve Jobs knew there was a place for that, but not for his customers. As a card carrying member of the “holiday family IT” crowd, my idealism was shaped by watching the low level details of the IBM PC legacy leak out to unsuspecting users and ruin them. These machines were frightening. Impersonal. Let’s call Jonathan, maybe he can fix it.

Steve said, “No.”

And so, here I am. From the small beginnings, I started down a path of invention, problem solving, and entrepreneurship. As a child I studied the story of Apple’s humble start in that garage back in 1976 (my birth year, btw). I didn’t want to be like other technology companies. I wanted to be like Apple. I wanted to build products that ordinary people could use.

So crazy.

Yeah, I’ll gripe about Xcode or Objective C. I’m not impressed with their stance on patents of software. Apple isn’t perfect. But it does a lot of things so, so different.

Steve guided a company that demonstrates patient, slow growth and profitability, not a quick race to market. A company that makes tools and services we pay to use rather than selling us and what we do to advertisers and “partners”. A company that knows how to make money, create jobs, spawn industries, inspire.

Here’s to the Crazy Ones.

Rest in peace, Steve Jobs. Quite a ride.

Wednesday September 21, 2011

UTF-8 All The Way Down

Learned some great stuff about encodings from Jonathan Rentzsch. He shares his experiences making sure your entire technology stack properly supports UTF-8. He even has a test string, “Iñtërnâtiônàlizætiøn”, that he uses. If that string passes all the way through your system and back out unscathed, then you’re set!

Yes, NSStrings are pretty darn good when it comes to handling encodings. But if you’re building a server side component for your hot-awesome-new iOS app, make sure you handle encodings properly. Poor encoding causes confusion. Confusion causes anger. Anger causes war.

Visualize world peace! Support proper encodings!

Tuesday September 20, 2011

A Pausable, Persistent Operation Queue

Ever notice how Instapaper picks up downloading your queue right where it left off if you quit and come back to it? Marco Arment has been kind enough to release the next generation of his persistent operation queue for us to use. It’s in alpha right now, so use at your own risk. But he’s going to be plugging this into the future of Instapaper and now you too can have this power.

Tuesday September 13, 2011

A "URL" Router for Objective C

Already, Jeff Verkoeyen is making good on his promise to remake the old Three20 framework with better abstractions and documentation. He’s ripped out the url router into it’s own project, called SOCKit. It’s a companion to Nimbus, but can be used independently.

For those who’ve never messed with Three20 before, this is a big deal because it lets you specify a path through navigation controllers with essentially a URL. That URL could be used to launch the app and put it in a consistent state, or used as the previously saved state before the app was terminated.

But unlike the tightly coupled monstrosity that was Three20, this router isn’t just for navigation. It lets you use URLs to easily specify any kind of state you want!

Tuesday September 06, 2011

Privacy Policies

Graham Lee lays down the law with his Don’t Be A Dick Guide to Data Privacy.

Thursday September 01, 2011

Destroy All Software

My friend, Gary Bernhardt, is a self-proclaimed destroyer of software. Gary uses his power for good at destroyallsoftware.com to dissect what we programmers do for fun and profit.

All of his screencasts are great, but his recent ones are particularly noteworthy. He takes a real world open source Ruby project and demonstrates a series of steps to refactor one of its controllers into a more maintainable design. Method naming, object extraction, framework taming, you name it. Haven’t we all faced that monolithic 300 line function with useless comments and obtuse cleverness?1

It’s not directly related to Cocoa, but it’s general enough to be invaluable. I’ve lost count of how many projects I’ve helped where cleaner and clearer code would have solved basic communciation problems and prevented many bugs. If you’re not subscribed to his screencasts, you’re doing it wrong.


  1. Written by someone else, of course

Monday August 29, 2011

The Architecture Of Modern Browsers

Tali Garsiel writes a marvelous high level look at modern browser architecture. If you’ve been curious how the parsers deal with the forgiving nature of HTML syntax, or how CSS is applied efficiently, you might enjoy this read. Given the way Apple keeps augmenting Safari and WebKit, I think it will behoove you to keep up to date with the browser mechanism. There will come a day when it won’t be Cocoa all the way down.

Tuesday August 23, 2011

Smalltalk Running on Javascript

I know this isn’t related specifically to Cocoa, but I’m a sucker for stuff like this. Someone ported a Smalltalk implementation on top of the Javascript interpreter. Write Smalltalk, export Javascript. Welcome to the future.

Has anyone else noticed how Javascript is becoming the low level “byte code” of many things these days?

Saturday August 20, 2011

Google Drops a Load on Lodsys

Great news for companies under pressure from Lodsys. And it sounds like great news about the patent mess in general. Groklaw analyzes Google’s request to reexamine the Lodsys patents. It’s really thorough, but there’s a nice summary at the end:

Most reexamination requests rely on a finding of obviousness, which is a far more subject standard than demonstrating a lack of novelty. A lack of novelty can be established by any one piece of prior art that discloses each of the key elements of claimed invention. In each of these cases Google has identified not one, but five separate pieces of prior art that each alone demonstrates a lack of novelty in the critical Lodsys claims.

I like this. And I hope Lodsys gets smashed. Google, unlike many other companies, is a titan that has a vested interest in weakening the patent system.

Yes, Google just acquired a massive portfolio from the acquisition of Motorola mobility. Google’s no saint, but so far their business model doesn’t depend on using patents to offensively stop competitors or extract licensing fees. For now, Google’s in a good place to upset a system that causes havoc for the little guys and the company wants to be seen in that light. I’m okay with that.

Wednesday August 17, 2011

Aspect Oriented Programming with Proxy Objects

I found this interesting little library that uses proxy objects in Objective C to achieve aspect oriented programming. You can inject your own code before or after method invocations on other objects.

Too bad that the syntax is still so verbose. Cue the pining for MacRuby on iOS…

Tuesday August 16, 2011

✦ After CocoaConf 2011

I’m finally catching up after CocoaConf. For a first time effort, I was impressed with how well they pulled it off. Logistically trim, good WiFi (!), good food, and a great set of speakers.

I’m honored to be a member of that set. For those who came to my talks looking for slides, here they are in all their PDF exported glory.

UI Automation
MacRuby

And remember, the code and examples I used in the demo during my UI Automation talk come from my ongoing series.

I’ve never been to a conference that made such a big deal about soliciting feedback on the sessions. They wandered around every room handing out forms and pens while you were sitting in your seat waiting for each session to start. And every form you turned in gave you another ticket for a raffle. That makes for pretty low friction of participation. I walked away with a larger-than-expected stack of forms. Yeah, there were some unhelpful comments here and there, but it’s feedback nonetheless. I filtered it out and found it useful.

My favorite talk was Mark Dalrymple’s “Thoughts About Debugging”. It was a nice collection of wisdom gleaned from his life as a technical sleuth. Race conditions, untraceable third party libraries, spaghetti; I’m a sucker for well delivered anecdotes.

If you hear of CocoaConf coming to an area near you, check it out. They take it seriously.

Monday August 15, 2011

Nimbus, Rebirth of Three20

Jeff Verkoeyen’s Nimbus is a grand rewrite of Three20, a useful framework that had some interesting ideas at the time. It had a concept of “styles” you applied to UI controls, and it had a very forward thinking navigation mechanism where you used URLs to specify routes to and saved history of navigation controllers.

But it was horribly organized—a classic case of the “big ball of mud”. The tightly coupled components made it too opaque for it’s target audience to understand and augment. I considered it for a couple of projects, but looked elsewhere because I could smell the hassles of maintenance in this behemoth.

That’s where Nimbus sets itself apart. Jeff wants to rewrite it from the ground up. He cleverly calls his framework’s development pace “bounded by O(documentation)”. A worthy goal that I hope he can do. Many of the ideas in Three20 were way ahead of their time, even Apple like in style.

From Jeff’s goals:

Over the last year I’ve found that shedding baggage is not only an emotionally satisfying process, but also a necessary one. So I am shedding Three20’s baggage and out of the remaining bits building Nimbus.

Want more? Check out the article or linked archives.