Solved

Game programming for C++?

Posted on 2001-09-18
20
473 Views
Last Modified: 2008-02-01
Is C++ the best programming language for game programming?
0
Comment
Question by:johntrelvey
  • 5
  • 4
  • 3
  • +5
20 Comments
 
LVL 3

Expert Comment

by:cwrea
Comment Utility
PC video games?  I'd say yes.  Of course, that's just my educated guess, since I'm not a games programmer.  But I'd bet it is so.

0
 
LVL 10

Expert Comment

by:makerp
Comment Utility
depend if you can program using it, if you can not then its the worst for you.

the answer to this is probably YES, soem experts may now come along and say that it all depends etc, but they probably know that C++ is the best etc cos of the control you get
0
 
LVL 4

Expert Comment

by:IainHere
Comment Utility
>>soem experts may now come along and say that it all depends

It all depends :-)  Some people still swear by C.  Certain routines will probably be written in assembly.  VB would be fine for minesweeper.  I agree with makerp though, that C++ is a fine choice if you know it.
0
 
LVL 10

Expert Comment

by:makerp
Comment Utility
okay, C or C++, for all intents and purposes with the Q.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
No, I don't think you can say that C++ (or any other language for that matter) is the BEST for game programming.

There are many factors, some having to do with the problem to be solved, others having to do with your background.  There are certainly many good games on the market today that were developed using languages OTHER THAN C++.
0
 
LVL 10

Expert Comment

by:makerp
Comment Utility
what langauges? jhance
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
I've sen many games done in VB and Delphi.  There is nothing specific to VC++ or C++ that makes it more applicable to games than any other language.

Certainly Java has been used in games and I have personally done a "missile command" game in FORTRAN for a DEC VAXStation II.
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
Oh, and let's not forget ASM.  
0
 
LVL 4

Expert Comment

by:IainHere
Comment Utility
I didn't think we had :-)
0
 
LVL 2

Expert Comment

by:zechis
Comment Utility
99% of the retail games coming out are written in C/C++/asm.  This includes playstation, dreamcast, playstation 2, PC, and will include Xbox.

Originally, games were written in C and assembler, but as compilers get better and programmers get to focus less on hardware interaction due to good HAL libraries and get to focus more on gameplay, they are moving to C++ because of its ability to model complex entites with a minimal performance hit.

You just aren't going to get the same performance out of other high level languages (Pascal,VB) than you can out of C.  C++ is a close second (in terms of performance) but even it can be misused (MFC anyone?).



0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:griessh
Comment Utility
>> You just aren't going to get the same performance out of other high level languages (Pascal,VB) than
you can out of C.  C++ is a close second

That's an implementation issue! When I started programming (about 2000 years ago), my C binaries could never beat my Turbo Pascal. Implemenation, programming style, optimization and all these things are very important for the speed of a program. I'd be curious how you want to prove your C/C++ statement ...

======
Werner

0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
>>You just aren't going to get the same performance out of other high level languages (Pascal,VB)

That is a GENERALIZED ASSERTION and is EASILY proven false.  All I need to do is come up with one example that show a better performance in VB or whatever vs. C or C++.

Want to make a friendly bet?

There is NOTHING inherent in C or C++ that makes it faster.
0
 
LVL 2

Expert Comment

by:zechis
Comment Utility
That would simply imply you couldn't code in C as well as you could in Pascal :)

While it is true that implementation matters, my statement assumes that the same algorithm in either language will result in C being faster.  This is based on the fact that a single C statement compiles to fewer assembler instructions (on average, there are always exceptions) than other languages.  Fewer instructions (again, generally) means faster execution.  Again, all these statements are based on all other things being equal.

I would have to say that regardless of 'proof', why would 99% of the (retail) games out there use C if it was so slow?  The proof is in the pudding I would say!
0
 
LVL 2

Expert Comment

by:zechis
Comment Utility
I BET that you could come up with ONE example where VB is faster than C, but GENERALLY C is faster for the reason slated above: closer relationship to underlying assembler.  This closer relationship is what makes C inherently faster.

I stress: ALL OTHER THINGS BEING EQUAL.

BTW, VB is probably the WORST comparison because most VB code requires making API calls to DLLs which are written in _C_ !! :)
0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
>>ALL OTHER THINGS BEING EQUAL

The problem is that they NEVER are equal and so the general assertion is wrong.

VB, in it's compiled form, is quite a good performer and while I do prefer VC++, I'll just again state the fact that there is NOTHING inherent in C++ or C that necessarily makes it faster.
0
 
LVL 2

Expert Comment

by:smitty1276
Comment Utility
The answer is unarguably, YES.  I don't think that there is any question.  You absolutely will NOT get a job in the game development industry if you do not program in C/C++.  A lot of developers actually use scripting languages for their particular game engines, but the engine is written in C/C++.  

If there were a better language, the industry would be using it.  Like some people mentioned, though, there is often a little assembly thrown in to optimize things... but nowadays hardware extensions will do it better anyway.
0
 
LVL 10

Accepted Solution

by:
makerp earned 50 total points
Comment Utility
despite all this controversy C++/C is still proabaly the best for games, as has been said 99% of retail games are coded in it, why? maybe because it has provded to be the best for the job,

i just think that programmers feel obligated to aruge that C/C++ are not the only good lanaguages to show that they are good open minded coders. i bet really that they know C/C++ are at the end of the day the most flexible, fastest (on average) etc

Paul
0
 

Author Comment

by:johntrelvey
Comment Utility
Besides C++, shall I need to learn other language(Graphics API ...) to create a professional game like Red Alert, StarCraft etc.?
0
 
LVL 2

Expert Comment

by:smitty1276
Comment Utility
You will need to learn DirectX or OpenGL.  If you want your game to run only in Windows, you can use DirectX.  If you want your game to be more portable (between OS's) you will need to use OpenGL.  OpenGL can do anything DirectX can do, plus you can use hardware extensions as soon as the new hardware is released... whereas with DirectX you have to wait for Microsoft to release a new version containing any features that they deem appropriate.  I know I'm a little partial, but I suggest learning OpenGL.  It's easier anyway.  A good book... "OpenGL SuperBible 2nd Edition"

0
 

Author Comment

by:johntrelvey
Comment Utility
Shall I need to learn C++ before I learn OpenGL?
Which book is the best book for learning C++ ?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now