Cocoa is Awesome.

I’m just getting started with Cocoa, and I’m having difficulty believing just how easy it is to do useful stuff. Today I wanted to open a dialog box to add a folder path to an object in a Core Data store. “Sigh”, I thought, “This will be a pain.” Fast forward just 10 minutes, and I’d implemented the basics of what I wanted:

NSOpenPanel* openDlg = [NSOpenPanel openPanel];
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
  NSArray *folderToAdd = [openDlg filenames];
  NSString *folderToAddPath = [folderToAdd objectAtIndex:0];
  NSManagedObject *projectToAdd = [[NSManagedObject new] initWithEntity:projectEntity insertIntoManagedObjectContext:context];
  [projectToAdd setValue:folderToAddPath forKey:@"FolderPath"];
  [context save:NULL];
}

“Hmm. That’s cool. But I want the user to only be able to select directories and disable multiple selection.” A quick look at the documentation for NSOpenPanel yielded:

[openDlg setAllowsMultipleSelection:NO];
[openDlg setCanChooseFiles:NO];
[openDlg setCanChooseDirectories:YES];

“Er… Wow. That was seriously easy”, said I, “But surely getting the selected folder name will be tricky?” Wrong. A little more research and two lines of code later, I’d done it.

NSArray *folderToAddPathArray = [folderToAddPath componentsSeparatedByString:@"/"];
NSString *folderToAddName = [folderToAddPathArray lastObject];

It seems that every feature I want to add, provided it’s commonly used, is ridiculously easy to implement. I’ve only been using Cocoa for a matter of days – I wouldn’t even describe myself as a amateur. And yet I can implement features that I thought might take me ages in the blink of an eye.

Cocoa is incredibly well designed and brings Apple’s “It just works” philosophy to the programming world. As I’ve already said, it’s very, very early days for me as a programmer, and I’m sure there will be frustrating times up ahead, but so far I’m very happy. Almost too happy… (cue haunting music).

One problem with this extraordinary ease of use is that I feel like I’m continually cheating. I’ve not come from a traditional programming background, but I have caught a glimpse of programming in other, shall we say, less friendly environments (*cough* Java). I used to program embedded microcontrollers, where you needed to write 10 lines of code just to store a text string. I’ve also come from the Microsoft world – I once spent 14 hours trying to figure out how to set up a linked server to read an Exchange Server database in SQL Server. So the idea of creating a new database entry that appears in a table view in 2 lines of code is a real culture shock, and if I’m truthful, makes me feel like a bit of a freeloader. After all, some programmers out there are having to implement their own accessor methods, write lots of custom code just to make a connection to a database and deal with developing in languages that need a third-party framework installed to get them to do anything useful. And here I am, with only half a clue and no previous exposure to object-oriented languages cobbling together what I need in 10 lines. It doesn’t seem fair somehow.

This may well mean that when things get a lot more involved, I’m out of my depth. This code is not production by any stretch of the imagination – it’s only for a prototype. I’m sure that the time will come where the things I want to implement are much more challenging as I have yet to experience the joys of threads but I’ll cross those bridges asynchronously when I come to them. Whilst maintaining a stringent locking strategy, of course.

For now, I’m just going to enjoy using a tool that seems to deliver on the promise “Common things are easy, and uncommon things are possible”.

Thanks, Apple.

Stagnation of Mac Software

I’m frustrated with the stagnation of Mac software. OK, before you all stab me in the eyes with flaming toilet tissue, let me clarify slightly. It’s not the stagnation of implementation. I know that modern Mac software is fabulous to use and looks drop dead gorgeous – with one or two exceptions, of course (such as terrible new UI bits of Leopard or MS Office).

It’s the stagnation of function. What problem does the software solve? We seem to have an endless stream of similar solutions to already well catered for problems. Another FTP client. Another money manager. Another Subversion front end. Another browser.

Trust me – I get the premise behind a lot of these products – “Product X does the job OK, but it could be so much better! I reckon I could make a much nicer UI. And I could definitely implement feature X a lot better.” It’s also makes perfect business sense – there’s an established market for the product and there’s a good chance users are bugged by that substandard UI too.

“What’s wrong with improving existing solutions?” you might ask. Nothing. It’s a great thing – it means at the end of the improvement road we get a wonderfully polished application. But we also need a balance between tweaking existing solutions and building the next iteration of solutions for problems that have sat for years without any substantial progress.

There are already a smattering of innovative applications out there: programs like Marco Polo, F-script, Voodoo Pad and Delicious Library all do something novel, unique and interesting. But there just aren’t enough.

Certainly, we’ve got some remarkable applications that solve the problem better than some may have believed possible – Things, Versions, Coda and TextMate – but these applications are now so polished that we just can’t improve any more. Can anyone imagine a significantly better torrenting client than Transmission? A vastly better news reader than NetNewsWire?

We seem to have become hung up on implementation. How nice does the app look? How usable is it? How many features does it have? Of course, all this stuff is vital, but we seem to develop new software within the context of existing software – “it’s like Word but better” – instead of looking for the unexplored territory.

This unexplored territory doesn’t take much looking for either – it’s sat there staring us in the face every time we use a computer. Some examples? OK…

Filing

What about a good way of filing and retrieving our documents? We’ve become totally dependent on the filing cabinet analogy. “So what?”, people say, “if we forget where we put something we can type into a box on the desktop and select from a list”. The computer has then got to search the index which is slow and returns results, at least in Mac OS X, in a constantly updating list. This approach leads to a horrible user experience that’s more circus fairground than file search – “Roll up, roll up! Can you click on the document you want before it disappears? It’s a true test of skill and reflexes, Ladies and Gentlemen!”. Every time I have to save or open a document I need to browse to the project folder all over again and I end up wanting to gnaw my own hand off with frustration. And yes, I know there are some nice applications out there like Default Folder X, Leap and Path Finder that take some of this pain away. But I still think we’ve got a long way to go – these applications feel like band-aids to solve a much more fundamental problem of how we store our data.

Window Management

Why on earth do we not have any decent tools for managing windows? If I want 4 Finder windows tiled I still have to do it manually. The lack of a proper maximise in Mac windows is a complaint that has been very well documented and yet we’re still living with it. And then there’s that lovely moment when you miss clicking on a scroll bar by one pixel and you switch to whatever random window is hiding behind your current one. If you’re trying to do work, your windows rapidly degenerate into a complete mess. And no, neither Spaces or Expose are proper solutions to this – they are clumsy workarounds that miss the point.

I think maybe these and other similar problem areas aren’t given enough priority because we don’t really see these as problems any more. We’ve got so used to working round them or gritting our teeth and battling through that they’ve become just another fact of life.

But I believe that they can be solved in a way that tackles the root cause of the problem. So I’ve decided to take the plunge and develop my own bit of software to provide a solution for a problem I face every day. I’ll be providing more details in a future post.

I have a blog. And you’re reading it.

Hello to all those people who have just found my new blog.

Which you are now reading, just in case you were wondering about your current activity. This paragraph could get existential fast, so I’ll just move on.

OK, so what’s this blog going to be about? Well, it will focus on my new adventures in programming my own bit of software. I’m doing this because there will be many challenges and excitements ahead and I’d like to share them with a few people. I could go into more details here, but I’ll save that for a future post. In the meantime, welcome.

Look at the date. Spot what I’m not saying in this message. That’s for a good reason – I think New Year is utterly meaningless. Also to be saved for a future post.