Sign in to follow this  
blowing20

c++ or c# is future trend of game programming?

Recommended Posts

Well, C# is a good language, but it requires another layer to execute the code, as it only gets compiled to MSIL, so then the virtual machine will compile that to machine code at runtime.

C++ is always compiled, and is much better for cross-platform development, because of the lack of virtual machine required to run the executable.

C# definately has the upper hand when it comes to websites however.

Share this post


Link to post
Share on other sites
Quote:

c++ or c# is future trend of game programming?

C++ will remain dominant for many years to come, if only because of the sheer amount of existing legacy code and knowledge investment coupled with the fact that the portability issues with C++ are solved for nearly all relevant platforms, which is not yet the case with other languages.

Quote:

but c++ is more efficiency

Blanket statements like these are generally wrong.

Quote:

so then the virtual machine will compile that to machine code at runtime.

Things like ngen.exe or similar tools can 'pre-JIT' assemblies. I would imagine that if anybody went to do C#/managed development on a console they would employ something like this, since the console is a fixed platform and games would likely avoid the slower aspects of the domain like reflection (at least during performance-critical code). So there is some amount of a panacea to be had there.

Quote:

C++ ... is much better for cross-platform development, because of the lack of virtual machine required to run the executable.

Your overall point is accurate but your details are fuzzy.

In fact, C++ is just as suitable for cross-platform development as C# or any other language. Taken from a certain perspective, C# and CLI languages in general are "better" in some sense, because they can be run without recompilation on another machine provided that other machine has a runtime available.

Remember, C++ doesn't magically run on other machines too: it requires both a compiler and a runtime to be implemented for the target platform.

C++ wins the cross platform bid purely by virtue of brute force and its age. It's been around long enough that people have developed platforms and runtimes for pretty much every platform that matters for game development, and its such a well-understood problem that its easy to churn out new ones. In constrast CLI languages are very new and Mono and similar projects are just getting started.

Oh, and I moved this to General Programming.

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
Quote:
Original post by blowing20
c# also can web application~
What relevance does this have to the "future trend of game programming" ?


Plus one can do web-programming in nearly all major programming languages (even Delphi (though I am unsure if it is really a major programming language/environment)).

Share this post


Link to post
Share on other sites
The current trend in game programming is moving towards multiple languages. Some languages are useful for specific platforms like Flash for web based games, Java for mobile phones, etc. Even on the desktop, multiple languages are often used to develop a single game. Ex: C++ for system interfaces, a scripting language to handle most of the game logic, assembly to take advantage of certain CPU features that the C++ compiler doesn't have good intrinsics for, and a shader language to write things for the GPU.

Share this post


Link to post
Share on other sites
I can see BOTH languages playing their roles for years to come.

I used to look down on C# a while ago, but then promptly changed my mind when I started to use it; something I'd suggest ALL people who look down on C# should do!

C# IS a nice language and has many benefits to games programming. One such being game tools development.

My personal preference will ALWAYS be C++, but I can really see a combination of MANY languages being used to create games for the foreseeable future. And using the right tools for the right job in a complex project such as game programming can't be a bad thing!

Share this post


