• Advertisement
Sign in to follow this  

C in game development

This topic is 1616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Programming languages are for people, not computers. Even assemblers offer us meatbags much in the way of convenience over inputting op-codes by hand (or even the hypothetical worlds simplest assembler that only lets us write those opcodes with symbolic names). So it is kind of silly to say that using one language or another makes the computer think in a certain way. Demonstrably not true. Using one language or another makes you think in a certain way, but not the computer.

 

Program in C if you want. That's fine and dandy, but the only thing that C actually offers over C++ is that its a model your own human brain is more comfortable with, and perhaps that its marginally more portable to extremely limited or esoteric platforms, related mostly to the fact that its runtime is simpler and more compact than the C++ runtime -- take note, however, that only the first of those things is any benefit to you as the programmer.

 

There's a significant amount of software out there that's written in C, its not going to disappear. A lot of that software re-invents aspects of what's already provided in C++ or in other languages. But given that C is a nearly-perfect subset of C++ (There may be differences in the standardese or other small things, but truly impactful differences are essentially non existant), Microsofts slow adoption of C99 not withstanding, there's no really reason to limit yourself to 'C'. If strict C compatibility isn't something you need, you can merrily code along in C and then pull in bits of C++ as needed, rather than reinventing them yourself. Its probably wiser to just learn and use C++ proper, but at least it saves you reinventing the wheel.

Share this post


Link to post
Share on other sites
Advertisement
This has devolved into a language flame war.

There are no solid numbers that say "x% of all games are written in language y", and even if there were the numbers would be useless. It does not matter.

Major games are written in many languages. At work I routinely have files open in anywhere from four to ten languages at a time, all used in building a single AAA game. The languages used are irrelevant, all that people care about is that the game runs and is fun to play.

You can write games in whatever language you want. Write them in C, C++, C#, Java, Python, JavaScript, ActionScript, Basic, or any other language you want.

All of those languages have been used to write commercially-successful games. If you are looking for approval or someone's blessing before starting out, you have it. Write your game in ANY language that you want.

Share this post


Link to post
Share on other sites

I worked for a big company a few years ago, with 400 staff, multiple offices, and their own engine team, who made quite a few console games per year.
Their engine code was all plain C.
The tools were C# and other languages.
The games were a "C with classes" style of C++ (no templates, constructors, destructors, etc).

 

So yeah, it is used. I'd definitely say that C++ is more popular though (although the sanctioned sub-set of C++ that's used will vary greatly from studio to studio)

Edited by Hodgman

Share this post


Link to post
Share on other sites


worse thing is that they are static sized tables and i do not know how achive flexibility in such static array approach,

 

soft code array size in data file. 

 

read in array size from data file at program start. then malloc entire array at once at program start, and free at program end. set array size big enough to get the job done.

 

the speed of static arrays, and the variable size of malloc'd arrays.

Share this post


Link to post
Share on other sites


c in game development (in relation to c++ usage) ? In big games?

 

i've been writing games in C since 1989 or so. I've done a number of large titles in C. my current project is in C (in a c++ compiler) and tips the scales at about 70,000 lines of code so far. a typical big game for me is about 100,000 lines of code.

Share this post


Link to post
Share on other sites

 


worse thing is that they are static sized tables and i do not know how achive flexibility in such static array approach,

 

soft code array size in data file. 

 

read in array size from data file at program start. then malloc entire array at once at program start, and free at program end. set array size big enough to get the job done.

 

the speed of static arrays, and the variable size of malloc'd arrays.

 

 

But what with large c projects (such like windows/linux/gcc)

Are they internally static array based, what is their main containers for data? As I said if this is static arrays it is prone to overflows (mallocked to), static arrays with realloc? If this is something like linked list of structures it would be much slower... 

Share this post


Link to post
Share on other sites

 


c in game development (in relation to c++ usage) ? In big games?

 

i've been writing games in C since 1989 or so. I've done a number of large titles in C. my current project is in C (in a c++ compiler) and tips the scales at about 70,000 lines of code so far. a typical big game for me is about 100,000 lines of code.

 

 

I would say 100k-lines are medium size not big. I belive any big title commercial game shipped to shops is much larger (how much?)

My own home framework with some unfinished prototypes

of 2d games has 100k-lines by now. Big game is probably about 1M-lines and more

Share this post


Link to post
Share on other sites

This has devolved into a language flame war.

You say that as if it were a surprise :)

Granted, this was a zeitgeist topic about, what, 15 years ago but when have these threads ever ended well? Still, if anyone needs any more gasoline to throw onto the fire I'm here all day (or at least until the inevitable lock).

Share this post


Link to post
Share on other sites


if anyone needs any more gasoline to throw onto the fire I'm here all day

 

now i got your first comment on that^^

Share this post


Link to post
Share on other sites


You are not making the CPU think in any particular way at all, to even consider that is frankly stupid.

I'm not talking about the physical CPU. I'm talking about the CPU from the vantage point of purely the language. If I could express my point more clearly in the previous post, what I was trying to say:

 

Computer instructions are roughly the same either way on the physical machine for similar C and C++ programs, but C++ offers a different way of organizing your data and methods. The computer, however, runs instructions one by one (for the most part) in programs, and does not concern itself with objects and the like. The computer just runs a sequence of instructions. C, however, is more closely based off of the linear organization and execution path that an actual computer follows. The underlying computer does handle functions and memory addresses and data types. The underlying computer does not have class/object manipulation instructions or private/public this and that.

 

I wasn't trying to make it sound like I thought the CPU architecture was dynamic based on the language used to program it, although you may find this post equally stupid.

Share this post


Link to post
Share on other sites

Computer instructions are roughly the same either way on the physical machine for similar C and C++ programs, but C++ offers a different way of organizing your data and methods. The computer, however, runs instructions one by one (for the most part) in programs, and does not concern itself with objects and the like. The computer just runs a sequence of instructions. C, however, is more closely based off of the linear organization and execution path that an actual computer follows. The underlying computer does handle functions and memory addresses and data types. The underlying computer does not have class/object manipulation instructions or private/public this and that.


And the private/public nature of fields and functions has zero impact on the instruction stream the CPU sees, they are just a human abstraction, so what is your point again?

More importantly why is that abstraction 'bad' yet structures, which a CPU has no concept of either, fine?

Also CPUs don't "handle functions"; they have jump instructions but the whole 'function call' concept is, again, a human abstraction. A CPU has no more idea about a calling convention or a flow than a hamster does.

It sees a stream of instructions; coming from C or C++ makes zero difference in the grand scheme of things. Edited by phantom

Share this post


Link to post
Share on other sites
I was hoping the gentle reminder about it becoming a language war would be enough to push it back toward a topic. As we all know, language wars are not constructive. Closing.

Share this post


Link to post
Share on other sites

This topic is 1616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement