Time for Cocoa

I've always wanted to get into Cocoa programming. I like the look and feel of a good Cocoa app, and folks I respect tell me that it's a wonderful environment. But, to be honest, I've always been somewhat put off by the way that Cocoa programming is tightly coupled to Xcode and Interface Builder. I've never really liked IDEs, simply because in the past they've felt like they're in my way.
So then Daniel Steinberg twisted my arm and got me to edit his new book, which introduces Cocoa programming to people who are already programmers in some other OO language. Trying to be a good editor, I gritted my teeth are fired up Xcode and started to follow along with his tutorial chapters. And, somewhat to my surprise, I had a working (if minimal) web browser up and running in a few minutes. I added buttons, and later a progress bar, and it all just worked. So now I've changed my opinion. Cocoa is a really well thought out framework, but the tight integration with Xcode and IB make it very, very sweet. I'm looking for an excuse to spend some serious time writing a decent-sized app with it.
In the meantime, if you're like me, and want to dip a toe into Cocoa development, I'd recommend his Cocoa Programming: A Quick-Start Guide for Developers. If you're more of a hands-on learner, the good news is that Daniel and Bill Dudney will also be running a great 3-day Cocoa Studio at the end of October. It's in the amazing Inverness facility in Denver (which I'm at right now, teaching a Rails Studio with Chad).




When you wrote, "Cocoa is a really well thought out framework, but the tight integration with Xcode and IB", I thought you were going to follow it up with, "makes it a pain in the ass to use with anything else."
I think Cocoa is well-designed too, but I'm more interested in writing applications that work on multiple platforms. That's why I stick to cross-platform APIs, though lately I've been using XULrunner a lot, which also makes it easy as pie to get something up and running quickly.
Posted by: Steve | September 17, 2008 at 10:25 AM
I've been blogging my forays into Cocoa/Xcode/IB/Objective-C. Being a .NET guy on Windows, it's been interesting, but it hasn't been frustrating. Objective-C is interesting, and the apps don't look all that bad either. Like any tool, it has its quirks, but overall it's not that bad.
Posted by: Jason Bock | September 17, 2008 at 10:36 AM
Dave, certainly Xcode and IB are the usual / suggested route, but you don't need to use either to write a Cocoa app - the UI can be written programmatically (not within IB), including bindings and target/action stuff, and the Obj-C editing can be done in whatever you want (TextMate if you're already using that for Ruby, or emacs / vi etc.). It builds using the Apple Developer Tools gcc (so you do need them installed).
The problem is more that the docs assume you're using Xcode and IB, so most people would have to go through that before they can go with their preferred editor etc.
But may I suggest you play more fully once you've released the new edition of the Agile Rails book... OK I'm just being selfish now ;)
Posted by: The Boy Ken | September 17, 2008 at 11:13 AM
Ken:
I appreciate that you can use TextMate and friends, but for the first time I actually see that I might prefer to use and IDE (Xcode) for development. I'm a firm believer that there's not one true editor or one best tool: I'm always looking for the best tool for the job at hand. For Ruby code, I use Textmate. For editing books, I use Emacs. And, now, for Cocoa programming, I'd use Xcode. I was just surprised to find myself liking it.
Dave
Posted by: Dave Thomas | September 17, 2008 at 11:34 AM
@steve: You mean cross-platform APIs like Win32? I think you're missing the point of Cocoa.
Xcode, Cocoa & Carbon are tools and APIs for building native Macintosh and iPhone/iPod applications. If you have cross-platform considerations for you application then Cocoa is not the right tool. This is just as much the case for Win32 or UNIX native applications. There is still a need, and probably will be for a really long time, to have native applications. You can provide a much better user experience when building to a specific platform.
Cocoa is the "crown jewel" of what makes the Macintosh such a great user experience for both end users and developers alike.
I am in agreement with Dave, Xcode is the only IDE I actually enjoy using. I am stuck in a Java world in my day job (I'm a Ruby programmer by night and tinker with Cocoa when I can). So that means I'm stuck living in a Java based IDE pretty much all day.
The nature of Java today pretty much dictates that you'll be using one of their IDEs. There's just to much boiler-plate code involved in Java applications to forego the IDE. And no matter how much work goes into creating these Java IDEs, they never have the great "native" feel of Xcode and IB.
Posted by: Robert Walker | September 17, 2008 at 04:41 PM
@Robert Walker: No, you are missing the point of Steve's comment (and since when is Win32 cross-platform?). He just said that he's more interested in using cross-platform APIs like XUL or Qt (or soon GTK+) and not proprietary and single-platform ones like Cocoa. And I happen to agree with him.
Posted by: Robin | September 18, 2008 at 09:05 AM
@Robin: First you imply that Steve was just stating his _preference_ of working with cross-platform APIs, then you say you agree with him. That makes no sense. You can hold the same preference, but, since a preference can be neither wrong nor right, you can't agree with it. Unless you mean that you agree with Robert's notion that since cocoa is not cross-platform, it is not adequate.
In that case I would ask what you and steve actually _said_? What did you contribute by your comments? If you decide to write an application for multiple platforms, of course you aren't going to choose cocoa (just like you wouldn't choose gtk to write a native windows app). Why does that even need saying, except for purposes of verbal [self-pleasuring]? (ahem.) It's the equivalent of calling all the companies in the phonebook who's services you _don't_ need that day to say, "I just wanted you to know that I will not be requiring your services today." Its not necessary or helpful to anyone involved.
My gut tells me that the purpose of both comments was to bash cocoa and its IDEs (and win32, et. al.) because they are not free (open) tools and your ideals cause you to harbor hate for them for these reasons. That's a shame.
Posted by: Fabio | September 24, 2008 at 08:02 PM
@Robin: "and since when is Win32 cross-platform?"
I'd like to introduce you to sarcasm...you guys will get along quite well.
Posted by: Brent | September 27, 2008 at 03:19 PM
@Dave: "For editing books, I use Emacs."
Could you expand on why you prefer emacs for editing books Dave?
And also, do you specifically mean "editing" as opposed to "writing"?
What do you use for writing? Can you recommend a toolset/workflow for would-be technical writers?
Thanks for the quality of content in your work and products.
Posted by: Don | October 02, 2008 at 10:58 AM
@don: I meant to say "editor I use when writing books." The killer feature of Emacs is filladapt-mode, which wraps intelligently as I type.
Posted by: Dave Thomas | October 02, 2008 at 11:17 AM