XNA Creators Club Online
Page 1 of 1 (20 items)
Sort Posts: Previous Next

C# Xna?

Last post 3/29/2008 12:52 PM by The ZMan. 19 replies.
  • 3/26/2008 5:00 PM

    C# Xna?

    Sorry if posting in wrong place.

    How come xna uses c#? I thought must games were made using c++.

    How different is c# to c++?
  • 3/26/2008 5:17 PM In reply to

    Re: C# Xna?

    If you know C++, you'll have no problem picking up C#.  It's just a different language; no better, no worse in the general case.

    But be warned:  a lot of people on here like to take the C++ vs. C# debate very seriously, so be prepared for a lot of negative responses to your question.  :(
    Microsoft DirectX/XNA MVP
  • 3/26/2008 5:32 PM In reply to

    Re: C# Xna?

    mr_fruitbowl:
    How different is c# to c++?

    Just download and peruse the numerous samples provided on this site :-) really the decision for c# vs c++ must be made for oneself ... we'll all be here to answer any C#/XNA questions you may have.
    Joel Martinez - XNA MVP
    Blog: http://codecube.net
    XNA Unit Testing: Scurvy Test
  • 3/26/2008 5:48 PM In reply to

    Re: C# Xna?

    mr_fruitbowl:
    How come xna uses c#?

    Developers in other industries around the world have recognized productivity gains by adopting the .NET Framework and managed languages. The XNA Community Game Platform (CGP) team believed that the game industry could also benefit from such productivity gains. The whole point of XNA Game Studio and the XNA Framework was to prove that managed code is not only viable for many games, but also has many advantages over native development.

    The XNA Framework is interesting precisely because it is managed code. If you don't find any merit to developing with managed code, then you have a virtually limitless set of alternatives already available.

    It is true that most games are developed with C++. We created XNA Game Studio to challenge that.

    Stephen Styrchak | XNA Game Studio Developer
  • 3/26/2008 5:54 PM In reply to

    Re: C# Xna?

    XNA uses C# because C# is faster and more efficient (timewise) for casual developers making games.

    C# is a managed language, which means that when nothing cares about an object any more it is automatically recycled by the garbage collector.  In C++ this had to be done manually.  (Not doing it and never reclaiming memory from dead objects is called a memory leak.)

    Under certain circumstances (very high performance) C++ is better suited for games, but such games are usually developed by large teams.

    I am developing Lexagon, a fast-paced multiplayer word game.
  • 3/26/2008 6:24 PM In reply to

    Re: C# Xna?

    ShawMishrak:
    But be warned:  a lot of people on here like to take the C++ vs. C# debate very seriously, so be prepared for a lot of negative responses to your question.  :(
    Haha. I started-out with C++, and "moved on" to C#. But, to be honest, I use them both all the time, and love them both very much.

    <3

  • 3/26/2008 7:23 PM In reply to

    Re: C# Xna?

    Here's my mental list of pros/cons

    C++ PROS:
    • Tons of examples
    • Tons of reusable libraries
    • Cross platform between PCs for free (free $$-wise but not no-extra-work free). C++ is portable to consoles IF you have a dev kit (these are vigilantly protected from almost everyone getting them - you pretty much need to be an established publisher or studio to have the opportunity to pay $10K each for them (my price could be wrong but I think it's ballpark) ) - again it's still a lot of work but it *can* be done
    • Tons of off-the-shelf libraries at many prices
    • I really like how deterministic C++ is
    C++ CONS:
    • *Can* be faster, though well written c# will run circles around poorly written C++ - and basically 99% of your code won't care about the performance difference.
    • Harder and MUCH more dangerous - you and anyone you work with needs to be more skilled if you're using c++ because it can be so dangerous
    • Higher learning curve
    • Static analysis tools are slower, more expensive, and of lesser quality
    C#/XNA Pros:
    • Considerable amount of examples (less than C++ but many more are being written)
    • EASY Cross platform support between xbox and PC but no non-microsoft product support
    • C# is easier and faster to develop in with better IDE support
    C#/XNA Cons:
    • Fewer libraries (though again, more are becoming available) - but for example I don't know of any that are the quality of ogre, PhysX, FMod, etc.
    • Theoretically you can't get the performance from C# you can get from C++ (though again, this probably won't matter for non-highend game titles)
    • Very few game engines available (I only know of a couple) - and none of them are as good as equivalently priced C++ engines.
    • If you're looking into getting into the games industry, having something in your portfolio that is C++ based might be important
    I havn't been so active with XNA in the last year but I've been thinking about it more recently. Some of my information could be outdated, in which case, please correct me so I can fix my post :)

    EDIT: p.s. some of these are opinions that you need to validate for yourself within the context of what you are doing!
  • 3/26/2008 7:50 PM In reply to

    Re: C# Xna?

    aclysma:

    C#/XNA Pros:
    • EASY Cross platform support between xbox and PC but no non-microsoft product support
    Why does everyone lump C# with XNA? C# as a language is very much supported on Linux and OS X through the Mono project. They have a full .NET 2.0 compliant compiler and CLR that works great. I've done some OpenGL C# stuff in OS X and it worked just as well as it did on Windows using their .NET CLR. I just want to keep trying to clear up this myth that C# is only available on Microsoft products. It might have better support on Microsoft products, but that doesn't mean support doesn't exist elsewhere.


    C#/XNA Cons:
    • Theoretically you can't get the performance from C# you can get from C++ (though again, this probably won't matter for non-highend game titles)
    • Very few game engines available (I only know of a couple) - and none of them are as good as equivalently priced C++ engines.
    • If you're looking into getting into the games industry, having something in your portfolio that is C++ based might be important


    Your list is pretty good, so I'm just going to comment on a few of them from my perspective.

    First of all the performance issue: most games nowadays wind up GPU limited. They try to apply too much bloom with too many polygons and too many other things that they wind up running out of GPU cycles before CPU cycles. I remember that was said to be a problem with Halo 3 and other AAA games. In those circumstances the CPU difference between C# and C++ is irrelevant. As long as you are GPU bound it won't matter whether your uber-awesome routine runs 2.5% faster because you still aren't going to get that GPU to draw faster.

    As for engines, I still point everyone to Blade3D. That is an amazing engine at what I consider an amazing price. You figure an indie title takes about 18 months to ship with maybe three people (generous figures depending on the game). Let's say your team wants to just try the engine out so you get the hobbyist license for three months. Then you finish out the next 15 months with the indie license and ship the game. Total engine cost for three seats like that: $1485 give or take some change. For the quality engine that is shaping up to be, that's quite a deal. I was temporarily with a team working on an XBLA title and the engine they were using was upwards of $8,000 a seat I believe. So Blade3D is really a steal for what it offers.

    And lastly regarding the industry, this all depends on what you want to do. I would be more comfortable working on the backend and tools myself and in that area C# is starting to really dominate (even in the games area). I've seen lots of help wanted posts for C# tool developers. Most studios do still want C++ knowledge for integrating the tools with the games (or to work on the games themselves), but I think more and more studios that do casual games will definitely see the benefit in C# for their games (regardless of whether its C# with OpenGL, MDX, XNA Framework, or plain WinForms).
  • 3/26/2008 8:09 PM In reply to

    Re: C# Xna?

    Heh, and right on cue this turns into a C++ vs. C# debate, even though the original question only asked what the differences were.  Gotta love this community.
    Microsoft DirectX/XNA MVP
  • 3/26/2008 9:14 PM In reply to

    Re: C# Xna?

    I'm not sure you can discuss the differences between the two properly without discussing some of the pros/cons people have brought up like performance, existing library support, cross-platformness, productivity etc. There's no use in having the most syntactily awesome language if it runs so slowly it's not usable, so poorly supported/documented you have no idea what you're doing and so difficult to work with that hello world takes a week. We certainly don't need another C#/C++ war, but generally I think this thread is staying on topic, at least for now.
  • 3/26/2008 9:25 PM In reply to

    Re: C# Xna?

    Adam Miles:
    We certainly don't need another C#/C++ war, but generally I think this thread is staying on topic, at least for now.

    You can tell that its still on topic becuase I've not locked it yet ;-) Kudos to all who are keeping it civil...

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 3/27/2008 8:32 AM In reply to

    Re: C# Xna?

    What do you mean by this?

    Harder and MUCH more dangerous - you and anyone you work with needs to be more skilled if you're using c++ because it can be so dangerous


    What do you mean by dangerous?
  • 3/27/2008 8:59 AM In reply to

    Re: C# Xna?

    mr_fruitbowl:
    What do you mean by this?

    Harder and MUCH more dangerous - you and anyone you work with needs to be more skilled if you're using c++ because it can be so dangerous


    What do you mean by dangerous?


    Being a lower level language, it's easier to write bad code that crashes your program in C++.  While a null pointer reference while throw an easily recoverable exception in C#, you'll get the ever so helpful "Your program has performed an illegal operation" crash dialog in Windows, or a segmentation fault on *nix; unless you do some platform-specific exception/signal handling.  Then again, most of these can be eliminated with a little bit of forethought and proper planning.  I assume that's what he means by needing to be "more skilled."  You actually have to think about what you're doing instead of just writing code and relying on the debugger/runtime to tell you what's wrong.

    It's not dangerous in the sense that it'll make your eyeballs bleed or your arm to fall off.
    Microsoft DirectX/XNA MVP
  • 3/27/2008 11:46 AM In reply to

    Re: C# Xna?

    to give an example of why it is more dangerous:

    C++ allows for direct memory control. if i have an array that is length 10, and i try to access the 11th index, C++ will let me do that and return to me whatever is in memory at the end of the array. if you are lucky, it is empty memory, and if you are unlucky, the memory is being used by some other program. if you were to then try to change that memory, you have a very bad crash on hand.

    if you try to do that same thing (access the 11th index on an array of length 10) in C#, you will get an ArrayIndexOutOfBounds exception.

    thus C# is much friendlier to beginner programmers as it keeps you from such potential snafoos.
  • 3/27/2008 1:37 PM In reply to

    Re: C# Xna?

    ShawMishrak:
    It's not dangerous in the sense that it'll make your eyeballs bleed or your arm to fall off.

    It ain't 'nam that done given me a peg leg. :-P

  • 3/27/2008 4:19 PM In reply to

    Re: C# Xna?

    Although the topic is really about C++ and C#, I'd like to just point out my experiences in C#/XNA vs C++/DirectX.
    While XNA is basically based off of DirectX, I think everyone here can agree it's a lot easier (and faster) to make things happen with the XNA API. It's just a lot more intuitive and there is less code required.

    That being said, in DirectX some people prefer the idea of writing 'boiler room code', code that runs at a much lower level (this coincides with the ideas that C++ is a lower level language). I personally enjoy C# at the moment, but I am using it as a sort of in-between in my learning. I've learned a lot of programming and OOP concepts just by coding games in C# with XNA and I know those concepts will transfer.

    Here's the caveat-- As cool as XNA is, as much as I love it and C# (And the uber amazing intellisense features in the C# Express IDE.. yeah I'm still using 1.0 refresh >.>); It is harder for me to get my games to my friends. Sure, I can put it on my Xbox, and in the future we will be able to put our games on XboxLive if it goes through the creator's club process. And that is amazing! I really dig it. The problem is, my friends who're on PC have to install quite a bit of software in order to get it to run. .NET 2.0 Framework, the very latest version of DirectX (which requires them generally to use the web installer and download windows genuine advantage). It is quite a bit to ask of some people, even if some of you disagree, a few of my friends won't do it because it's too much of a hassle.

    So if I was programming in DirectX, for the most part my friends would be able to run the exe and go with it.

    I'm not diminishing anything of what XNA is, and I really really love it and C#. I think the industry IS moving towards using C# more than C++, even though it is managed code. Will be something cool to see.

    My $0.02.
  • 3/28/2008 7:31 AM In reply to

    Re: C# Xna?

    Just to add me tuppence hapenny.

    Again I use both c++ and c# a lot. I also use java, assembler, c, and a load of other languages too boring to list.

    C#/XNA as a combination was designed for Microsoft products. However many other platforms can support C# and the .NET framework. Mono for one.

    AND I know of a couple of projects starting up to give XNA support to other OS's

    Add to that the fact that Microsoft products are currently THE mass market, and the cross platform support of c++ becomes less of an issue.

    One of the things I hate about c++ is that features designed into it to solve specific problems have been corrupted into programmer shortcuts.

    For example, you define a new type, say CROOK, and you need to be able to do

    CROOK a,b;

    CROOK c=a+b;

    Not a problem, you can define the behaviour of "+" when applied to a CROOK. Well done c++, nice feature.

    But I have worked in places where someone has redefined "+" to be a print routine

    This is not a very good example, but I hope you can see what I mean.

    There are so many ways of doing something in c++ that sometimes you can spend days trying to find a simple bug because the code is effectivly camoflaging the problem.

    I intially was wary of C#, it feels a lot like java to me, (which I hate by the way), but the combination of C#/.NET/XNA is a very powerful and easy to use system, and it's gradually won me over.

    There are still things I hate of course.

    Having to cast Enums to (int), type conversion in maths (byte a+byte b=int), *** about face way of array defenition, .... but these are trivail compared to the benefits of the system.

     

    Information is not knowledge, knowledge is not wisdom, wisdom is not truth, truth is not beauty, beauty is not love, love is not music, music is the best! Wisdom is the domain of the Wis (which is extinct).
  • 3/29/2008 10:16 AM In reply to

    Re: C# Xna?

    So xna only works with c# 2005? Any updates coming out for it to work with 2008?
  • 3/29/2008 10:33 AM In reply to

    Re: C# Xna?

    mr_fruitbowl:
    So xna only works with c# 2005? Any updates coming out for it to work with 2008?


    Im pretty sure XNA 3.0 will be designed for VS 2008.
  • 3/29/2008 12:52 PM In reply to

    Re: C# Xna?

    Skonk:
    mr_fruitbowl:
    So xna only works with c# 2005? Any updates coming out for it to work with 2008?



    Im pretty sure XNA 3.0 will be designed for VS 2008.

    Yes XNA GS 3 is for VS 2008 - See the FAQ for Visual Studio Version Compatibility - and remember always search the forums and look in the FAQ before asking things. This question as you can imagine gets asked about 5 times a week.

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
Page 1 of 1 (20 items) Previous Next