Friday, September 4, 2009

Goodbye to all that



This post is about Apple-specific programming issues, so feel free to move on if you don't care about both subjects. Perhaps the title is premature, and it is certainly melodramatic. But my recent upgrade to Snow Leopard broke my programs written using the PyObjC bridge (like HeatMapper), and what it looks like to me is that PyObjC is headed for the ash heap of history.

That pisses me off. The advantage of doing what I have been doing is to get a shiny GUI almost for free. Now comes the hurt, everything has to be redone, no matter what. If I have to learn get good at Objective C and integrate my Python parts with the ObjC parts, it's not such a good deal any more. Going the SVG route makes much more sense.

What happened: the app failed to launch, but that was no big surprise. Upgrade and s**t happens. So I go to XCode (the latest, v 3.2), and try to re-compile the project.

..._bridgesupport.py", line 53, in _parseBridgeSupport
))
ValueError: Unknown typestr...


This happens when I do "import Foundation", which works, by the way, from the command line. I am suspicious, because Snow Leopard is not such a simple upgrade. 64-bit is wild. (Read Ars Technica).

But that's fine, I say, I can just fix what's wrong. So first I need a working PyObjC application. I go to create a new Project, but it turns out the templates for PyObjC stuff are no longer included in XCode.

You'll need to download and install the templates from the PyObjC repository or web site.

The templates were pulled from the release because the template development moves at a different pace & schedule than the Xcode releases. Too often, the templates have been out of date by the time the discs were pressed.

b.bum


No problem, I say, I'll just download the templates...

svn checkout http://svn.red-bean.com/pyobjc/trunk/pyobjc/pyobjc-xcode/Project%20Templates/

Follow the instructions in the readme...Look in XCode: there is a new thingie called User Templates. Make a new project using the template...it dies with the same error.

So I google: "leopard ValueError: Unknown typestr" and I find this:

As the maintainer of PyObjC for nearly 15 years, I will say it bluntly. Use Objective-C. You will need to know Objective-C to really understand Cocoa anyway and PyObjC is just going to add a layer of bugs & issues that are alien to 99% of Cocoa programmers.

– bbum 2 days ago


Can't get any more blunt than that. And I find this:
To be blunt:

If you want to be an effective Cocoa programmer, you must learn Objective-C. End of story.

Neither Python or Ruby are a substitute for Objective-C via their respective bridges. You still have to understand the Objective-C APIs, the behaviors inherent to NSObject derived classes, and many other details of Cocoa.

PyObjC and RubyCocoa are a great way to access Python or Ruby functionality from a Cocoa application, including building a Cocoa application mostly -- if not entirely -- in Python or Ruby. But success therein is founded upon a thorough understanding of Cocoa and the Objective-C APIs it is composed of.

b.bum
It is early days yet for Snow Leopard. Maybe it'll get fixed. You have to understand: Bill Bumgarner is the man. Well, him and Ronald Oussoren.

So what it looks like is that:

• Python is great on the Mac---from the command line
• PyObjC was fun, and great for the amateur programmer
• but, it was basically a complicated hack (thanks Bill and Ronald)
• I should follow bbum's advice and learn Objective C (it'll take time)
• you cannot depend on PyObjC to get you to Cocoa
• in the meanwhile, I am going to make my graphics with SVG

One bonus of this, of course, is that it'll be useful for people with PCs. But I think it's a sad day. Apple should think more about people who play on their computers but are not (smart enough or don't have the time to be) experts.

2 comments:

Ronald Oussoren said...

PyObjC is still being developed. I'm doing all development in my spare time, without any funding. This results in a fairly slow development pace.

Ronald Oussoren

telliott99 said...

So the first thing to say is "thank you, Ronald." And then say it again. I've benefitted more from your efforts than I can say. And if I had any clue how to fix what's wrong I would. I will update when I can. In the meantime, I spent all day working on re-writing the application in Objective C. I am about 20% of the way...