what language is games written in?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Addis

Junior Member
Dec 29, 2004
15
0
0
i've not had any previous experience with C and C++ seems pretty easy for me. If you get a good book then its ok. C# is the web language for the programmer who's used to C and its part of MS .net.
 
Jun 18, 2004
105
0
0
Originally posted by: siyan
Originally posted by: Dopefiend
Originally posted by: mitch2891
C for example would be useless for net based stuff for that you would want java or something similar

Um...
C works fine for "net based stuff".

Yeah...just look at what GTK+ can do...


Maybe it has it's uses I meant more like if he want to program stuff like java applet, then I don't think you can do anything similar with C never really looked into it though to be honest my work does not call for it and I have no personal interest in net based anything except browsing around.
 

stickybytes

Golden Member
Sep 3, 2003
1,043
0
0
right now im learning c++ in school. real simple stuff like loops, if statements and iostream components. some commands that i already know hot use well are do while, for, do until loops, if and else if statements. does game programming require any knowlege in the things i listed above?
 

SJP0tato

Senior member
Aug 19, 2004
267
0
76
Originally posted by: stickybytes
right now im learning c++ in school. real simple stuff like loops, if statements and iostream components. some commands that i already know hot use well are do while, for, do until loops, if and else if statements. does game programming require any knowlege in the things i listed above?

They do use these things as means of logic control, but they act as a small part of a larger system.

The best analogy I can think of is addition, subtraction, basic algebra and how they are used in a physics equation to describe the rotation of the planets in their orbits using advanced calculus. They would be a fundamental portion of the calculations required, but still only a small part.

Hehe, just wanted to give a little insight. ;-)
 

Jassi

Diamond Member
Sep 8, 2004
3,296
0
0
Originally posted by: jzietman
what's the difference between c and c++? whatever happened to c+?



I don't know if anyone posted this yet, too lazy to check. The reason it is called c++ is because in c, when you increment you can type variablename++; (ex. c++ is the same as c = c + 1), so as an inside joke, the creater of c++ used this to name the new language and thats why there is no c+ :)
 

Todorov

Member
Dec 17, 2004
76
0
0
Originally posted by: Jassi
Originally posted by: jzietman
what's the difference between c and c++? whatever happened to c+?



I don't know if anyone posted this yet, too lazy to check. The reason it is called c++ is because in c, when you increment you can type variablename++; (ex. c++ is the same as c = c + 1), so as an inside joke, the creater of c++ used this to name the new language and thats why there is no c+ :)


Yep Correct
 

complacent

Banned
Dec 22, 2004
191
0
0
Originally posted by: Jassi
Originally posted by: jzietman
what's the difference between c and c++? whatever happened to c+?



I don't know if anyone posted this yet, too lazy to check. The reason it is called c++ is because in c, when you increment you can type variablename++; (ex. c++ is the same as c = c + 1), so as an inside joke, the creater of c++ used this to name the new language and thats why there is no c+ :)

The funnier part about this is that C++ is post-increment. Why would you want to use C before it is upgraded/incremented? To be truly correct with C++ syntax, the language should have been ++C. People that do not care much for the language because of it's somewhat unwieldy syntax always give us a hard time about the syntactical error in the name of the language itself.

I am a little shocked that no one has mentioned OpenGL or DirectX. Most games today use an engine written in either of these two API's. A game company comes out with an engine, and then they usually lease the engine to other companies. For example, many of the FPS war games on the market use the Quake 3 engine developed by id. Pretty soon, you will see other games made with the Doom 3 engine and the Source engine (Half-Life 2.) Actually, Vampire: Bloodlines leased the Source engine from Valve for their game to the tune of $1 million.

You want to write a game? Learn C/C++ like the back of your hand, take some advanced linear algebra, and then learn OpenGL.

 

futuristicmonkey

Golden Member
Feb 29, 2004
1,031
0
76
I've only begun to learn programming (I've been a hardware guy for so long, and I want to learn how to get more out of it :)). I've chosen to learn C++ first, as I found an excellent ebook to teach it: Teach Yourself C++ in 21 Days.

This is awesome. I'm only on like day 5 (I only stated about a week ago, but want to let the stuff I'm learning sink in) and I've learned a lot of cool things. I've already started to make small, cheap (but effective) programs to help me with my math and science homework :).

And as for whether to learn C or C++ first, they suggest in the book, that it "would be advantageous not to".

Oh, and for a small Visual Basic tutorial, check out this: Maximum PC: How to learn Visual Basic Programming. It's a small lesson, I haven't been able to try it yet (been a little busy) but it looks cool. :)

