C or C++?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

C or C++?

Post 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.
User avatar
Trask
ES Beta Backer
ES Beta Backer
Posts: 738
Joined: Wed Oct 29, 2008 8:17 pm
Current Project: Building a 2D Engine
Favorite Gaming Platforms: Sega Genesis and Xbox 360
Programming Language of Choice: C/C++
Location: Pittsburgh, PA
Contact:

Re: C or C++?

Post 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++.
MarauderIIC wrote:You know those people that are like "CHECK IT OUT I just made Linux run on this piece of celery [or other random object]!!"? Yeah, that's Falco, but with ES.
Dear god, they actually ported ES to a piece of celery!
Martin Golding wrote: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: C or C++?

Post 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.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: C or C++?

Post 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
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: C or C++?

Post 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
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
sparda
Chaos Rift Junior
Chaos Rift Junior
Posts: 291
Joined: Tue Sep 23, 2008 3:54 pm

Re: C or C++?

Post 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-)
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: C or C++?

Post 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++?
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: C or C++?

Post 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.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: C or C++?

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: C or C++?

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: C or C++?

Post 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)
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
sparda
Chaos Rift Junior
Chaos Rift Junior
Posts: 291
Joined: Tue Sep 23, 2008 3:54 pm

Re: C or C++?

Post 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.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: C or C++?

Post 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.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: C or C++?

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: C or C++?

Post 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.
Post Reply