Solved

Game programming for C++?

Posted on 2001-09-18
20
480 Views
Last Modified: 2008-02-01
Is C++ the best programming language for game programming?
0
Comment
Question by:johntrelvey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +5
20 Comments
 
LVL 3

Expert Comment

by:cwrea
ID: 6490700
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
ID: 6490766
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
ID: 6490779
>>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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

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

Expert Comment

by:jhance
ID: 6490815
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
ID: 6490859
what langauges? jhance
0
 
LVL 32

Expert Comment

by:jhance
ID: 6490973
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
ID: 6490976
Oh, and let's not forget ASM.  
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6491029
I didn't think we had :-)
0
 
LVL 2

Expert Comment

by:zechis
ID: 6491047
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
 
LVL 11

Expert Comment

by:griessh
ID: 6491329
>> 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
ID: 6491350
>>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
ID: 6491366
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
ID: 6491382
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
ID: 6491444
>>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
ID: 6491603
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
ID: 6492701
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
ID: 6493516
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
ID: 6495706
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
ID: 6496165
Shall I need to learn C++ before I learn OpenGL?
Which book is the best book for learning C++ ?
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

696 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