The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

phobjc vs objective c disadvantages?

Hi All,

I want to start building applications for the mac os x, but i'm unsure of which language to start learning.

I come from a very strong Java background, and because of this I think i'd prefer coding in Python.

However, is there any disadvantage using PyObjC rather than just learning objective c?  Does the PyObjc lack in any area  that objective c offers?  I know that python is an interpreted language and hence may not be as fast as an objective c language, but i can accept this.

~gav
Gav Newalkar Send private email
Sunday, February 18, 2007
 
 
"I come from a very strong Java background, and because of this I think i'd prefer coding in Python."

Um... why?  Surely Objective C has more in common with Java than Python does?
Iago
Sunday, February 18, 2007
 
 
Start with Objective-C.  It's the native language of the Cocoa frameworks, and it does pay to learn them in their native language so you don't have to always figure out how to figure out how to translate what the documentation is telling you into what your tools will want.

Also, regardless of the route you choose, the vast majority of your effort will be spent learning the frameworks themselves rather than the language.  Objective-C is just a set of lightweight additions to C; any experienced developer should be able to pick it up easily.
Chris Hanson Send private email
Sunday, February 18, 2007
 
 
The first language I learned was Turbo Pascal in my school days.

After that I learned C ***in a day***.

I still code in plain vanilla C without any frameworks like MFC, though I use some features of C++ like function overloading, struct functions, automatic virtual destructors (for automatic memory management).

I think phython is a derivative of lisp, though I may be wrong about that.  Lisp is worth learning for its own sake, though you may not use it for any projects.

What's wrong with learning both?  If I can learn C in a day, so may you.  So you can learn C and Phython in two days?

Also be sure to read this:

 http://www.paulgraham.com/icad.html
Donald Duck
Sunday, February 18, 2007
 
 
"However, is there any disadvantage using PyObjC rather than just learning objective c?"

Even though Apple bundles Python with OS X, you cannot easily guarantee that your customers will have the correct version of Python installed, or even that they do have it installed.

For a back end server room type of application, this is typically not a problem - system administrators will usually be comfortable with installing Python or keeping the versions in synch with your application. For a consumer desktop application, this is potentially a serious issue because they want your application "to just work."

Objective C "universal binaries" are about as independent as you can get (assuming you don't link to third party libraries at compile time).
TheDavid
Tuesday, February 20, 2007
 
 
Iago: "Surely Objective C has more in common with Java than Python does?"

I'd say Python and ObjC have more in common with each other than either has with Java. The ObjC runtime isn't quite as flexible as Python's, but it's still a lot more dynamic than Java's.


TheDavid: "Even though Apple bundles Python with OS X, you cannot easily guarantee that your customers will have the correct version of Python installed, or even that they do have it installed."

This is really a non-issue. Just install the latest Python framework from http://www.python.org/download/ and tell py2app (which you should be using anyway) to build your application as standalone; py2app will include your Python framework plus all dependendencies in the application bundle.

...

To the OP: if you're already comfortable with C I'm inclined to agree with Chris H. given that the Cocoa documentation is written for ObjC, most of the example code you'll see is written in ObjC, etc., so it's a little less to think about when finding your way around the Cocoa frameworks (which is the real work). That said, I started off in PyObjC and didn't find it that much more work; most of the Cocoa APIs map directly across, and you quickly get in the habit of translating from one to the other.

Which ever way you do go, don't forget that once you've got the hang of Cocoa programming in one language, picking up the other language should be pretty quick; e.g. you could learn ObjC first, then pick up Python once you're comfortable in that.

Using PyObjC certainly has its advantages:
- Python's a higher-level language, so code tends to be shorter and more readable
- memory management is 99% automatic (while ObjC's semi-automatic retain/release/autorelease system doesn't take long to get the hang of, it's still more work)
- high-level exception handling is ubiquitous (ObjC does support exceptions, but they're not so heavily used so you still tend to write some old-timey error code)
- you don't have a compile-link stage, so making and testing changes should be faster (see also py2app's --alias option).

Also, PyObjC provides full two-way bridging, so it's straightforward to, say, build and test your prototype in Python, then profile it and convert any bottlenecks into ObjC later on.

Relative disadvantages of PyObjC:
- including the Python framework in application bundles adds approx 8-9MB to the file size (or 4MB by the time you zip/dmg it for distribution)
- if you're a fan of static typing, Python supports dynamic typing only (ObjC supports both)
- applications take longer to launch (2-3x?), due to the extra binding that has to be done
- Python bytecode is easier for third-parties to decompile than ObjC binaries.

Anyway, if you want to discuss PyObjC further, the PythonMac-SIG mailing list (http://mail.python.org/mailman/listinfo/pythonmac-sig) is the best place to go.

HTH
has Send private email
Tuesday, February 20, 2007
 
 
I didn't know about py2app so I withdraw my initial objection.

However, the disadvantages Has came up with, have kind of soured me on the prospect of developing consumer "shrinkwrap" code for the desktop. It does sound like it's practical, maybe even better than Objective C for the server though.

So it does depend on what your application will do (beyond the GUI aspects already discussed).
TheDavid
Tuesday, February 20, 2007
 
 
"""However, the disadvantages Has came up with, have kind of soured me on the prospect of developing consumer "shrinkwrap" code for the desktop."""

Didn't mean to make it sound like any are deal-killers. An extra 4-5MB on a .dmg download is tolerable on dialup and insignificant on broadband; C is hardly renowned for having the best static type system anyway; the slower startup times are a little irritating but not unacceptable, and there's techniques for reducing these (e.g. defer loading of nibs until they're needed). The disassembly issue is the only one that may be a significant problem if you've super-sekrit code to protect. However, if somebody really wants to reverse-engineer your program they will, regardless of what it's written in - .o instead of .pyo files will merely slow them down a bit.

...

Anyway, I notice there's some discussion of Cocoa programming with ObjC vs Python/Ruby/etc. going on in the blogosphere at the moment that may be of interest, so here's a random link into it:

http://www.friday.com/bbum/2007/02/16/c-portable-macro-assembler

HTH
has Send private email
Wednesday, February 21, 2007
 
 
has Send private email
Wednesday, February 21, 2007
 
 
guys, thanks for all your suggestions.  i've also taken some time to look at how PyObC works and I think I'll stick with objective c.

once again, thanks to everyone here for their suggestions.
Gav Newalkar Send private email
Wednesday, February 21, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz