Re: how is C often used in Cocoa, if at all?
Re: how is C often used in Cocoa, if at all?
- Subject: Re: how is C often used in Cocoa, if at all?
- From: "John Notis" <email@hidden>
- Date: Tue, 11 Feb 2003 18:31:36 -0800
After reading another response from someone who may be a more seasoned programmer, I feel the need to make some points that would have been _very_ useful to me a year ago. After a while, people seem to take the learning curve for granted, and don't realize how much they've internalized about what they know. I'm still pretty much of a newbie, so maybe I'm coming from a similar standpoint.
>
And I'm wondering if C is used much in writing Cocoa applications? It
>
doesn't seem to be, from what I've read on here, or have I got the
>
wrong impression there?
Cocoa apps ARE written in C. C with some extras tacked on to support object-oriented ways of getting things done. Most of the questions on here are about the Cocoa parts of the programs, but I've seen several cases where folks are stuck because they don't understand C and how the basic rules affect what they're doing.
>
How often, and how is C often used from within Objective-C and Cocoa,
>
if at all? Are there some things that lend themselves well to being
>
written in straight C, and other things that don't? Which sort of
>
things? Is it just a matter of preference and ends up being easier not
>
using C?
>
>
I know these are very broad questions but I'm just trying to get an
>
understanding of how C fits in generally with Obj-C and Cocoa.
The relationship between C and Obj-C and Cocoa is something I've just figured out, because I discovered I couldn't write a program to do what I wanted. C is a very basic language that is fast because it deals with things fairly close to the way the computer actually deals with them. You can separate out the different chunks of the program into separate routines that each do a separate job, but in the end, they can all "see" each other's data and depend on each other very closely.
Obj-C gives you a few more rules and keywords/symbols that you can use to separate out the different chunks of a program into logical objects that are less interdependent. This makes development by big teams of programmers much simpler, because everybody just writes their own little chunk. You can't write much of an Obj-C program without using any C in between the bits that define the objects. You can, however, write huge Obj-C programs without a single reference to Cocoa.
Cocoa is a set of pre-made objects (a framework) that make it incredibly easy to do many common things under Mac OS X. It's actually TWO sets of Obj-C objects, the "Foundation" and the "Application Kit". The stuff in the Foundation is generally behind the scenes utilities, while the Application Kit is generally for dealing with all of the pretty Aqua user interface items in a program. You can use the Foundation Kit to write command-line apps that run in a UNIX terminal and never show anything but text output, but AppKit will not work outside of the Aqua windowing environment.
There are also a ton of other frameworks out there, most of which are not written in Obj-C. You probably have about 100 on your machine right now. Run the Apple System Profiler and click the Foundations tab to see what you've got. Most of them are pretty specific to certain tasks (eg. TheaterMode.framework is just for playing movies in theater mode), but some of them are big and indispensable. I was forced to learn about IOKit.framework after I couldn't find anything to talk to a USB device in Cocoa. It's just plain old C procedural function calls. Cocoa is a really big, really nice, modern, polished framework, but it doesn't do everything.
I may have digressed a little here, but my suggestion is to work through a C course, and then move to Cocoa.
Two excellent sites:
http://www.le.ac.uk/cc/iss/tutorials/cprog/cccc.html
http://www.macdevcenter.com/pub/ct/37
Look at the bottom of the second site, and work your way up.
I hope this is useful info.
-John
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.