I read some speculation recently imagining that Apple might be looking at Python as a replacement for Objective C. PyObjC is very a robust Cocoa-Python (and is used in the OS X version of Goombah); it's easy to create a Cocoa app with Python. Apple even has a developer note explaining how to do it and providing bullet points explaining their take on Python's advantages:
- Automatic Memory Management. Python is garbage collected, freeing you of most manual memory allocation bookkeeping. When you create an Objective-C object instance from Python, Python takes ownership of the object and manages its retain count on your behalf.
- Python is succinct. Python gets a lot of work done in a small amount of code, without being terse. Its expressive nature means you write less code to get any job done. And less code can lead to less bugs and greater productivity. Common tasks such as performing an operation for each element in a collection are one-liners in Python. And the built-in regular expression support makes processing text a breeze.
- Compile and link times vanish. Gone are the days of editing a fundamental .h file, and having to wait for a recompile of your entire application. When change is cheap, you'll be able to explore more options, faster. (Though you can compile Python, during development you'll probably want to skip compiling and execute your application via the source interpreter.)
- More Dynamic. PyObjC builds on the Objective-C runtime, enabling even more dynamism. For example, PyObjC allows you to create Cocoa-compatible classes at runtime, even allowing you to create new methods while your app continues. PyObjC comes with an interpreter window you can add to (or inject into) your application, enabling instant control and inspection over your application's objects.
I just today brought up Apple's FileMerge app for the first time in a while. And I noticed a major change since last time I used it -- it now parses Python files enough to be able to provide a pop-menu menu allowing navigation to classes, methods and functions in each file being merged.
I'm not saying this makes the speculation about Apple and Python true or even probable. I haven't checked out whether it parses other languages such as Ruby. In any case it is interesting to see Apple further embracing Python.
Recent Comments