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 > Getting started in Cocoa

Getting started in Cocoa
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2002
Location: Los Angeles, CA
Status: Offline
Reply With Quote
Apr 17, 2002, 02:15 PM
 
Hello all. I'm a newbie to the programming scene, and I'm really interested in programming Cocoa apps. I was wondering if anyone had any recommendations in regards to reference materials, programming tools, etc. I already have the Dec. 2001 Developer Tools for OS X on my machine, as well as a copy of BBEdit.

Thanks so much!
     
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 17, 2002, 03:15 PM
 
i'm a programmer, but have not programmed in cocoa yet. you should start by learning a programming language. since you want to do cocoa i would recomend c++ (as opposed to java or realbasic). i know cocoa is programmed in objective C, but learing C++ will be good for now.

The bible of c++ is this book by the creator of C++. I would use this book as a reference, not as a tutorial.

As for learning C++, C++ in 21 Days is pretty good. I like it because it teaches you the basics and the tutorials are simple enough that you won't get frustrated.

now, you can use project builder to write terminal apps till you are blue in the face.

On to Cocoa:
From what I've looked at, cocoa apps write all of the gui code fore you, but you have to do the rest yourself (but now that you know c++ you shouldn't have a problem. Do the "currency converter" tutorial. this will teach you how to make the widgets.

A word about RealBasic:
I know a lot of people will cry foul that I'm putting this in here, I think it is worth it.

If you want to make programs quickly and easily, realbasic is great. the "language" is similar to C,objC, C++ and I think you can build programs faster. However if you want a future in programming then you chould go with C++ as not many developers in "the real world" program in realbasic.

good luck and don't try to write a major program in your first week. i have been doing this for four years now and even the simplest of programs take for ever.
12" Aluminum Powerbook
1.5Ghz G4 | 512Mb Ram | GeForce FX Go5200
     
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 17, 2002, 03:16 PM
 
if you use project builder you will not need bbedit since there is a built in text editor, although bbedit is great!
12" Aluminum Powerbook
1.5Ghz G4 | 512Mb Ram | GeForce FX Go5200
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Apr 17, 2002, 04:18 PM
 
Eek! If all you want to do is program Cocoa, don't start by learning C++. I don't know how many developers I've watched get themselves totally confused and frustrated by trying to apply C++-style thinking to Objective-C programming. The two languages and their class libraries apply object-oriented design concepts in very different ways.

I recommend spending a short period of time learning the basics of plain ANSI C if you're unfamiliar with the syntax of C-like languages, then read either Apple's Object-Oriented Programming and the Objective-C Language or Aaron Hillegass' Cocoa Programming for Mac OS X. (Or both!) If you'd like to spend some time first getting to know object-oriented programming in a more generic sense, research SmallTalk. Or, if you want to learn a language that's useful both within and outside the Cocoa world, learn Java.

Not that there's anything wrong with learning C++ for its own sake -- there are plenty of well-paying jobs for C++ programmers out there -- but it'll hinder more than help your progress towards mastering Cocoa.
Rick Roe
icons.cx | weblog
     
Forum Regular
Join Date: May 2001
Status: Offline
Reply With Quote
Apr 17, 2002, 04:21 PM
 
Poulh, I hate to dampen your enthusiasm in answering, but I have to vehemently disagree with your advice, on several grounds.

1) C++ isn't the language of Cocoa. Objective-C is.

2) C++ and Objective-C are *very* different beasts. C++ is a statically bound class based language. Obj-C is a dynamically bound class based language with object based traits, much more akin to Smalltalk than C++.

3) As a first language (particularly an object oriented one), C++ is a poor choice, teaching the programmer all sorts of artificial limitations of OO programming while pounding bad habits into their heads because of the various bizarrities of C++ that need to be worked around.

I'd recommend learning C, if you haven't already, then Obj-C directly. Skip C++, you'll have much less to unlearn later. (Learning C++ after Obj-C should be, in my opinion, much easier. You can always dumb down your OO thinking to C++'s level, then concentrate on the obtuse syntax.)

If you've installed the Developer Tools, then the file file:///Developer/Documentation/Cocoa/ObjectiveC/ObjC.pdf is an excellent start to learning OO concepts and the Obj-C language. (It's not perfect, by any means, but it's a start.)

I'd also recommend Aaron Hillegass' _Cocoa Programming for Mac OS X_ once you feel comfortable with the ideas behind Obj-C. It's a bit steep for the novice, but I've found it to be a good ramp up to building a complex app in a short amount of time. (A new book from Scott Anguish (of www.stepwise.com fame, another excellent Obj-C/Cocoa resource), Don Yacktman and Erik Buck is available now, but I haven't seen a copy of it. Given the quality of these gentlemen's contributions to the NeXT/Cocoa community though, I expect excellence. <http://www.amazon.com/exec/obidos/ASIN/0672322307/stepwisecom-20> )

You don't need all of C++ to do Cocoa - in fact, it's likely a waste of time... it certainly isn't the easiest way to learn OO programming philosophies. (And a quick way to learn poor approaches in general...)

And, just so the usual "Who do you think you are?" comment can be answered ahead of time: PhD student in software engineering and OO languages at Univ of North Carolina at Chapel Hill, where I've taught the undergrad programming language theory course.
     
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 17, 2002, 04:35 PM
 
I was assumed that along with learning cocoa he wanted to become a programmer. C++ is the big daddy on the street and there are 1000's (there are also 1000's of java apps, both are very popular) of programs out there written in c++. Java is great and it is what i learned gui-style programming in while in college, but java hides a lot of stuff from the programmer that can be a bad thing and can lead to poor programming tequniques down the road (this happened to me after getting out of college where i had been programming in java and had to start my job where i programmed in c++). things like memory management and passing variables around. java does the work for you, but with c++ you know what you are doing.

also, c and c++ are what most programs that you use today are written in, there aren't that many apps out there that consumers would see (java is very big on the server side, but you don't sound like you want to write server apps). while smalltalk is easy, you can write simple c and c++ apps as well and you wont have to relearn syntax when you switch out of small talk.

if you only want to learn cocoa... get this book . some friends at work say its better than orielly's. or go get the currency converter tutorial off of apple's developer web site.

if you are thinking about a carreer in programming, go with c++ and once you are up to speed you can jump to java really easily.
12" Aluminum Powerbook
1.5Ghz G4 | 512Mb Ram | GeForce FX Go5200
     
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 17, 2002, 04:40 PM
 
yes yes yes, i know objC and C++ are different beasts, but you can't write a huge event driven app for your very first program. you have to start small and terminal apps are a good way to learn the basics. then you can sink your teeth into bigger programs. if you are worried that Mike will get confused with the object side of c++ then he can write a few terminal apps in C until he has the syntax down.
12" Aluminum Powerbook
1.5Ghz G4 | 512Mb Ram | GeForce FX Go5200
     
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 17, 2002, 04:50 PM
 
Kickaha, I'm curious how the first few courses at UNC are taught there. I went to The University of Michigan and all engineers took C, the computer engineeers took C++ then data structures and algorithms, also in c++.

A lot of our new recruits from UofM and other schools (Cornell, RPI, CMU)this year are coming to us only knowing java. Is UNC also doing this (switching to java from c++)? I don't think its the best idea because of the memory issues that i discussed above (java is great for quick development, but not for learning what is going on under the hood in my opinion).
12" Aluminum Powerbook
1.5Ghz G4 | 512Mb Ram | GeForce FX Go5200
     
Forum Regular
Join Date: May 2001
Status: Offline
Reply With Quote
Apr 17, 2002, 05:10 PM
 
Originally posted by poulh:
<STRONG>I was assumed that along with learning cocoa he wanted to become a programmer.
</STRONG>
Oooooooh, are you implying that Obj-C developers *aren't* programmers?

<STRONG> C++ is the big daddy on the street and there are 1000's (there are also 1000's of java apps, both are very popular) of programs out there written in c++. </STRONG>
Absolutely... and Windows is the big daddy of the OS world, so what are you doing on a Mac?

Mike asked about learning Cocoa... C++ isn't needed or even necessarily wanted for Cocoa, and IMHO leads to bad OO design practices in general, which will only hurt him down the road for learning other systems, including C++.

<STRONG> Java is great and it is what i learned gui-style programming in while in college, but java hides a lot of stuff from the programmer that can be a bad thing and can lead to poor programming tequniques down the road (this happened to me after getting out of college where i had been programming in java and had to start my job where i programmed in c++). things like memory management and passing variables around. java does the work for you, but with c++ you know what you are doing.</STRONG>
Alternate interpretation: with C++ you *HAVE* to know what you're doing, instead of letting the language and development environment handle it for you. Heck, take that to its logical conclusion and we should all be writing directly to silicon in assembler punched in on a hexadecimal keypad. (Don't laugh, I've done it. Bleah.)

C is the language for doing such work, in my opinion, and it's excellent for it - it lets (forces) you to work at the near-silicon level, while Obj-C lets you work at a much higher level, while dipping down into pure C when necessary. Best of both worlds. C++, unfortunately, has a fairly mediocre object conceptualization, which doesn't let you move into the more abstract realms that Obj-C does. (Which is where the interesting OO concepts lie.)

