Page 1 of 2

C or C++?

Posted: Sun Nov 02, 2008 8:46 am
by XianForce
Well I'm going to buy either Sams teach yourself C/C++ in 21 days book soon, so any suggestions on which? I've been hearing C++ from everyone, but I started with C, so I don't really care, I could go either way. I wanted to learn C++ when I started but, since I was a noob with no directional influence, I thought C++ was advanced C and not two seperate items. Anyways, what do you guys suggest? I don't want, "It's completely based on your opinion" or something like that. Give your preferences please, and reasons for your preference.

Re: C or C++?

Posted: Sun Nov 02, 2008 9:16 am
by Trask
I really like C and for some console development, it may be unavoidable but as an industry whole, I think it would benefit you to learn C++. I've heard that, if you know C well enough that C++ isn't that hard to pick up and that may be true syntax-wise, but you need to learn OO theory as well as the syntax. My teachings took me from BASIC to C++ in high school, then when I went to college they took me back to BASIC, then went C, then C++... I didn't have a hard time working with C nor getting use to procedural programming as that's what BASIC uses, but that's just me.

If you want to work low level, learning C in and out is probably your best bet. If you're not sure what you want to do or if you want to jump into game development with no specific plan, then I'd go with C++.

Re: C or C++?

Posted: Sun Nov 02, 2008 9:24 am
by Falco Girgis
Yeah, I agree with Trask. I started with C, because I was doing lower level things on Dreamcast when I first got into game development. I was pretty good at C, so the hardest part about C++ was learning the theory behind it.

if you aren't doing something like console development, and you're just looking to get into general PC game development, you really can't go wrong with C++. You can't go wrong with C either, but I would still recommend C++, as it is growing increasingly popular over C in recent years, even in the console development world.

Re: C or C++?

Posted: Sun Nov 02, 2008 10:18 am
by XianForce
GyroVorbis wrote:Yeah, I agree with Trask. I started with C, because I was doing lower level things on Dreamcast when I first got into game development. I was pretty good at C, so the hardest part about C++ was learning the theory behind it.

if you aren't doing something like console development, and you're just looking to get into general PC game development, you really can't go wrong with C++. You can't go wrong with C either, but I would still recommend C++, as it is growing increasingly popular over C in recent years, even in the console development world.
alrighty, C++ it is then xD

Re: C or C++?

Posted: Sun Nov 02, 2008 11:37 am
by Arce
I agree with Trask and Gyro.

I personally jumped from BASIC to C++ (procedural to OO), but have since revisited C in school (until I was kicked out of the class. xD). This weird order of learning things has pretty much left me as the odd-man-out, as I am fully capable of writing things structured or OO, and I often find my style neglecting "good OO design" in favor of speed at runtime or coding time.

There are certain aspects of C++ that I high disagree with using and deem quite nearly useless for the average programmer. They exist only for good OO design and highly encapsulated structuring--which I am more than capable of, but I deem more of a burden to a developer than useful. Perhaps if I were working for a company with 30+ developers such measures might begin to become necessary, but I'm not about to sacrifice performance and speed as well as precious time to make my code for an application where I know all developers personally and am responsible for the main design.

In short, C++ has many new highly OO features, and though I'd recommend beginning with C++, I would also suggest visiting C in the future to help you gain an understanding as to why a highly object oriented design is sometimes needed and practical as well as when it can become counterproductive. Too many times I see inexperienced programmers wasting all their time adding unneeded accessors methods, overriding functions and operators that will never be used, creating abstract datatypes and templates that will only be used once or twice, having to declare functions mutable just to work around their own limitations they've placed by using const, going overboard with inheritance and virtual functions, and many other things with serious overhead as the result that would only be necessary if you were producing your own library to be used by a very bast audience.

Hopefully this post didn't scare you. ;P

Re: C or C++?

Posted: Sun Nov 02, 2008 1:16 pm
by sparda
Well, to tell you the truth I think you should learn C in concurrence with a much easier language, as that what worked best for me. I remember trying to learn C, then getting stuck at some confounding concept, and then going to Python, getting stuck there, and then going back to C; it was an awesome cycle :mrgreen:

I love C++, but C to me was much more educational. Not to mention it is a tiny language with a small set of built in operators, so in my opinion its easier to learn than the gargantuan C++. Once thats done, then hit C++.

In addition, I suggest you do some low level programming together with your C studies, as there are things you will only see in other peoples low-level code, and not in a standard C book. For instance, a book may cover type-casting and pointer arithmetic, but some concepts are compounded and look weird. I remember in my GBA coding days, when I had to write to Object Attribute Memory (OAM), I saw some weird fucking code. In my C learning days, I would see something like:

Code: Select all

#define OAM ((u16 *) 0x07000000) 
And think to my self: "What the fuck is going on here!?" It was really confusing, and I had to go into forums and ask. Its really helpful to pic a console and do some low level coding in it. You can try these consoles as they all have nice toolchains: PS1, PS2, GBA, PSP, DS, GB. If you're like me and like to do stuff on your own, then try SNES, NES, or some other archaic console. Keep in mind you will most likely not deal with C, which kind of beats the purpose of this thread 8-)

Re: C or C++?

