views:

909

answers:

15

In which languages are high-profile games like Half-Life 2, Crysis, Quake 4 and Red Alert 3 and so on written in?

This includes game design tools, scripting tools, and so on.

+3  A: 

C and C++. LUA is a common script language used in games as well (check here for a list of games using it).

Will
Lua, not LUA: http://www.lua.org/about.html
titaniumdecoy
+1  A: 

I would guess C/C++ and assembly language for the main game engine and some kind of scripting language for customization, testing and modding like lua, javascript or some custom scripting language.

SDX2000
+5  A: 

Pretty much exclusively C++ with a smattering of assembly.

Some will include a 'hand-rolled' scripting engine to make life simpler. This is usually interpreted (or byte-code interpreted).

LUA (www.lua.org) is a commonly used scipting engine.

Andrew Rollings
A: 

C++ primarily though with heavy use of various APIs and libraries.

One of the (unfortunate) reasons is that most games are developed for multiple platforms including game consoles, and these game consoles do not support any runtime environments (JVMs, .NET, etc.). So one is left programming "on the metal". This is the case for Sony consoles, and I think that also for XBOXs and Nintendo's.

Uri
So it is possible to develop high-profile games using high-level languages such as C#? I thought high level was a no-go for high performance games?
IceHeat
I don't see why runtime environments would be a problem. The game engine is often native-written and encapsulated behind an API. Much of the game logic (especially in strategy games/RPG) can easily be written in runtime environments.
Uri
You would only be able to use C# with XNA as far as I'm aware. Calling unmanaged code (platform APIs) from managed code tends to end very, very badly.
invenetix
@IceHeat: most performance problems these days are pushing triangles to the GPU and shader performance. Both are independent of the language used to develop the system. The sole CPU bottleneck these days is in physics.
Jasper Bekkers
There are relative few things these days that require actual down to the metal access as the largest part of the code is in game play and is most of the time written in a scripting language such as Lua or python.
Jasper Bekkers
+10  A: 

I work for a major game publisher and all of the answers given of C/C++ and LUA are in fact what are used for a majority of games (not just ours). I have yet to see any assembly used for any of the games I've been involved with.

The container for the game to interact with the various underlying platforms (PC, Wii, XBOX, PS2/3) are all based in C/C++ as well.

invenetix
No assembly? How do you guys use SSE then?
Nils Pipenbrinck
Or how do you guys programmed the vector-units of the PS2?
Nils Pipenbrinck
Most systems have APIs that are implemented in Assembly but have C++ interfaces... Game developers outside the engine group rarely have to crank up assembly.
Uri
It's possible we still do use Assembly in some form. Like I said though, I just have yet to see any use of it. From my understanding of the underlying engine, we just plug into the APIs that are exposed by the platform being used. I work with upper levels of the game in the user interface/usability.
invenetix
@Nils: SSE can be used with C++ intrinsics that look something like _mm_set_ps(0, 1, 2, 3) to load data into SSE registers. Advantage is that the optimizing compiler still gets to manage the SIMD registers and that it can reorder instructions as needed. No inline assembly needed.
Jasper Bekkers
if assembly is necessary it would be abstracted away in libraries, not even the engine developers would use it often.
Dustin Getz
Jasper, I know you can use the intrinsic, but the generated code is so bad that it's almost not worth the efford.
Nils Pipenbrinck
Nils, what compiler are (were) you using? I've never had problems with the generated output nor did any of the projects I've seen 'm used in. I'm still not confident enough to actually do the assembly myself because it can't be abstracted like the way OS X does that for AltiVec / SSE.
Jasper Bekkers
jasper, I've tried VS2008 and various GNU toolchains. Even the latest GCC does funny things using the intrinsics (like storing vectors on the stack and reloding them for no aparent reason)
Nils Pipenbrinck
BTW, Lua is not an acronym. It means moon in Portuguese. To write it as LUA is wrong. See lua.org. :)
Nick
Assembly is still used in games, but will mostly be hidden away. 20 years ago most games were 100% assembly, now they are 99.9% C/C++ with some assembly to optimise very specific parts. Intrinsics are better than assembly as they tell the compiler more about what you are trying to do.
Nick
+1  A: 

Half-Life2 is entirely in C++, in fact they release an SDK for mod development which I think includes about half the game's source code. They even develop their own chain of tools (at least for mapping).

Although I haven't been following the HL2 Mod scene for over a year so I can't say anymore.

hasen j
+2  A: 

I know for a fact that the Football Manager series is written exclusively in C++, with Java being the choice for the installer. I'd assume that, as everyone else has mentioned, all other games are written in C/C++ with a touch of Assembly Language.

Note: I've heard rumours that Rollercoaster Tycoon was written entirely in Assembly Language. Anyone want to weigh in on this?

EnderMB
You heard correct, http://www.chrissawyer.com/faq3.htm
Jasper Bekkers
As everyone else has mentioned - modern games rely heavily on scripting languages. It's about modularising the application as a whole, and writing each module in the language that makes most sense.
slim
A: 