<STRONG>also, c and c++ are what most programs that you use today are written in, there aren't that many apps out there that consumers would see (java is very big on the server side, but you don't sound like you want to write server apps). while smalltalk is easy, you can write simple c and c++ apps as well and you wont have to relearn syntax when you switch out of small talk.</STRONG>
Learning syntax is trivial in most languages (C++ being a nasty exception), and should be something a good programmer can pick up in an afternoon or so. The *CONCEPTS* behind the languages are what are critical, and will carry over from system to system.

<STRONG>

if you only want to learn cocoa... get this book . some friends at work say its better than orielly's. or go get the currency converter tutorial off of apple's developer web site.

</STRONG>
I think the general consensus is that O'Reilly's offering isn't that hot, surprisingly.

<STRONG> if you are thinking about a carreer in programming, go with c++ and once you are up to speed you can jump to java really easily. </STRONG>
Better route that will serve you better in the long run:

C -&gt; Obj-C/Java/Smalltalk -&gt; C++

<STRONG> yes yes yes, i know objC and C++ are different beasts, but you can't write a huge event driven app for your very first program. </STRONG>
No, but you can write a non-trivial event driven app for your very first program. Cocoa handles all the cruft for you.

<STRONG> you have to start small and terminal apps are a good way to learn the basics. then you can sink your teeth into bigger programs. if you are worried that Mike will get confused with the object side of c++ then he can write a few terminal apps in C until he has the syntax down. </STRONG>
That was pretty much my exact advice, actually.

I have to agree with you that there's a sad move away from programmer knowing what's going on under the hood. We have *graduate students* coming in who don't know the basics of how a compiler works. How they got undergrad degrees I'll never know. Nor do they have any real feel for memory management.

However, while I *do* know that level of detail, it doesn't mean I want to have to deal with it on a regular basis. I'd much rather be working on creating useful tools than wrestling with low level implementation details.

Right now at UNC there's a mix of languages being used in undergrad classes: C, Java, C++, *Haskell* for ghod's sake... whatever makes sense for the task at hand (which is how it should be.) The move towards Java has slowed, but unfortunately that leaves C++, which ain't great for teaching (or learning) programming.

Learn the *concepts* behind the languages, and you can use whatever language is best for the task.

Learn the *language*, and you're stuck with one tool in your toolkit.

Obj-C is much better than C++ for learning *OO* techniques.

C is much better than C++ for learning low level details.

Java is an odd duck, having most of the benefits of Obj-C for OO concepts, but hobbled by mediocre libraries (IMHO), the inability to drop into a C-level language for detail work, and that &*(%@# JVM bytecode system. (Whoever designed that should be drawn and quartered.)

[ 04-17-2002: Message edited by: Kickaha ]
     
Forum Regular
Join Date: Jan 2002
Location: Hungary
Status: Offline
Reply With Quote
Apr 18, 2002, 12:56 AM
 
Obj.C + Cocoa = The way to Go!

C++ just too confusing...

Really

nothing is when everything is alright
stupidfish23@mac.com ICQ: 153647416
     
Fresh-Faced Recruit
Join Date: Feb 2002
Location: Los Angeles, CA
Status: Offline
Reply With Quote
Apr 18, 2002, 01:45 AM
 
You can do one of two things.

Learn Java, and then learn Cocoa for Java. Java although having some drawbacks (slow VM on some systems, slow start up of pure java binaries, the first time around.) Is actually quite good.

Apache's Xerces is written in both Java and C/C++, Xerces is an XML parser and validator. So there you have a real world example that Java can do real world applications. It is also intended to make it easy to write once and run almost anywhere. Of course the run everywhere is still a myth, partially thanks to Microsoft, some would argue otherwise.

With java you can write web applications, or system dependent applications, you can write plain terminal applications or gui applications. So it really is promising, and if you're a serious programmer you want to learn as many languages as possible, that way you can choose which language is best for which task.

There are however limitations you have to overcome when writing Cocoa Java applications, mostly due to the fact that Cocoa is based on OpenStep which was designed to work very well with Objective C. But I don't think its a big issue anyways.

You can see results faster in Java. Say you want to write an event driven application with a GUI. Java will get you there faster.

The other route is learning Objective C. However, you dont need to know C++ to learn Objective C. Objective C is an extension of C, and considered to be a much better Object Oriented Programming language than C++

So you can learn C which is pretty easy, and then once you get through there you can learn Objective C. The Objective C manual Apple has on its site will tell you everything you need to know about Object Oriented Programming (OOP).

C and C++ are also very useful for accessing system dependant stuff. I dont know if Java can do much of that. I dont think you can find many or any printer drivers written in java. But look around and you'll find plenty written in C/C++.

However if you find the time also learn C++.

Either way you choose, there is a lot of code written for C, C++, and Java, and learning C or Java or both will get you really far into learning cocoa programming.

The standard disclaimer is that I do know Java but have not dealt with the language as much as C/C++/Objective C. So my comments are biased.

My suggestion is learn what makes sense for you to learn and expand your horizons into other languages. For example, I think Objective C is fine for developing with Cocoa, but if I'm serious about targetting multiple platforms i'll stick with Java, if i need a GUI, if not i'll stick with POSIX compliant C/C++ code running in terminal.

Oh and I'd use PHP for some web stuff, Perl for parsing some files

As far as realbasic goes, it can be very handy to use it as a stepping stone into the world of VisualBasic programming if you like that...

Hope that helps
     
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 18, 2002, 08:46 AM
 
Hey Mike, tell us what you've decided after all of this.
12" Aluminum Powerbook
1.5Ghz G4 | 512Mb Ram | GeForce FX Go5200
     
Fresh-Faced Recruit
Join Date: Mar 2002
Location: Los Angeles, CA
Status: Offline
Reply With Quote
Apr 18, 2002, 03:56 PM
 
Thank you all for all the help - it's more than I could have ever asked for! I thought I should clarify some things, since I was between things and in a rush when I first posted this thread. First, I have *some* programming experience. I'm a Webmaster, so I've done more HTML, CSS and JavaScript than I'd like to talk about. (This would explain why I have BBEdit lying around.) I've also dabbled in - but not mastered - some server-side stuff like PHP and ASP (no Perl, haven't been brave enough). Given all that I'm familiar with some C syntax - enough to work with the aforementioned languages except ASP - but probably not enough to write a full-blown application.