Link to post
Share on other sites
I think that c++ will remain the main language for those games that would benefit the lower level optimizations available with c++. Other less resource intensive games might easily move to C# (or other languages) wich feature a faster development. Lately I've seen that a few games (expecially those ported from consoles) aren't all that optimized for pc, so I suppose that optimization is no longer the main concern for some software houses.
I could imagine Microsoft providing a .Net enviroment for their next console, and if the market will ask for it, perhaps someone will write a .Net runtime for other consoles (thought Mono performances are not that great, at least under windows, so I don't really belive it suits the games world.

C# is already heavily used for tools (i.e. editors).

Share this post


Link to post
Share on other sites
Quote:
Original post by blowing20
c++ or c# is future trend of game programming?
Only way you can answer that is to make your own time machine. Or invent a stasis pod so you can just be revived at the future time you are interested in. Both of those options are better than asking such a question on any web forum, least of all on one with a rating system.

Share this post


Link to post
Share on other sites
Well one of the hottest new entries to the future of gaming is the ipod phone/touch applications which don't use either so I say neither-LOL!

p.s. Actually, I thought I just read around here or someone that someone did write a C# game for the iphone so I might be premature in my prediction?

Share this post


Link to post
Share on other sites
For some reason firefox is crashing if I try to edit my post.

I should also mention that other developers where I work use Java to develop games for other mobile platforms and then run the Java code through a converter that produces Objective C that runs natively on the iPhone.

Share this post


Link to post
Share on other sites
sounds like flame hell.

I am going to take the stance that .NET (notice, I did not say C# particularly, though that is obviously the current focus of .NET, I am including variants here) will push heavily on C++ for the dominant HIGH LEVEL language in the future (C++ will still be used heavily for lower level programming, pInvoke style wrapping, embedded systems, and as the new "assembly" language for many programmers. If nothing else this will be due to Microsoft's insane marketing capacity and dedication to this dream. First off, hotspot or JIT compilers are growing extensively in popularity, and microsoft has done well to push C# on aspiring game developers (as well as other programmers) by opening up their console for its usage, and providing absolutely top-end tools at the insanely cool price of free. And with open implementations such as Mono allowing capable programmers to create cross platform applications.

I love how people continuously talk about the optimal power of low level C++. I do agree that in many scenarios a programmer can write swifter and better code in C++, pushing that last 2%-10% speed gain for a crap load of extra work. But if you look at the direction things are going, that is something that will slowly fade as the MSIL PLATFORM matures.

The truth is, optimal C++ code varies from platform to platform. the language itself has grown incredibly complex, and is difficult to grab the level of optimization that is necessary to compete with a true platform oriented JIT compiler.

My forsight tells me that eventually we are going to see a much more common cross platform usage of the .NET runtime. hardware and OS development will be producing assemblies in a similar manner to how they currently release drivers. these will be beautifully written C++/ASM libraries that adhere to a common (perhaps even standardized) spec, similar to C++'s STL implementation. Thus the code that one person writes, in the language of their choosing, will be implemented natively on various platforms. This allows levels of cross-platform optimization that are unrealistic on a low level language such as C++. It will also allow programmers to take advantage of hardware upgrades and changes in devices and consoles, which would be a prominent selling point.

This move seems eminent considering the level of piracy going on in the PC world, which would cause the push for more companies to move into device centric environments.

Anyways, hopefully that rant made some sense. Still pretty tired, been writing up UML designs all night for a client. Bleh.

-Cesar

Share this post


Link to post
Share on other sites
Quote:
Original post by PaulCesar
is difficult to grab the level of optimization that is necessary to compete with a true platform oriented JIT compiler.
Quote:
This allows levels of cross-platform optimization that are unrealistic on a low level language such as C++.
  • LLVM (especially look at the oldest, basic documents here).
  • clang.

Share this post


Link to post
Share on other sites
Well, realistically, I expect C++ to remain the dominant language for the foreseeable future, but I do think there are some shortcomings of C++, and that there must be (or at least be the possibility for) a much better language for game development. But I'm not really that sure if C# would be the answer though.

The biggest reason why I would not want to use C# for a game, or at least, not for anything lower level than scripting, is that it isn't as predictable as C++. In C++, you know that the performance cost is the cost of what you use, and if you are having a performance problem, or memory usage problem, you know that it's most of the time quite feasible to zoom in on it, and fix the problem at the place where it occurs.

In C#, you don't have this freedom as much. I really wouldn't be surprised that if you would write a game in C#, that seems to run fine at first, but once it gets bigger, your "stop the world" garbage collection cycle suddenly becomes a noticable stall. And getting that fixed may turn out next to impossible. Much harder at least than a comparable problem would be in C++.

And also, things like bounds checking are of course nice if security is a big concern, but with games, performance is generally more important, so the performance hit from this may not be worth it.

Then again, I do think C++ has its share of problems as well, especially in the age of multi threading.

For example memory allocation. Traditionally, games only allocate memory for more or less permanent data (like textures, meshes, etc.), and use the stack (local variables) for temporary data. But when you want to use multi threading well, the stack concept doesn't work that well any more for temporary data, as it'sgoing to be passed between threads all the time (think of messages and copies of data that is going to be processed in a different thread, while an other thread still needs it's own, immutable copy of that same data, which is swapped when the other thread is done). With this kind of allocation patterns, and the inherent restriction of C++ that the location of a block of memory has to be decided at the moment of allocation, and cannot be moved afterwards, can be a huge performance bottleneck, and can result in huge amounts of memory fragmentation.

If we would use a language that has the freedom of moving memory blocks around, then it would be possible to get allocations that are a lot cheaper (ie. bumping a pointer), and the runtime could defragment memory in the background, so you won't have the problem of slowing down allocations, that start creaping in as your game runs for a longer time. (Note that this doesn't even have to mean that the language has to be garbage collected. The program could still specify when it's done with a certain block of memory, but just having a runtime that has the freedom to repack it's memory in the background would be a huge benefit for programs that use multithreading a lot).

Share this post


Link to post
Share on other sites
Quote:
Original post by phresnel
Quote:
Original post by PaulCesar
is difficult to grab the level of optimization that is necessary to compete with a true platform oriented JIT compiler.
Quote:
This allows levels of cross-platform optimization that are unrealistic on a low level language such as C++.
  • LLVM (especially look at the oldest, basic documents here).
  • clang.

If you read my post in its entirety, you would notice I was refering more to the common platform then the usage of C++ over a particular virtual machine style setup (which would achieve a similar thing). I probably should have not used the term JIT aswell, as most will be converted to native code upon "installation".

Essentialy, recommending a new compiler target for C++, does indeed provide many of the same features that make .NET great. On the other hand, it provides very little OVER .NET either. A low level language will always be needed to handle native functionality (in this case from the looks of it, LVVM can handle both). But should native assemblies be created which house all functionality in a standardized nature, but at the same time be hand-optimized for the particular platform, then you have the best of both worlds anyways, and a very nice, language independent framework to build on.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this