Hope this is useful. :)

Edit: It would seem that most games are written in C/C++ :p
 

SelArom

Senior member
Sep 28, 2004
872
0
0
www.djselarom.com
how powerful is C# compared to C++? could the games mentioned above be programmed in c#? I know C# is really good for web stuff (like asp.net) but how is it for windows programming (vs vb.net) and console programming (vs c++)? thanks!
 

Extrarius

Senior member
Jul 8, 2001
259
0
0
Just for those that mentioned it: The only thing assembly is used for these days is MMX/SSE/etc, because processors these days are REALLY complex and you'd have to study a long, long, LONG time to be able to write better 'normal' assembly than a modern compiler.

In the old days(everything before pentium iirc), instructions took a certain number of clock cycles and that was that - you just strung them together however you wanted picking the fastest ones (possibly trying to line up memory access so it used the cache a lot but not much else) and that was that.
These days, multiple instructions can be executed at the same time, and new instructions can start executing before old ones really finish, and there are 100s of conditions that can add a few cycles where the processor has to sit and wait on one thing or another, or take an extra cycle to calculate something, and they can even change the order of your instructions so they run faster. Such things make the old 'cycle counting' game insanely difficult. In fact, in some ways it is impossible because things like the OS running in the background could totally destroy all your usage of the cache and cause other problems.

Most optimizations these days involve settling for approximations (such as calculating square root to say 4 places instead of the ~7 the FPU will calculate for a 32-bit floating point number), using better algorithms (such as using a radix sort instead of a bogo sort), and using metadata about the task being done by the program to take shortcuts(for ex, if your program is going to read in 1K each time and process each byte seperately, it woudl be better to read in 1K and loop though it after loading than to have a loop that loads a single character and then processes it and then reads another one at a time).


In reguards to the OP: Games are mainly programmed in C and C++ these days. For a beginner, I'd suggest learning C++ first because IME that is the most common language in use in general programming today.
Another language I would suggest you learn (solely to increase your programming ability) is Common Lisp. The book ANSI Common Lisp (ISBN: 0-13-370875-6) is a good introduction to the language IMO, but it will not introduce you to programming itself (so you need to learn another language or find a Lisp book that intros programming as well before reading that book).
 

Addis

Junior Member
Dec 29, 2004
15
0
0
I'm reading c++ Demystified right now. It doesn't go into huge detail but by the end of it you should be able to write your own simple programs. Once thats done I'll move to a more advanced book.
 

complacent

Banned
Dec 22, 2004
191
0
0
Originally posted by: Extrarius
Just for those that mentioned it: The only thing assembly is used for these days is MMX/SSE/etc, because processors these days are REALLY complex and you'd have to study a long, long, LONG time to be able to write better 'normal' assembly than a modern compiler.

I wholly disagree. Standard x86 processors are not as complex as one would like to think. Now, the new EPIC (Explicitly Parallel Instruction Computing) processors are that complex, and it would be near impossible to program in assembly because of the way packets of instructions are formed...

With an x86 processor, it has nothing to do with the processor being very complex; it has everything to do with the optimization of your compiler, and I can guarantee that, given a piece of code, I will be able to find at least one optimization for it. I haven't studied assembly for a "long, long, LONG time" and have been able to beat the optimizing compilers by hand writing assembly to unroll loops, do a bubble sort, and other tasks. Lets not forget John Carmack, and the fact that Doom was written mostly in assembly. I'm willing to bet that some of the new Doom 3 engine has some hand-written assembly. Go here http://games.slashdot.org/arti...amp;tid=112&tid=10 to see a thread about Doom 3. There is discussion that all of the shaders used in Doom 3 (and in fact most games) were hand-written in assembly.

Gaming aside, assembly is used all of the time.
Especially if you want to spawn a new root shell :)


 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
Writing things entirely in assembler is combating the compiler too much.

However, on P4s I can sometimes make a function run faster by taking the assembly and reordering a few instructions already there from the compiler. Not that it's worth keeping it around.

It is very useful to know enough assembler to read the disassembly of a function and see whether you got what you wanted, e.g. no unwatned constructor invocations, no functions calls where you wanted inline, how big exactly a loop is, where is the data you have alined and is it in the same cache line as the mutex locking it (it shouldn't)?

The thought that C# is competition for C++, performance-wise, is entertaining, but C# clearly plays in the Java class.
 

Jeffyboy

Senior member
Dec 17, 2004
276
0
0
Which language to use to use is the least of your worries. The mathemetics involved or opengl/directx knowledge and game theory is more difficult. You may want to start simple with what language you know well first of all... doesn't matter what the language is.. delphi, C++Builder, MSC++ or whatever... and start from there. Once you get a grasp of how to do directx or opengl programming.. then decide if you want to code it in another language.

Asm may be used to optimize code if it's sluggish... depends on your game.... unlikely you'll compete with Doom3 or somethin gbut...ya' never know ;-)

Jeff
 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
Originally posted by: Jeffyboy
Which language to use to use is the least of your worries. The mathemetics involved or opengl/directx knowledge and game theory is more difficult. You may want to start simple with what language you know well first of all... doesn't matter what the language is.. delphi, C++Builder, MSC++ or whatever... and start from there.

I agree with the first sentense, in the end you only program well if you think about the problem domain and forget about the language you use.

But regarding the second sentense, anybody who starts programming should use a language that is implemented by more than one vendor and has a real standard somewhere.

There is nothing worse than being locked into one vendor's will and if they decide to wreck the language or turn it into something different then they drag you down along them. Look at Turbo Pascal and all the Smalltalk implementations. Their programmers had a rocky ride, they have never been cut off but the languages turned into something else and are not universally useful.

While it is true that you will forget about the language when you enter "real" problem-oriented programming you still keep a ton of libraries around, even from your early days. If you can. A one-vendor language will effectively either prevent you from keeping your libraries or it will force you into a niche.
 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
Originally posted by: hoppa
Originally posted by: MartinCracauer

The thought that C# is competition for C++, performance-wise, is entertaining, but C# clearly plays in the Java class.

score:
java: 28.40
c++: 27.63 (vc++)
c#: 27.33

http://dada.perl.it/shootout/craps.html

That's a nonsense artificial benchmark. Not to mention that all the links to concrete info what t is doing are broken. But I remember this language benchmark from the time it started.

the problem here is that Java and C# do fine as long as you compare programs that are written with low-level data types and only using plain arrays.

The moment your program gets complex and you have to use your self-defined structures/classes in collections, and those collections are sequential but simple arrays won't do, the performance of Java and C# goes to hell.

There is no way to do
Code:
struct foo {
  int a;
  char b[12];
  double c;
}

void bar(void)
{
  struct foo myfoos[20];
  // code
}

In any efficient manner in Java or C#. In these languages you will always get points to your objects, not the object laying linear in memory. Not to mention I use a simple array here, if you use something that is almost an array but support richer intacerfaces you lose double in Java/C#.

That is a killer, and it becomes more of a killer and CPUs get more and more sensitive to memory indirections and benefit more from compact data.

Languages like C, C++ and Common Lisp which can arrange your own data structures in memory exactly the way you like will get a huge performance gain when your program becomes complicated enough that you cannot live with collections of atomic data types anymore and begin shuffling your own structures/classes around.
 

iotone

Senior member
Dec 1, 2000
946
0
0
Originally posted by: complacent
Originally posted by: Jassi
Originally posted by: jzietman
what's the difference between c and c++? whatever happened to c+?



I don't know if anyone posted this yet, too lazy to check. The reason it is called c++ is because in c, when you increment you can type variablename++; (ex. c++ is the same as c = c + 1), so as an inside joke, the creater of c++ used this to name the new language and thats why there is no c+ :)

The funnier part about this is that C++ is post-increment. Why would you want to use C before it is upgraded/incremented? To be truly correct with C++ syntax, the language should have been ++C. People that do not care much for the language because of it's somewhat unwieldy syntax always give us a hard time about the syntactical error in the name of the language itself.

I am a little shocked that no one has mentioned OpenGL or DirectX. Most games today use an engine written in either of these two API's. A game company comes out with an engine, and then they usually lease the engine to other companies. For example, many of the FPS war games on the market use the Quake 3 engine developed by id. Pretty soon, you will see other games made with the Doom 3 engine and the Source engine (Half-Life 2.) Actually, Vampire: Bloodlines leased the Source engine from Valve for their game to the tune of $1 million.

You want to write a game? Learn C/C++ like the back of your hand, take some advanced linear algebra, and then learn OpenGL.

i completely forgot about OpenGL and DirectX... yes, those are two APIs that are worth learning when trying to program games... additionally, someone mentioned Linear Algebra?? yeah, you gotta know that too if you really want to get down and dirty with your graphics...

i had taken a graphics course and programmed a few things in C/OpenGL, and the Linear Algebra stuff was the most difficult for me... you have to know it in order to describe your camera, where you're looking, where your objects are in space, how to do transforms, skews, etc...

as far as the assembly thing is concerned, does anyone have any benchmarks on mixed assembly/C(++) vs strictly compiled C(++)??