The general concensus seems to be that I should learn C first, and that's probably what I'm going to do. I picked up a book on a clearance rack once (forgot which one) and tried learning from that, gave up after a week or so because I was tired of getting syntax errors all the time. Granted, this was about five years ago and I'm a little older and wiser now. That, and I've had experience with C-derived languages since then, so it probably won't be as daunting the second time around.

From there, I'll work my way into Objective-C. Funny, I was thinking about picking up the O'Reilly book, glad I didn't.

My mother once tried C++. (My mom and dad met at the equivalent of a start-up back in the 70's. Both were trained in COBOL, but only my dad continued with it. It's apparently a good line of work considering the number of legacy systems still in use at major corporations. And my younger brother is a Photoshop master, majoring in Studio Art with a Digital Art minor or concentration, I forget which. Family full of tech geeks, mine is. But I digress.) It didn't catch on with her; I guess it was a bit too much for her to handle. I might try my hand at it some time in the future, in the event that I ever want to write Windows applications. *shudder*

I want to program in Cocoa for two major reasons: 1) The tools are cheap, usually free (thank you, Apple!) and 2) I love Macs and want to give back to the Mac community in some way. I have lots of great ideas for programs, but I don't know how to write them myself. That, and I'd love to be able to help out with other people's Open Source projects.

By the way, Rick: been a big fan of icons.cx for a long time, keep up the good work! My desktop has literally been covered by your icons, and they never cease to amaze my friends (especially my PC-using ones!). :-)

Again, thanks everyone!
     
Dedicated MacNNer
Join Date: Oct 1999
Location: Seattle, WA, USA
Status: Offline
Reply With Quote
Sep 2, 2002, 02:22 PM
 
I was lurking in here because I'm trying to throw together some data analysis apps quickly. I'll probably use Realbasic because of it's integration with Excel (all my data is in Excel).

Thanks to all of you thoughtful posters. The future of the Mac is in good hands...
Don
     
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status: Offline
Reply With Quote
Sep 3, 2002, 04:03 AM
 
Originally posted by dbergstrom:
I was lurking in here because I'm trying to throw together some data analysis apps quickly. I'll probably use Realbasic because of it's integration with Excel (all my data is in Excel).
You might consider using VBA or AppleScript (dunno if Excel has an AS dictionary).
     
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Sep 5, 2002, 10:55 PM
 
Just my 2 cents worth...

I'd highly recommend starting with just C. Objective C is a simple super-set of C so it makes a good foundation. I agree that C++ would be confusing to someone switching to Objective C.

After learning C, I'd highly recommend the book "Learning Cocoa" (O'Reilly). This will teach you all you need to know about Objective C and about using the Mac OS Cocoa development tools.
     
   
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 09:48 AM.
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