Page 1 of 2

What makes C++ such a good programming lang for games?

Posted: Mon Mar 03, 2008 10:36 pm
by MasterGod
I've been wondering in the last few weeks, o.k I get it that C++ is used widely, especially in games (though not only I know) but what exactly so good in it that most popular games use it?

I'm in love with C++ so blindly that I can't answer that myself :P

What's your opinion in this matter?

Posted: Mon Mar 03, 2008 11:13 pm
by Vsk
C++ is flexible and have good performance (if you use it corrctly).

But at this time ad especialy for games c++ should not be used anymore in my opinion.

I had read some articles (I don't if here or gamedev) tha c# games are performing the same velocity and even with particles.

C++ has some old habits that made process slow, you always must define at least the standard of implementation if you work in group or even alone. Else you will have some 300 way of implementation (that c++ allows (flexible)).

But again I think that we must give the next step and let die to c++ :P

Posted: Tue Mar 04, 2008 1:23 am
by TheBeef
C/C++ isn't just used for games, it's the strongest and one of the oldest languages around. It's used to develop almost everything, from OS's (Windows) to most games and applications.

Basically, it's really badass, so that's why most people use it.

(All the cool kids use C# though 8))

Posted: Tue Mar 04, 2008 1:39 am
by Halifax
Well it has already been spoken about all over the internet. C++ is more suited for C though due to the object-oriented design, instead of procedure-oriented.

Although you can fall into procedure-oriented programming with C++, and you can use object-oriented programming ways with C.

I have to say C++ was the best choice for Irrlicht, simply because Irrlicht is basically built around objects. I would hate to see how Irrlicht would look if it was developed with C.

I rather opt for C when I feel like getting stuff done fast, and having some easy to manage code. I use C++ for bigger applications because C becomes unwieldly at a certain point with one person, although it can be done. That's just my opinion.

Posted: Tue Mar 04, 2008 5:51 am
by CuteAlien
One of the main advantages to me is that c and c++ do not restrict your control over the computer in any way. With every other language you will sooner or later reach some border at which you have to include some c modules.

C++ also made it easier to structure my data than c, though I must admit that this might be mostly because I'm more used to c++. I long though that it's obviously better than c because it can do all the c stuff and some more, but by now I've seen some c code which was written so extremely well and so short that I'm actually no longer really sure. Checkout the quake sources for an example of very nice c code.

Also it has a lot of advantages if a language has been around for a while. Tools are stable, there are *lots* of tools and it runs on every platform for which I ever have developed (and I had to work for a few more than just linux/windows). If you compare that for example with c# you will see that support for that outside the windows world is rather poor. For most game consoles it's not even available so far.

Similar to tools is the library situation. I guess about 90% of all game libraries are written in in c or c++. So as soon as you leave c++ you have more work ahead for all large projects (and most games get large after a while).

C++ is also not proprietary. I just like that. Java got also opened up recently, but I'm not sure if it's already as open as C++. And Sun never *got* games anyway which shows all the time in everything they develop. And c# ... uhm, yeah.

There might be other languages catching up sooner or later. But I suppose that must come from bottom-up. A few small projects which are suddenly all finished faster than their c++ counterparts and the language used there will be tried in bigger projects. Maybe that's c#, but I rather doubt it. I don't think that the development time is different enough to justify the switch. I would rather bet on languages which do abstract on an even higher level like Python.

Maybe another language will also get a chance when multithreading becomes more common, as this will change the way applications have to be written more than probably everything else happening within the next years. So a language with real strong support for parallelization might get a chance.

By the way .. there are also certainly a lot of reasons for me to hate c++ beside the fact that I'm using it. But most of it has it's reasons in the c++ syntax. C++ is very hard to parse and that slows down the development of good tools for it. Also it's compile times are just horrible compared to seemingly every other language out there (and once your compile times get above 10 minutes for a rebuild that starts to hurt!). And while it offers no borders when it comes to controlling the computer, it restricts control of the language itself. So metaprogramming in c++ is hard and often things are nearly impossible to do. Another problem is that you have to write a lot of cruft. C++ sources always get large - and that's hard to avoid in this language. Coding just for fun is nearly impossible...

So c++ is far from perfect, just still more usable than all the other languages for this job. For other jobs (like tool programming) I usually prefer script languages. I still hope someone will develop a language one day which can work with c++ libs, offers *the exact same functionality* (and I'm not talking about a turing complete language but about inline assembly, manual memory management and pointers) but has a better syntax and better meta-programming facilities :-)

Posted: Tue Mar 04, 2008 10:35 am
by rogerborg
C++? Y'all from the future? Find me an extant operating system (other than Symbian) that's written in C++, let alone C#, and we can talk. :P

Posted: Tue Mar 04, 2008 11:20 am
by CuteAlien
rogerborg wrote:Find me an extant operating system (other than Symbian) that's written in C++, let alone C#, and we can talk. :P
VoilĂ : http://choices.cs.uiuc.edu/

;-)

Posted: Tue Mar 04, 2008 3:01 pm
by rogerborg
CuteAlien wrote:
rogerborg wrote:Find me an extant operating system (other than Symbian) that's written in C++, let alone C#, and we can talk. :P
VoilĂ : http://choices.cs.uiuc.edu/

;-)
Post from an extant operating system written in C++, and we can talk. :P

Posted: Wed Mar 05, 2008 2:04 am
by Halifax
Well iirc, this topic is about why C++ is good for games. I would also like to note the C++ isn't exactly the standard for games these days either, as people would like to think. Most big companies do use C++, but smaller companies use C.

And as CuteAlien pointed out, C can be organized in a object-oriented style, like Quake 3, but allows for manipulation of that data in a procedure-oriented way. Modifying data in a procedure-oriented fashion is the downfall of most beginners, and why they think that C isn't as powerful as C++.

Posted: Wed Mar 05, 2008 3:42 am
by BlindSide
Halifax wrote:but smaller companies use C.
Lol, and what makes you say that? Alot of big games were written in C, including Quake 3.

Posted: Wed Mar 05, 2008 12:24 pm
by FlyingIsFun1217
CuteAlien wrote:With every other language you will sooner or later reach some border at which you have to include some c modules.
Somebody is forgetting their assembly roots.

FlyingIsFun1217

Posted: Wed Mar 05, 2008 1:05 pm
by Halifax
BlindSide wrote:
Halifax wrote:but smaller companies use C.
Lol, and what makes you say that? Alot of big games were written in C, including Quake 3.
I'm talking about currently. After quake 3, id software switched to C++. There are a select few companies out there now that are using C. Especially since the release of UE3.

Posted: Wed Mar 05, 2008 8:02 pm
by dlangdev
050 REM: What makes C++ good for games:

100 Print "C++ is C with classes. Much easier to implement ADTs."

101 Print "STL"

102 Goto 100

103 End Run

Posted: Wed Mar 05, 2008 8:07 pm
by Halifax
dlangdev wrote:050 REM: What makes C++ good for games:

100 Print "C++ is C with classes. Much easier to implement ADTs."

101 Print "STL"

102 Goto 100

103 End Run
Wow congratulations, you forgot to read the forum rules where it says you should speak in english. Great job!

Posted: Wed Mar 05, 2008 9:23 pm
by night_hawk
I'm not realy in to all this, but I have seen several performance tests between Pascal, C++ and C# and have taken part in several debates regarding C++ vs C#, and C++ beats C# when it comes to overall performance and control. There were even several programmers considered "Gurus" that were against C# big time. Why? They had their technical reasons.

Personaly, C# is scary and I don't like it. C++ (and Pascal. Good ol' Pascal) all the way.