# C or C++



## Zimbop (Nov 25, 2002)

I've been working in PHP for a couple of years now, but would like to take a step into programming Mac (OSX) applications. 

I don't know any C or C++ whatsoever, and presume that this should be my first step, but which should I study, C or C++ ?

I'd also be grateful of any recommendations of books on C or C++ for complete novices.

Thanks

Zim


----------



## anarchie (Nov 26, 2002)

> _Originally posted by Zimbop _
> *
> I don't know any C or C++ whatsoever, and presume that this should be my first step, but which should I study, C or C++ ?
> *



Just....don't ask that.  You'll start a religious war.  Flip a coin or something.  Or just learn C++, if you don't plan to use plain C, ever.


----------



## r4bid (Nov 26, 2002)

learn c++ in the process you will earn about classes and oop, very important stuff nowadays.


----------



## tosk (Nov 29, 2002)

C++ seems to be the "standard" nowadays. Almost everything I've seen has been in C++.


----------



## slur (Dec 16, 2002)

Not to beat this topic to death, but if you want to learn C++ you'll certainly need to understand C first, and there are many instances where you'll use vanilla C functions in conjunction with C++, so again, it's a must to know.

Since you already know PHP you're halfway there. The most striking thing about C in contrast to PHP is the way you have to deal with data types. In PHP all your variables are scalar, freely converted between strings and numbers. In C you have to be very cautious about how you deal with your variables, especially arrays and strings (arrays of characters). This is because C doesn't do anything in itself to prevent you reading or writing beyond the end of your buffers.

Get the original Kernighan & Ritchie book on C and tool around with console applications. Once you feel comfortable with the behavior of C variables then you should move on to C++ - and heck, learn Objective-C while you're at it.


----------



## mpwiedemann (Dec 16, 2002)

Right on! 

The original Kernighan & Ritchie book on C is a great tool. It can be a bit dry though. After going through "C for Dummies" volumes 1 & 2, it all made much more sense. My background is in PHP as well and making the jump to C (pointers, yuk!) would have been impossible using only the K&R. The dummies book tied it all together for me.

Good luck!

Martin


----------



## cbaron (Dec 17, 2002)

And why should'nt you start with Objective-C and Cocoa ? O'Reilly's "Learn Cocoa" has a whole chapter about Objective-C before starting with Cocoa classes, and this would allow you to start directly with GUI apps development (isn't it nice ?  ).


----------



## 96.9 (Dec 21, 2002)

If you want to learn how to build back end moduels for darwin or any brand of unix type OS study C .

If you want to work on front end GUI functions like games or stuff to work in the Aqua environment study C++ .

Unix was built with C , when studying C you will recognise the standard functions common with basic unix commands .


----------



## LordOphidian (Dec 23, 2002)

Every Obj-C book I have read so far assumes a working knoledge of C, so you should probably learn C first if you want to go down that road.  C as a language is pretty easy, the ANSI C library though will take you a while to learn.


----------

