Game Development Community

C vs C++

by Rodrick Brown · in Technical Issues · 03/30/2001 (11:26 am) · 5 replies

I will admit im a rookie programmer, how important is it to learn C++ and OOP in this day and age, I dont plan on "making end's meat" by programming games, Im 22 and I think I got into the programming scene a little two late, but I do love games and love to mod games. I have a decent programming backgroup Perl/PHP & C, im not familiar with alot of concepts with C++ has or the advantages it has to offer, I just want to know if its really important to learn to program games in C++ vs C I started out getting big on Unix so I never was really interested in learn C++. But all my friends went to college did the CS thing and are really big in C++ is it worth the hassel to learn ? I notice Most IDsoftware titles are mostly C with some minor asm low level optomizations.

Over the last 2 1/2 years I though my self C and im still lacking alot of Advanced concepts out there I didnt want to move to C++ without fully getting a strong understanding of the C language but with more and more game developers writing there games/applications in C++, it makes me wonder if I should be learning C++.

One last note god this post is long :)
How does gaming compaines look at people who come to them saying that there skills were self taught ?? Can this be a good or bad issue.

Any input will be appreciated.

About the author

Recent Threads


#1
03/30/2001 (2:01 pm)
C++ is regarded as one of the most powerful, versatile programming languages available today. OOP is on eof the reasons why guys like Tim Gift, can create these awesome engines that are at the core of these great games. Comparing C to C++ is really like comparing a Pinto to a Mustang. They are both cars but one is a better performer and better looking. Hence the name C++, ++ being the incremental operator or C plus one. Get it? If you pick up almost any C++ book they often compare the differences between C vs. C++. Many books I have read on the subject have even said that it might be a good idea to not learn C before C++ because you might have to unlearn some things to program efficiently in C++! I don't know why that is I never learned C I just jumped straight to C++.

Being self taught is ok too. Doesn't mean you'll be a great programmer but its ok. If you are self taught and got the skills to show it more power to ya. I work for a company (e-learning) that fortunately promotes self learning. I don't think that is how it is everywhere though. Some places aren't as fortunate.
#2
03/30/2001 (6:27 pm)
I think that view of C and C++ is a little bit skewed. I think a better description would be like comparing a Viper to a Mercedes. One is faster, but the other has a lot more features to offer. And really, if you know how to use either language well, you can get the job done.

My opinion is that your choice of C or C++ is irrelevant. The real challenge to to learn how to architect your software. That is where OOP comes in. A well architected piece of software is much easier to maintain, modify, and even create. Using function pointers, you could program C in a very "C++" fashion.

I would suggest learning an OOP language to help teach yourself these concepts. It is very easy for someone to write a program in C that gets out of control very quickly, especially someone who has not worked on a large project before. Actually, it is also very easy to write C++ in a very "C" fashion as well and not really take advantage of the language. Frankly, I would suggest Java. That language really shows how easy programming can become with a good set of well designed objects. It is also similar enough to C++ that if you decided to move in that direction it would not be a huge leap. Note I am not saying to program a game in Java since it is still way to slow for that (at least a serious game). But my C++ code improved a lot after I spent some time doing Java code.

Anyway, that is my humble opinion.
#3
03/30/2001 (10:34 pm)
I agree with the "Viper vs Mercedes (SL500 though)" analogy. C can be very fast. It's pretty much the closest you can get to coding the assembly yourself. Some people believe that C++ cannot come close to C in terms of speed, but that's just not true. Once you get a good handle of C++, I suggest getting a copy of "Efficient C++" to see how best to optimize your code. Unfortunately there are a lot of people out there that have no intention to learn new languages or new methods of doing things (even if they're better). One of the oddest practices I've seen is trying to code C in an OO fashion. Such as making functions like this:

myobjectstruct *MyObject_New();
void MyObject_DoSomething(myobjectstruct *pMyObject);

It's like trying to recreate C++. What's the point??? Put that's just my opinion... One of the biggest things that gets me is when people say they program in C++, but when you look at their code it's C with a 'new' or 'delete' sprinkled here and there. When you talk to them about interfaces, templates, etc. they draw a complete blank.
#4
03/31/2001 (10:22 am)
C++ is as fast as C, except maybe at compile time. I blend the two together, for example I like streams a lot more than printf, because you can overload some class functions to be able to cout << Classname; etc. But not all my programs have classes and not all my programs are OO, so I just use a mix. I don't think it has ever been proven that one is faster than the other, it is all personally preference. But to be a true C++ god, you really need to understand C very well. The two build on one another, and go hand in hand, I don't think you should make a distinction between the two.
#5
04/02/2001 (12:17 am)
In general C++ is as fast as C. However, it's quite possible to use some language features that would cause (often insignificant) slowdowns.

In any event, both are perfectly valid languages. Q3A was written in C, and it's quite spiffy. UT was written in C++, and is spiffy as well. Just remember that a good C programmer does not necessarily make a good C++ programmer, and vice-versa - it takes time, but a similar syntax helps trim it down.

OOP isn't a language construct, it's a paradigm. Certainly, C++ has "enablers" like explicit support of classes, but obviously you can code OOP in C - Genesis3D is OOP in many respects. It's not the end-all-be-all either, even Bjarne himself said it's often a better solution to mix OOP and structured programming.

The moral of the story: If the tool you know gets the job done, use it.