C/C++ has 95% of the PC market, on mobile devices J2ME is pretty strong. For games scripting LUA and Python are pretty popular.

Disney is doing some games with their free engine Panda3D, it's Python or C++. Perhaps worth a try if you don't know C++. Panda3D

If you would like to start working on games then I would recommend [Game Institute][2]. These are in depth courses "from zero to hero". You can start with entry level C++ and then progress with DirectX, Physics, AI etc. I'm doing DirectX there, it's really good.

[2]: http://www.gameinstitute.com/"Game Institute"

Nazgob
+9  A: 

Generally C++ is used for the core of the gaming engine, that is, the graphics, physics and audio pipeline. Assembly is hardly ever used because most modern compiler support the x86 SSE intrinsics (or equivalent for the chosen platform) to access the vector pipeline of the CPU. These intrinsics look like generic function calls but translate nearly 1:1 to the actual SIMD instructions. (This isn't specific to SSE btw, AltiVec's system is rougly identical). Most of the game-play coding happens in scripting languages such as Lua or python because these generally aren't the performance bottlenecks and thus have different requirements (ease of use primarily) the use of scripting languages also removes an entire class of issues: memory allocation bugs.

However, there is another class of programs in a game. The shader programs. These do a couple of different things; they are (most of the time) responsible for the skinning / bones animations, lighting, texturing and other materials. Writing shader programs is generally the same as SSE programming as you are working on a vector processing unit (that means it supports instruction level parallelism). Generally these are written in Cg (Cross platform), HLSL (DirectX) or GLSL (OpenGL). However, due to GPU limitations (instruction limitations, limiting the number of texture fetches or registers et cetera) these are often rewritten in assembly for performance reasons.

Jasper Bekkers
A: 

C++ is where it's at now, but there is a gradual trend towards high level languages for game logic and dropping into native code only for computationally intensive functionality like graphics, networking, physics.

Dustin Getz
A: 

Regarding assembly in game programming - the big studios generally license an engine from someone else, which encapsulates away all the low level stuff like graphics. Engine writers undoubtedly do use languages lower level than C++ - graphics shaders and console platforms with unique hardware come to mind. Often this stuff is done in a C-like language.

Dustin Getz
Some of the engines don't to a 'good' job of abstracting the low-level stuff. * cough* Havok *cough* for example comes with a huge list of "don't do this because we're doing SSE optimizations here"-things which albeit understandable is quite annoying.
Jasper Bekkers
+1  A: 

If you look in the ads section of an games 'industry' magazine such as Edge, you'll see lots of ads for engines and middleware. Games developers either use these layers, or they roll their own - an example might be Valve's 'Source' engine.

These layers are typically written in C or Assembler. They provide a compatibility layer to reduce development time for cross-platform games. Just like GTK lets you forget whether you're coding for Windows or Linux, these libraries let you forget whether you're coding for Xbox, PC or PS3. Having said that, there's lots you can't take for granted (differing memory constraints, controller maps, corporate standards...)

They also provide lots of the performance critical stuff that modern games rely on - physics simulation, fast and realistic rendering, all that jazz.

Once you've got that stuff down, you want to tell the engine what to do. Approaches to doing this vary. I know Jeff Minter's 'Space Giraffe' reads level definition files in a 'language' that looks like line noise to anyone but the developers.

But many, many, modern games adopt the approach of building a script interpreter into the engine. This is because people are productive in scripting languages, and publishers like productivity! Python is a fairly common choice because it has always been embeddable in applications (Civilization 4 uses Python). LUA is popular for similar reasons - lightweight and embeddable.

So the approach is, in your C/C++ code, you create a bunch of functions/classes that can be called to set up and run a game. Then you use the scripting language's embedding tools to bind theses functions/classes into entities that can be invoked from scripts.

slim
More on the use of Python in Civ: http://en.wikipedia.org/wiki/Civilization_IV#Python
Jon Hadley
A: 

I guess I should mention this because it surprised me when I first heard it, but the PS2 games in the Jak & Daxter series were coded in Common Lisp.

Yanik Magnan
Not Common LISP but a custom lisp-like language called GOAL.
Crashworks
+1  A: 

C/C++ for high profile games most certainly.

However I'm guessing the subtext of this is 'what language should I learn to code to get into the games industry', which is a subtly different question.

If you're really interested in getting the 'high-profile' games development (and I'd caution against it as received wisdom is that this is a very high turnover, burnout liable, relatively low paid field prone to recurrent death marches) then you've got to be a C/C++ wizard with a high level of mathematical skill. However if you're willing to settle for something a little less glamorous then consider development for mobile phones, handhelds and the like. Although the competition is still fierce the teams are smaller and it's still feasible to develop something profitable with just one or two people (realistically a coder and a graphics designer). Your choice of language is also much wider - Java on many mobile platforms, Objective C on the iphone, and even any of the .net languages if you're going for windows mobile.

Cruachan
A: 

Roller Coaster Tycoon was programmed mainly in assembly. A bit of C was also used to interface with Windows and Direct X. Source

DeadHead