Cocoa (Programmers Please Read)

Discussion in 'Mac Help/Tips' started by Wes, Dec 1, 2002.

  1. Wes macrumors 68020


    Jun 22, 2001
    I'm considering learning how to program in cocoa. How difficult will it be? Apple's documentation is a little too short for me so do you have any ideas for what a good book for a person with little programming experience, but lots of general computer knowledge? Thank you for any replies.
  2. bousozoku Moderator emeritus

    Jun 25, 2002
    Gone but not forgotten.
    I would start you off with the "Java for Dummies" book (I think I've seen this one). Although Java and Objective-C look somewhat different, they behave very similarly and have the same ancestor: Smalltalk.

    Being that you're not a programmer, the object-oriented aspects of these two languages would not be as difficult to grasp as with someone who's been programming for a while.

    Once you had a handle on object-oriented programming, I would think that O'Reilly's "Learning Cocoa with Objective-C" (ISBN 0-596-00301-3) could be accomplished. This is the updated version of "Learning Cocoa" which was a step-by-step tutorial (and was far too early to print) written by Apple staffers.

    After that "Cocoa Programming for Mac OS X" (ISBN 0-201-72683-1) from Addison-Wesley and "Building Cocoa Applications: A Step-by-Step Guide" (ISBN 0-596-00235-1), if you were really enthusiastic.
  3. Wes thread starter macrumors 68020


    Jun 22, 2001
  4. Choppaface macrumors 65816

    Jan 22, 2002
    try taking a class or finding an online group that works on a project

    its good to get out there with other programmers... books only teach you half of it
  5. bousozoku Moderator emeritus

    Jun 25, 2002
    Gone but not forgotten.
    Visually, Java and Objective-C are different enough to keep separated but you will find approximately 30 percent of both to be the same. If you like, I can probably find Apple examples written both in Java and Objective-C.

    Remember, Cocoa is not a programming language--it is a means to access the operating system and graphical interface, an application framework.

    As far as the "Java for Dummies" book, Sun's slogan for Java is "Write Once, Run Anywhere" so the operating system is definitely not an issue (these days!!), only the implementation of Java on that o.s.
  6. scem0 macrumors 604


    Jul 16, 2002
    back in NYC!
    I think that's just C, but i'm not sure.

    I have been taking C++ since school began and it is pretty easy.
    We are just now getting into arrays. I'm afraid that my background
    knowledge of computers isn't helping me that much in c++. I wish
    it were, but it is more logic then computer knowledge. It is a lot
    like learning a mix between english and another language.
    Someone who has had no prior knowledge of c++ could read
    through one of my programs and basically know what it would do.
    It is kinda like, as we say in texas, Texican. The mixing between
    English and Spanish. There are a lot of Texicans in Texas. c++ is
    no different from texican, except for the fact that they are totally
    different. LOL, that made no sense, but I think you understand.

  7. cubist macrumors 68020

    Jul 4, 2002
    Muncie, Indiana
    No, Objective C is neither C, nor C++.

    Objective C was an attempt to graft the Smalltalk concept of "everything is an object" into a C syntax. It is not very C-like, nor is it particularly Java-like.

    C++ is an attempt to add classes to C without doing too much damage to the C syntax and compilation. The result is not very pleasing, and it doesn't do anything more than C, just much less readably.

    Java's syntax is based on C, but it has classes built in at a more fundamental level than C++. Many strengths of C (in particular, pointers) were stripped out to make programming in Java "safer". However, it's not a very good OO language either. One particularly painful omission is the lack of a destructor. Because of this, objects cannot deinitialize themselves as they are destroyed; the creator must explicitly deinitialize objects. Still, Java is a pretty good language, and the classes that are provided give a wealth of capabilities that are available on all the platforms supported. The chief downside of Java is slow performance, as it is interpreted bytecode (a la UCSD Pascal).

    Objective C is compiled, but because everything is an object, performance is nowhere near as good as C or C++. I wouldn't recommend learning any other language as a stepping stone to Objective C, as it differs significantly from all others, except perhaps Smalltalk. While Objective C compilers exist for Unix/Linux, the "frameworks" (class libraries) used in Cocoa are unique to Mac OS X.

    Squeak is an implementation of Smalltalk for the Mac. It may be worth trying.

    IMHO, of these languages, only Java is suitable for a beginning programmer (one with less than five years experience). The others are just too complex.
  8. crackpip macrumors regular

    Jul 23, 2002
    Learning Cocoa

    First of all, objective-c is a superset of c. It takes c and adds additional functions to allow for object oriented concepts. Thus all c libraries and c code should work in objective-c. I am not very familiar with c++, but its an object oriented language that takes its foundation from c, but is different. For example, I believe it requires its own libraries, as functions seem to be handled differently. I've read that there is a big fundamental difference between c++ and obj-c, in that c++ is a strongly typed language. Therefore, the types of all objects need to be specified at compile time. obj-c is at the opposite end of the spectrum. It allows you to specify most things at runtime.

    I'm new to obj-c, and so far most of my work uses obj-c and MPI. Since I don't have the foundation framework installed on the cluster I'm using, I haven't gotten around to doing anything original with cocoa. Still, I like the book by Aaron Hillegras a bit better than the O'Reilly book (I haven't looked through the new edition of the O'Reilly book, maybe its better). To me, Hillegras does a better job of explaining things as you work through the tutorials. The O'Reilly book kind of degenerates into a cookbook of programs (i.e. you can follow their recipes, but its more difficult to strike out on your own because they don't explain their reasoning).


    As a response to cubist, I've read that GNUStep, the opensource version of NextStep, has kept up with the Foundation framework. So basically if you make a Foundation Tool (basically a cocoa app without the gui), it should be portable to any *nix system that has GNUStep istalled.

Share This Page