Posted: Sun Nov 02, 2008 2:56 pm
by M_D_K
I learned them both at the same time(wierd isn't it). And like what other people have said C is great for console dev(or any embedded system).

If its just PC dev here is a good rule when mixing C and C++ in a project:

If you can do it in 10 lines in C, why do in 50 lines in C++?

Re: C or C++?

Posted: Sun Nov 02, 2008 6:22 pm
by XianForce
sparda wrote:Well, to tell you the truth I think you should learn C in concurrence with a much easier language, as that what worked best for me. I remember trying to learn C, then getting stuck at some confounding concept, and then going to Python, getting stuck there, and then going back to C; it was an awesome cycle :mrgreen:

I love C++, but C to me was much more educational. Not to mention it is a tiny language with a small set of built in operators, so in my opinion its easier to learn than the gargantuan C++. Once thats done, then hit C++.

In addition, I suggest you do some low level programming together with your C studies, as there are things you will only see in other peoples low-level code, and not in a standard C book. For instance, a book may cover type-casting and pointer arithmetic, but some concepts are compounded and look weird. I remember in my GBA coding days, when I had to write to Object Attribute Memory (OAM), I saw some weird fucking code. In my C learning days, I would see something like:

Code: Select all

#define OAM ((u16 *) 0x07000000) 
And think to my self: "What the fuck is going on here!?" It was really confusing, and I had to go into forums and ask. Its really helpful to pic a console and do some low level coding in it. You can try these consoles as they all have nice toolchains: PS1, PS2, GBA, PSP, DS, GB. If you're like me and like to do stuff on your own, then try SNES, NES, or some other archaic console. Keep in mind you will most likely not deal with C, which kind of beats the purpose of this thread 8-)

Erm...too late for that, I saw the first 3 posts all said C++....so I went out and bought the book! It took me a while, I thought Sams teach yourself C++ in 21 days and SAms teach yourself C++ in an hour a day were two different books...that was until I ready on the cover "The sixth edition of Sams teach yourself C++ in 21 days"

Anyways thanks for the tips guys, I'm just beginning to read my book right now.


I must admit I was tempted to get the C instead of C++ just because it was longer lol.

Re: C or C++?

Posted: Sun Nov 02, 2008 6:45 pm
by avansc
depends what your end goal is.
i would suggest getting both books. but like for example, i did some stuff for redhat on the file system, and all we used is straight C.

Re: C or C++?

Posted: Sun Nov 02, 2008 6:48 pm
by MarauderIIC
Since you've already made your decision, for future readers: Learn both, maybe even at once. If you have to pick one to start with, though, I'd recommend C++ because it's easier to go procedural knowing OO than OO knowing procedural, in my opinion.

Re: C or C++?

Posted: Sun Nov 02, 2008 6:51 pm
by avansc
MarauderIIC wrote:Since you've already made your decision, for future readers: Learn both, maybe even at once. If you have to pick one to start with, though, I'd recommend C++ because it's easier to go procedural knowing OO than OO knowing procedural, in my opinion.
thats is a good point, however, any OO program can (mathmatically) be coded as a procedural program. and i think that people these day dont learn enough about performance and Big O and concepts like that. and i believe that it stems from just using OO when and learning the smart ways of getting procedural to do the nifty things for you. if you have ever taken a course in ASM, you would know exactly what i mean.(i just added that in there because i dont think i convayed my point across properly)

Re: C or C++?

Posted: Sun Nov 02, 2008 6:59 pm
by sparda
Oh god, did you just buy one of those "teach yourself in 21 days" books!? Damn, I must have overlooked it because I would have advised against that. I've read one of those "teach yourselves" and I must say, in relative to other C++ books, they suck big fat ballz.

This proves my point: http://norvig.com/21-days.html

The article has one of the most realistic points of view I've seen in a while. You should check it out.

Re: C or C++?

Posted: Sun Nov 02, 2008 7:04 pm
by XianForce
sparda wrote:Oh god, did you just buy one of those "teach yourself in 21 days" books!? Damn, I must have overlooked it because I would have advised against that. I've read one of those "teach yourselves" and I must say, in relative to other C++ books, they suck big fat ballz.

This proves my point: http://norvig.com/21-days.html

The article has one of the most realistic points of view I've seen in a while. You should check it out.
lol, well I took reccomendations from a lot of people, and this book was the most reccommended.

Re: C or C++?

Posted: Sun Nov 02, 2008 7:07 pm
by avansc
i actually own that book. and its not as bad as some might pretend. i think the title is misleading. i dont think they were being serious about 21 days. its just catchy and i guess sells. PS: if anyone wants it and will pay postage you can have it.

the book covers basically everything but skimps on the most important aspect of C in my opinion. POINTERS!
if you really wanna get the best foundation on pointers i would actually advise a book thats not even directly aimed at C.

"Assembly language for intel-base computers" by Kip R. Irvine.

its an absolute beauty and after going thought it you will be the keeper of memory, the god of efficiency and the lord of awesomeness.

Re: C or C++?

Posted: Sun Nov 02, 2008 7:19 pm
by XianForce
avansc wrote:i actually own that book. and its not as bad as some might pretend. i think the title is misleading. i dont think they were being serious about 21 days. its just catchy and i guess sells. PS: if anyone wants it and will pay postage you can have it.

the book covers basically everything but skimps on the most important aspect of C in my opinion. POINTERS!
if you really wanna get the best foundation on pointers i would actually advise a book thats not even directly aimed at C.

"Assembly language for intel-base computers" by Kip R. Irvine.

its an absolute beauty and after going thought it you will be the keeper of memory, the god of efficiency and the lord of awesomeness.
lol, well I wasn't expecting to actually learn it in 21 days. I can be a quick learner, but when I learn quick, I tend to miss bits here and there. So when I'm learning stuff like this, I'll go through it several times.