Page 1 of 7 123 ... LastLast
Results 1 to 10 of 68
  1. #1
    Join Date
    Aug 2003
    Location
    Peabody, MA
    Posts
    919

    C++ vs C# with Game Development

    I have been reading and thinking about this. Now i am currently involved in a project building a Game Engine and we are using C++ for it and i think that is the right thing to do. C++ has been around for a lot longer than C# and with that comes more knowledge, libraries, and support for it, I also think that it is a little bit faster using C++ than C#. The big reasons i hear people who say use C# is because it is easier to use and faster to code, does this make it better for building a game engine?

    Now I am a little confused about what C# is meant for. Like Perl is meant for processing text, PHP/ASP is meant for Web Development, and so on. I have heard many people say that C# is going to replace C++ in the game development market but i have heard people say that C# is more like Microsoft's version of Java(of course there are people that tell me the Java is better for building Games than C++). Just to give you a idea of what i mean by games, i am talking about World of Warcraft, Warcraft 3, Enemy Territory: Quake Wars, those types of games. I always though of java as a great programming language when dealing with web stuff, am I wrong here.

    One thing i think C# looks good for is Game Engine tool building(like level editor and stuff) because the performance lost is not that vital to a tool like it is to the engine itself.

    What is your guys opinion.

  2. #2
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    C# can be used to create games. C++ will be used to create games for a LONG time to come because mainly because companies already have huge source code bases and knowledge investments that they aren't going to port over to ANY language unless there is a significant business advantage compelling them to do so.

    Can C# be used to write a game engine? Yes. Can it rival the speed of C++? Yes. There are a lot of myths about C# it simply isn't fast enough to be used to write games with; this is not correct. The performance difference between C# and C++ is actually quite small, and games are usually GPU bound instead of CPU bound.

    C# and the .NET Framework is meant as a general programming language for any OS that supports .NET Platform.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

  3. #3
    Join Date
    Oct 2004
    Location
    Nova Scotia, Canada
    Posts
    1,425
    C# and the .net framework isn't ment just for general programming at all, it can do just about everything C++ can do, besides of one thing.. And that's programming a complete OS just using C# code..

    There is already a BIG BIG game out there on the market right now "Never Winternights 2", which was redone using C#. Most people don't even realize it at all..

    Also another great thing about C# is that it'll give u a much small size of the program comparied to C++ ones.

    Here's another good thing about C#, it's more of a cross platform programming language then what C++ is. Hmmm, u might be thing what is he talking about. While it goes like this if u take native C++ code and put it on windows/linux/unix/MACOSX systems, you'll have to redo some of the code just so it'll compile right, unlike C#.. where you can just take that code and put it on any OS and compile it and not having to worry about changing some of the code for it work right.

    Anyways that's all i got to say

  4. #4
    Join Date
    Feb 2006
    Posts
    11
    I agree with owensd.

    C# in my opinion is a lot quicker to code with but C++ has been used for games for a long time and will continue to do so.

    C# was created by Microsoft mainly for desktop and net applications. But yes you can make a game engine with C# but the real difference is down to performance issues.
    I heard XNA/C# can get upto 95% of the performance of a c++ game which means C# games will be able to compete but the memory management, GC - Garbage Collector - is unreliable. Sure there are ways around it but in C# you don't have to take care of memory management which is the power of C++ in games. The GC only clears the memory used(and marked for cleanup) when the memory resources are low. Other than that you may have finished using an object and marked it for deletion but it won't be cleared at that time.

    C# won't replace C++ as each programming language is made and used for a specific reason with advantages and disadvantages. Basic or now known as Visual Basic has been around for about 40 years now and it is still used a lot. C# is a new language - about 7 years old but it won't replace any language. It just adds programmers an extra option.
    Choosing which language to code in for your application depends on what you want to achieve - sure C++ is used a lot for games but that doesn't mean you have to use it.

    I hope I've helped in some way -

    Kind Regards
    lamedog

  5. #5
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    Quote Originally Posted by Sn4k36 View Post
    C# and the .net framework isn't ment just for general programming at all, it can do just about everything C++ can do, besides of one thing.. And that's programming a complete OS just using C# code..
    C++ is a general programming language... little confused.

    Quote Originally Posted by Sn4k36 View Post
    There is already a BIG BIG game out there on the market right now "Never Winternights 2", which was redone using C#. Most people don't even realize it at all..
    Hate to break it to you, but only the tools for NWN are written in C#. Do you have a source as to why you think the game engine is written in C# as well? There are parts of the game that do use .NET items, but the basic engine isn't written in C#.

    Quote Originally Posted by lamedog View Post
    I heard XNA/C# can get upto 95% of the performance of a c++ game which means C# games will be able to compete but the memory management, GC - Garbage Collector - is unreliable. Sure there are ways around it but in C# you don't have to take care of memory management which is the power of C++ in games. The GC only clears the memory used(and marked for cleanup) when the memory resources are low. Other than that you may have finished using an object and marked it for deletion but it won't be cleared at that time.
    That's not quite true... maybe by 'unreliable' you meant that the GC is undeterministic, but it doesn't wait until resources are low. Also, the GC simplifies memory management but does not get rid of having to care about it. You need to understand a thing or two about how the GC works in order to optimize your code fully, but there are common guidelines to follow to help you out.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

  6. #6
    Join Date
    Oct 2002
    Posts
    10
    People used to say the same thing arguing between C and C++ and between C and assembly. Anytime some of the processing is taken away from the programmer, people complain that it is not as good as coding it by hand. When people finally realize that they have to write the same code over and over to do a simple thing, they move to something that does it for them. I predict that this will happen soon with the move from native to managed languages. Managed languages do take some of the power away from the programmer, but it is usually stuff that you don't want to do anyway. There is tons of research and development that goes into making managed languages fast and reliable, sometimes even to the point that they are faster than their native counterparts. (This is because the bytecode for managed languages actually knows about objects and how to deal with them, while C++ uses virtual tables to look up object method definitions. Most managed languages are also Just in Time compiled as well, making the code virtually identical.) It is only a matter of time before games are coded for the most part in managed languages, just because it makes programming easier; less time is spent in implementation details and more is spent on actual programming. The great thing is that most managed languages let you break out into native code when needed, just like C++ lets you program in assembly when needed.

    As for what you should use on your project, unless you have the money, time, people and all the other resources that big game companies have, you should probably go with C# and XNA to get things done. In a small project, you will probably never have to worry about the things that might make you lean towards C++. What more likely will happen is that you will get bogged down in all of the implementation details that come along with C++ development. This is kind of the same argument that comes up in pre-optimizing code; you might as well go with the obvious approach until you see where the bottleneck is and then optimize.

    Another thing that you might want to ask is why to build a game engine in the first place. If it is for the learning experience of implementing graphics algorithms, logging, scripting and the like, then go for it. But, if you actually want to make a game, it would be better to start with one of the many engines or platforms already out there and made by smart people who think about these things every day. Something like XNA is a great place to start, while it's not an engine per se, most of the heavy lifting is already done for you.

    I know this is kind of long and rambling, but I have thought about all of these things as a hobby game programmer. I first wanted to do everything from scratch, but at some point you realize that re-inventing the wheel is only fun for learning purposes and not to actually get a game finished.
    Last edited by Golem59; 05-07-2007 at 10:16 PM.

  7. #7
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    Couldn't agree more Golem.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

  8. #8
    Join Date
    Jan 2003
    Posts
    536
    Its a very true, and a very valid, point that most "new" games today are heavily GPU bound, so the added CPU overhead could almost be considered "free" since your frame times are already 25ms or so in your GPU thread, while your game thread is twiddling its thumbs.

    This gets my gears spinning...and makes me want to do some more XNA work.

  9. #9
    Join Date
    Mar 2004
    Posts
    0
    I think Golem59 found some solid middle ground between mine and ownsd's debates about C#/C++. I have always known that C# provides an exellent framework for writing games and apps. But, like Golem59 said: do you want to know how games are made, or do you want to make a game? Games are mearly applications that use the graphics card more then, let's say, an internet browser this means that the same things you need to understand how apps are made are required to understand how games are made. Memery managment, the inner workings of the CPU and such are required to understand how apps are made (and therefore games). To make a game, you don't need that understanding. To make a game without thinking of the computer as a big scary black box, to know the difference between IP and ESP, to feel comfortable working with the computer to make things work, you need that understanding. Code security for example, is good to know when you have to decide if you want to expose a DLL interface for extension/modding (like the Source engine dose) or implament a scripting language (like the Unreal engines do). The difference between the two is vast; yet it is taken away when you only get into managed code.

    It is proven time and time again, that if you have no inclination to know how games are made, how they work with the computer, you will not find the act of coding enjoyable. It all boils down to what you are interested in and what you find fun. If you find in computers a passion, then you will learn all you can about them. Coding in C++, and or ASM, is one of the best ways to explore your passion about coding. If you don't possess a passion about coding, then you proboly won't care about how a computer works, and therefore it remains a big black box. Yet with the XNA framework, you find some middle ground in which you can do things that real developers who have a passion can do, yet you still do not exert as much engery and time into learning how it is done. Is this good or bad?

    Good: It gives people who have a great vision of a game a chance to make it possable. They do not acually posess a passion about coding, or else they would already have learned about how computers work with memey/code and such; in which case they would learn a language closer to the system like C++ for learning and experence purposes only. Of course, if they do posses a passion about coding, and already do understand all there is then XNA provides solid footing for writing games.

    Bad: It let's people who do not posses passions about coding to write code. Although I did say that is a good thing, it can also be a very bad thing too. Chances are, they will end up writing huge buggy messes of code, which would in most cases not reflect practices of OOP and such. If they hold no real passion, anything that works is fine for them. Belive it or not, there still is a whole frikin lot of alogorithms and advanced math required to make good solid games. If a person only knows XNA becuse they were told it was easy; they will be daunted by the maney extra things like alogorithims, and end up giving up or copy & pasting code, or trying thier own way, and in thier own inexperence, end up with big messes of sloppy code that works, yet is not maintainable, reuseable, and worst of all, not understood fully by the coder.

    So here I am again. Let me recap my main points:

    XNA is a great framework of code, letting the user of it not have to re-write redundent code. It also allows for people who have no passion in coding to make games. Yet it is not exlusive to that group. If used correctly, it can be a real help and be the basis of maney great games to come.

    People who have not a passion in code may abuse the XNA framework, simply becuse the XNA framework is shroweded in a guise of simplicity. Yes, advanced things can be done in a high-level fassion of OOP abstraction, yet the alogorathims and thery behind it is the same as any other game framework.


    So here is my advice: If you want to learn how to code games, if you have a passion of programing (and try it out if you are unsure), then learn C++ now and XNA later. If you have no desier of coding, no passion in working with the computer, then design the game and hire a programer or rent an engine.

    I hope the flame count of this post remains low

    And please post back with what you decide. We can help you, independent of which path you choose.
    Last edited by Nelson LaQuet; 05-08-2007 at 01:08 AM.

  10. #10
    Join Date
    Oct 2004
    Posts
    3,140
    I think C++/C# is good and all but you're all really overlooking the main point of this whole situation. It reminds me of a time once when some classmates and I were sitting in the cafeteria eating lunch and chatting away. Then all of a sudden someone started sliding m&ms across the table.

    Quote Originally Posted by <> View Post
    So here is my advice: If you want to learn how to code games, if you have a passion of programing (and try it out if you are unsure), then learn C++ now and XNA later. If you have no desier of coding, no passion in working with the computer, then design the game and hire a programer or rent an engine.
    You're so wrong in so many different ways I can't even count that high on 2 fingers. If you're looking to code games try actionscript. It's crazy powerful and you can code pretty much anything in it. I hear they used it as their main language in Unreal Engine 3.
    Last edited by Toastage; 05-08-2007 at 12:43 AM.

Page 1 of 7 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •