Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Learning cocoa/obj-c what books do I need?

Learning cocoa/obj-c what books do I need?
Thread Tools
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 26, 2002, 07:04 AM
 
I Would like to learn cocoa, but I don't know any other languages. What books do I need to learn all the stuff I need to know?
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Feb 26, 2002, 09:28 AM
 
If you don't know any other languages, it would be a good idea to first learn C or C++, as the Cocoa books do not go into detail about this. You definitely need to know C. Learning C++ will just help you understand Object Oriented Programming as you move to Objective-C. Once you have the language down, Aaron Hillegass' Cocoa Programming for Mac OS X is the best place to start for learning Objective-C and Cocoa.

As far as C/C++ are concerned, there are plenty of places online that you can learn the basics. I found the Deitel & Deitel books to be VERY informative on the language. However, it's basically a huge reference book (like an encyclopedia) and isn't something you would really want to sit down and read all the way through. A programming language is something you should be able to pick up entirely within a week or two. There are sufficient sources on the internet for that.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 26, 2002, 12:06 PM
 
So, do I need to learn C or C++ or both? What would be the best book on that. I plan on using the obj-c book on the dev tools cd.
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Mac Elite
Join Date: Jul 2001
Location: Evansville, IN
Status: Offline
Reply With Quote
Feb 26, 2002, 12:41 PM
 
Originally posted by mattstoton:
<STRONG>So, do I need to learn C or C++ or both? What would be the best book on that. I plan on using the obj-c book on the dev tools cd.</STRONG>
Get Bjourn Strousoupe's (I know i just killed his name) book. He is the creator of C++. No one better to learn from than the creator. If you wanna have a more watered down, easier to read book, get one of the Dummies Books. Most of their code is made for DOS though, from what I read in the books.

Hope it helps.
Justin Williams
Chicks Really Dig Me
AIM - iTikki [NEW AND IMPROVED!]
http://www.tikkirulz.com
     
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 26, 2002, 12:43 PM
 
What would be the name of that guy's book?
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Feb 26, 2002, 12:59 PM
 
his name is Bjarne Stroustrup

edit: sorry, you asked for the book's name; it's "the c++ programming language" -- not very surprising...

[ 02-26-2002: Message edited by: seb2 ]
     
Dedicated MacNNer
Join Date: Dec 2001
Location: Bolton, UK
Status: Offline
Reply With Quote
Feb 26, 2002, 01:02 PM
 
If you want to learn Objective C, don't start by learning C++. They have rather different notions of object, and (personally) I find the Objective C version easier to understand. You should start by learning C, and Kernigan & Ritchie is as good as anything. I learnt Objective C from the online stuff that comes with the developer tools, and no, I hadn't used C++ before.

You can learn Cocoa by playing with AppleScript studio. This uses the same cocoa api as Obj-C and cocoa-java, and you can mix them, so you can start by writing in applescript then gradually rewrite the slow bits in Obj-C.

Cocoa and the Apple dev tools are some of the best things about mac OS X, and great fun to use.

Barney.
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Feb 26, 2002, 01:27 PM
 
Hi Matt,

The best advice I can give is that you learn by coding. Start out with Hello World in C or C++ and make sure you understand every line completely. Off the top of my head...
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
#include &lt;iostream&gt;

int main()
{
std::cout &lt;&lt; <font color = red>"Hello, world!"</font> &lt;&lt; endl;
}
</font>[/code]

Learn the syntax of C because objective-C sits "on top of" C. In other words, learn what things you put in a file, how to declare a function, what a single line of code consists of (some combination of an assignment, a control statement, or a function call).

Once you totally understand Hello World, give yourself an overview of libraries and APIs. You can (and will) access C libraries from Objective-C. These allow you to do stuff like square roots, random numbers, etc... Don't memorize the stuff - just be aware of what broad categories are available. This way, when you need something, you know where to look to find the specifics.

Now do the same with the Cocoa APIs. Don't memorize the stuff, just be aware of what broad categories are available. For instance, you'll want to know that you can do stuff with windows, documents, buttons, etc... Now when you need something specific, you know where to look.

Finally, grab Apple's Currency Converter tutorial and do it, making sure that you understand everything completely. Once you do, start modifying their tutorial to do something else.

Before you know it, the tutorial will have morphed into a theme switcher.

Good luck - let me know if you've got any specific questions.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 26, 2002, 01:37 PM
 
I don't think I'm up to learning by doing. I don't even know where to find these API's. I have a loose understanding of how the syntax goes. If I knew C or something close to it I'd do what you suggest but I have no idea what I'm looking at (code). I think I could probably learn cocoa by doing it if I knew C and obj-c, but I don't think I can otherwise.
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Feb 26, 2002, 02:43 PM
 
Hmmmm... C/C++ tutorials

C libraries - these are C calls that can be used on any platform, not just OS X. You should be aware that they exist so that if you need one, you can go look up the specific call.

Cocoa API documentation (also available on your hard drive at /Developer/Documentation/Cocoa/CocoaTopics.html)

My point in the previous post (which I guess I should have stated) is that nobody knows C or objective-C. They're too big. Learn the syntax and learn what capabilities (libraries and APIs) are available, so that when you need something, you know where to look. The tutorials should teach you the syntax, and the links above show the libraries and APIs.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 26, 2002, 02:53 PM
 
Hmm, all I need to do what I want to do in cocoa is make calls to cocoa frameworks. What does C have to do with this? Couldn't I just learn obj-c then cocoa? If I really need to know C then I want to learn it from a book. I have no confidence in my abilities
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Mac Enthusiast
Join Date: Sep 2000
Location: Louisiana
Status: Offline
Reply With Quote
Feb 26, 2002, 04:02 PM
 
Originally posted by mattstoton:
<STRONG>Hmm, all I need to do what I want to do in cocoa is make calls to cocoa frameworks. What does C have to do with this? Couldn't I just learn obj-c then cocoa? If I really need to know C then I want to learn it from a book. I have no confidence in my abilities </STRONG>
It's best to know C because of the syntax obj-c uses. It's just for the understanding.
B&W G3/300 OS X 10.3 Server
AL G4/1.5 OS X 10.3
Next computer G5/3.X Ghz OS X 10.x.x
     
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 26, 2002, 08:51 PM
 
Hi, I'm also busy learning ObjC and I'll give you a run down of what I've come across so far.

1. Those who have said to learn C do have a point, to be more precise they have a pointer You will not get by in ObjC without learning at least theoretically what pointers are. You will at least have a good founding if you learn what the basic data types of C are, such as char, int, C strings, arrays, structs, unions and pointers. Also it will help you to know how C functions differ from ObjC methods. Memory assignment in C will also give you a good founding for when you get to ObjC. I recommend O'Reilly's "Practical C programming" for an excellent and quick guide to C.
2. Those who said you should learn C++ have less of a point from my point of view. There are various schools of thought in the Object oriented world, the two main ones being the Smalltalk school and the Simula school. C++ comes from the simula school and Java and ObjC come from the smalltalk school. I found ObjC fairly easy conceptually after java but not very similar to that little bit of what I know about C++.
3. You will do well to look at the mac dev section at oreilly.net. There are some good articles there for Cocoa. Very good articles.
4. You are right that reading Apples ObjC pdf will give you a background in the language (be warned, it is very dry)
5. I got O'Reilly's Cocoa book, and it's not bad. But it doesn't explain the language very well at all. Go to the above sources for this (Stepwise.com also has some good links)
6. The person who told you to start with a small programme has a very good point: It gives instant gratification and positive feedback which you will need as you progress further.
7. I will repeat I think, what I said about C++. ObjC has dynamic features that are completely lacking in C++ and do have a lot of resemblance to those in java. i.e. dynamic class loading, protocols in ObjC are similar to interfaces in Java etc. This isn't to say you should go and learn Java, but rather that after getting a basic grasp of C move straight on to ObjC.

Anyway, I wish you luck.
weird wabbit
     
Forum Regular
Join Date: Apr 2001
Location: DC
Status: Offline
Reply With Quote
Feb 26, 2002, 11:29 PM
 
Hmmm, I have yet to attempt this, but can't he also use Java to write Cocoa Apps? I have only used the Java Swing implementation, but I recall an option for creating Cocoa apps with it. If so, then I would advise learning Java and using it to write your Cocoa apps.

-m
     
Mac Enthusiast
Join Date: Sep 2000
Location: Louisiana
Status: Offline
Reply With Quote
Feb 27, 2002, 08:32 AM
 
Yes, technically you can use java to write a cocoa app, but if you do, then you lose the portability of java, and the cocoa app will not be as fast as if it were written in Obj-c. If you want to write an app in java, use swing(as Aaron Hillegrass states in his book). If you want a cocoa app, use obj-c.
B&W G3/300 OS X 10.3 Server
AL G4/1.5 OS X 10.3
Next computer G5/3.X Ghz OS X 10.x.x
     
Forum Regular
Join Date: Apr 2001
Location: DC
Status: Offline
Reply With Quote
Feb 27, 2002, 09:43 AM
 
Well, the reason that I suggested Java was that it seems a bit more flexible than ObjC. Don't get me wrong, I haven't used ObjC, so as far as the quality of the language goes, I have no clue. However, if he learns Java, then he will have a dearth of references available to him, will learn solid OO skills, will be able to take it with him in the future, and will be able to write Cocoa apps immediately (instead of first learning C++ and then translating it to ObjC).

IMO, Java is the way to go if you're looking to pursue development further without just biting the bullet and taking C++ classes or getting a degree. However, if massive speed is a major issue, or you never plan on going outside of the realm of Cocoa, then ObjC is the way to go and you'd be better off basing your knowledge on C++. In this case, I would suggest learning C++ instead of C. C++ may not be a flawless language, but it teaches basic OO concepts (and breaks them, but that's not important right now). C may familiarize you with ObjC syntax, but really the most important aspect are the OO concepts.

-m
     
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 27, 2002, 12:54 PM
 
Originally posted by mefogus:
<STRONG>Well, the reason that I suggested Java was that it seems a bit more flexible than ObjC. Don't get me wrong, I haven't used ObjC, so as far as the quality of the language goes, I have no clue. However, if he learns Java, then he will have a dearth of references available to him, will learn solid OO skills, will be able to take it with him in the future, and will be able to write Cocoa apps immediately (instead of first learning C++ and then translating it to ObjC).

IMO, Java is the way to go if you're looking to pursue development further without just biting the bullet and taking C++ classes or getting a degree. However, if massive speed is a major issue, or you never plan on going outside of the realm of Cocoa, then ObjC is the way to go and you'd be better off basing your knowledge on C++. In this case, I would suggest learning C++ instead of C. C++ may not be a flawless language, but it teaches basic OO concepts (and breaks them, but that's not important right now). C may familiarize you with ObjC syntax, but really the most important aspect are the OO concepts.

-m</STRONG>
This is rapidly becoming a pissing match, but I will restate what I stated above. Do not learn C++ if you want to learn ObjC. This is very plain and simple logic. ObjC is a superset of C. C++ is also more or less a superset of C. But ObjC!=C++. What I mean by this is the simple fact that you will have to learn C whether you learn ObjC or C++. ObjC is NOT the same language as C++. It will teach you NOTHING to learn C++ and then learn ObjC. Learn ObjC!!! This is the mans goal. Both C++ and ObjC are fairly complex languages, but I can guarantee that you will learn ObjC in a shorter span of time than you will learn C++. Learning C++ will be an incredible waste of time because you will take a long time to learn C++ and will have to learn a completely different language and OO concept when you eventually get round to ObjC. ObjC has no multiple inheritence and C++ has no dynamic class loading. The syntax of the two languages are very different. You would be better off learning your OO concepts in ObjC itself.
You would probably be better off learning Smalltalk than C++, since ObjC's OO syntax derives from Smalltalk.
Java is fine and frees you having to learn any of the above crap. You would in fact, if you are a non-programmer, do yourself a favour as Java has a more consistent syntax than ObjC(mixed with C) and will teach you all you need to know to start programming. If you are just starting programming, you will not be writing the next PhotoShop in the near future in any case and will be happy just to have your first programmes running.
People who have been coding for a long time tend to forget what it is like to be a beginner and how imporrtant it is to have that sense of satisfaction when your first programme runs.
weird wabbit
     
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 27, 2002, 03:05 PM
 
Thanks. I'm going to buy Learn C on the Macintosh and the Cocoa book you guys suggested. I'd rather learn C as I want something fast... even if its hard.
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Addicted to MacNN
Join Date: Feb 2001
Location: zurich, switzerland
Status: Offline
Reply With Quote
Feb 27, 2002, 07:19 PM
 
Originally posted by mattstoton:
<STRONG>Thanks. I'm going to buy Learn C on the Macintosh and the Cocoa book you guys suggested. I'd rather learn C as I want something fast... even if its hard.</STRONG>
Sorry to be a pain yet again. But don't buy that book "learn C on the Macintosh". It is for the classical macOS(7.x to 9.x) and is of not much use on OSX.
weird wabbit
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Feb 27, 2002, 11:38 PM
 
Originally posted by theolein:
<STRONG>
Sorry to be a pain yet again. But don't buy that book "learn C on the Macintosh". It is for the classical macOS(7.x to 9.x) and is of not much use on OSX.</STRONG>
Agreed. If you want a book for learning C, I would suggest getting one for Unix. You're not likely to find one specifically geared for Darwin or OSX, so try for FreeBSD if you can; it's close enough that the examples should work without any modification. NetBSD would be even better, but the books will be harder to come by, if any even exist.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Feb 28, 2002, 12:00 AM
 
Originally posted by barney ntd:
<STRONG>You should start by learning C, and Kernigan & Ritchie is as good as anything.</STRONG>
I met Brian Kernighan today. He's nice guy, and a real genius. ;-)
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Feb 28, 2002, 12:19 AM
 
At the risk of saying "Me Too,"

Me too.

You don't need to know C++ to learn obj-C - all that it will teach you is the concepts of object-oriented programming; you'll have to throw away all of the C++ syntax you've learned. Don't bother.

Learning C on the Smac tells you how to program for old-skewl Mac OS, using the API set that morphed into Carbon. You'll have to throw it all out when you move to Cocoa. Don't bother.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
Senior User
Join Date: Sep 2001
Location: Closer than you think
Status: Offline
Reply With Quote
Feb 28, 2002, 06:42 AM
 
So what C book should I buy? I know someone who learned cocoa with Learn C of the Macintosh and he's pretty good.
New sig coming soon. Yes, it will violate the sig guidelines :p
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Feb 28, 2002, 08:23 AM
 
My opinion as loosely stated before is as follows: Deitel & Deitel write very good programming books--teaching languages. I understand what everyone says about why you shouldn't bother to learn C++. However, you can still use C++ when writing Cocoa programs, as the compiler supports C, C++, and Objective-C, all in the same program. In addition, you will have an easier time finding documentation for C++ than for Objective-C. If you can find a very thorough description of the Objective-C language that goes into depth about Object Oriented concepts, then by all means, read it. Personally, I haven't seen one of these yet. There are plenty of them for C++ and Java. A nice, large reference on either of these will teach you what Object Oriented Programming is all about. That's the point of learning C++ first. And let me reiterate: you can still use C++ in Cocoa programs. The restriction is that Cocoa itself uses Objectve-C. This doesn't mean that you can't create your own classes using the C++ programming paradigm. You won't have to throw C++ away once you start programming in Cocoa.

But if you can find an Objective-C book that actually teaches the Object Oriented Programming paradigm, the go for it. The one's I've seen assume you already understand OOP and just teach you the syntax--and the differences from Java or C++. These would be included as a single chapter in a Cocoa book--which is sufficient if you already understand what's being said. If not, well, it turns into a nice thick book.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Mac Enthusiast
Join Date: Jan 2002
Location: Trondhjem, Norway
Status: Offline
Reply With Quote
Feb 28, 2002, 07:55 PM
 
I learnt C from an O'Reilly book by Steve Oualline (Probably spelled his last name the wrong way...) Anyway, I completed the book in a short time (a few days), and skipped some irrelevant chapters. There are many code snippets to work with, I wrote code directly in a text editor (Emacs) and compiled it in the shell on a BSD Unix box.

This would help you understand C and Obj-C code. Afterwards, I had no problem reading Apple's document on Object Oriented Programming and Objective C.

[ 02-28-2002: Message edited by: alien ]
זרו
     
Fresh-Faced Recruit
Join Date: Feb 2002
Status: Offline
Reply With Quote
Feb 28, 2002, 08:24 PM
 
Originally posted by alien:
<STRONG>I learnt C from an O'Reilly book by Steve Oualline (Probably spelled his last name the wrong way...) Anyway, I completed the book in a short time (a few days), and skipped some irrelevant chapters. There are many code snippets to work with, I wrote code directly in a text editor (Emacs) and compiled it in the shell on a BSD Unix box.

This would help you understand C and Obj-C code. Afterwards, I had no problem reading Apple's document on Object Oriented Programming and Objective C.

[ 02-28-2002: Message edited by: alien ]</STRONG>
Practical C Programming. A very good book. C is necessary to learn Objective C; C++ is unnecessary and generally useless when you would be writing Cocoa apps &mdash; it is difficult in Cocoa to use C++ and C++ is full of junk anyways (though C++ programmers would tell you otherwise) unless you want to write a game or do other majorly graphical app writing.

Oh, by the way, if you intend to learn C, I can think of no better book than Practical C Programming for learning it. Especially if you don't know of any other programming languages, though it is still a good book if you know other programming languages.

[ 02-28-2002: Message edited by: Riastradh ]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:10 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2