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

Discussion about everything. New games, 3d math, development tips...
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

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

Post 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?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post 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
TheBeef
Posts: 25
Joined: Wed Feb 20, 2008 4:38 am

Post 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))
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post 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.
TheQuestion = 2B || !2B
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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 :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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/

;-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post 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++.
TheQuestion = 2B || !2B
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post 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
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post 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.
TheQuestion = 2B || !2B
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post 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
Image
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post 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!
TheQuestion = 2B || !2B
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

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